1 #!/usr/bin/env drgn 1 #!/usr/bin/env drgn 2 # SPDX-License-Identifier: GPL-2.0+ 2 # SPDX-License-Identifier: GPL-2.0+ 3 # 3 # 4 # Dump out the number of RCU callbacks outstan 4 # Dump out the number of RCU callbacks outstanding. 5 # 5 # 6 # On older kernels having multiple flavors of 6 # On older kernels having multiple flavors of RCU, this dumps out the 7 # number of callbacks for the most heavily use 7 # number of callbacks for the most heavily used flavor. 8 # 8 # 9 # Usage: sudo drgn rcu-cbs.py 9 # Usage: sudo drgn rcu-cbs.py 10 # 10 # 11 # Copyright (C) 2021 Facebook, Inc. 11 # Copyright (C) 2021 Facebook, Inc. 12 # 12 # 13 # Authors: Paul E. McKenney <paulmck@kernel.org 13 # Authors: Paul E. McKenney <paulmck@kernel.org> 14 14 15 import sys 15 import sys 16 import drgn 16 import drgn 17 from drgn import NULL, Object 17 from drgn import NULL, Object 18 from drgn.helpers.linux import * 18 from drgn.helpers.linux import * 19 19 20 def get_rdp0(prog): 20 def get_rdp0(prog): 21 try: 21 try: 22 rdp0 = prog.variable('rcu_pree 22 rdp0 = prog.variable('rcu_preempt_data', 'kernel/rcu/tree.c'); 23 except LookupError: 23 except LookupError: 24 rdp0 = NULL; 24 rdp0 = NULL; 25 25 26 if rdp0 == NULL: 26 if rdp0 == NULL: 27 try: 27 try: 28 rdp0 = prog.variable(' 28 rdp0 = prog.variable('rcu_sched_data', 29 ' 29 'kernel/rcu/tree.c'); 30 except LookupError: 30 except LookupError: 31 rdp0 = NULL; 31 rdp0 = NULL; 32 32 33 if rdp0 == NULL: 33 if rdp0 == NULL: 34 rdp0 = prog.variable('rcu_data 34 rdp0 = prog.variable('rcu_data', 'kernel/rcu/tree.c'); 35 return rdp0.address_of_(); 35 return rdp0.address_of_(); 36 36 37 rdp0 = get_rdp0(prog); 37 rdp0 = get_rdp0(prog); 38 38 39 # Sum up RCU callbacks. 39 # Sum up RCU callbacks. 40 sum = 0; 40 sum = 0; 41 for cpu in for_each_possible_cpu(prog): 41 for cpu in for_each_possible_cpu(prog): 42 rdp = per_cpu_ptr(rdp0, cpu); 42 rdp = per_cpu_ptr(rdp0, cpu); 43 len = rdp.cblist.len.value_(); 43 len = rdp.cblist.len.value_(); 44 # print("CPU " + str(cpu) + " RCU call 44 # print("CPU " + str(cpu) + " RCU callbacks: " + str(len)); 45 sum += len; 45 sum += len; 46 print("Number of RCU callbacks in flight: " + 46 print("Number of RCU callbacks in flight: " + str(sum));
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.