Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scripts/gdb: update documentation for lx_per_cpu

Commit db08c53fdd542bb7f83b ("scripts/gdb: fix parameter handling in
$lx_per_cpu") changed the parameter handling of lx_per_cpu to use GdbValue
instead of parsing the variable name. Update the documentation to reflect
the new lx_per_cpu usage. Update the hrtimer_bases example to use rb_tree
instead of the timerqueue_head.next pointer removed in commit
511885d7061eda3eb1fa ("lib/timerqueue: Rely on rbtree semantics for next
timer").

Link: https://lkml.kernel.org/r/20250503123234.2407184-3-illia@yshyn.com
Signed-off-by: Illia Ostapyshyn <illia@yshyn.com>
Cc: Alex Shi <alexs@kernel.org>
Cc: Brendan Jackman <jackmanb@google.com>
Cc: Dongliang Mu <dzm91@hust.edu.cn>
Cc: Florian Rommel <mail@florommel.de>
Cc: Hu Haowen <2023002089@link.tyut.edu.cn>
Cc: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kieran Bingham <kbingham@kernel.org>
Cc: Yanteng Si <si.yanteng@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Illia Ostapyshyn and committed by
Andrew Morton
09e1d93a 6be7045c

+47 -59
+15 -19
Documentation/process/debugging/gdb-kernel-debugging.rst
··· 127 127 128 128 - Make use of the per-cpu function for the current or a specified CPU:: 129 129 130 - (gdb) p $lx_per_cpu("runqueues").nr_running 130 + (gdb) p $lx_per_cpu(runqueues).nr_running 131 131 $3 = 1 132 - (gdb) p $lx_per_cpu("runqueues", 2).nr_running 132 + (gdb) p $lx_per_cpu(runqueues, 2).nr_running 133 133 $4 = 0 134 134 135 135 - Dig into hrtimers using the container_of helper:: 136 136 137 - (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next 138 - (gdb) p *$container_of($next, "struct hrtimer", "node") 137 + (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost 138 + (gdb) p *$container_of($leftmost, "struct hrtimer", "node") 139 139 $5 = { 140 140 node = { 141 141 node = { 142 - __rb_parent_color = 18446612133355256072, 143 - rb_right = 0x0 <irq_stack_union>, 144 - rb_left = 0x0 <irq_stack_union> 142 + __rb_parent_color = 18446612686384860673, 143 + rb_right = 0xffff888231da8b00, 144 + rb_left = 0x0 145 145 }, 146 - expires = { 147 - tv64 = 1835268000000 148 - } 146 + expires = 1228461000000 149 147 }, 150 - _softexpires = { 151 - tv64 = 1835268000000 152 - }, 153 - function = 0xffffffff81078232 <tick_sched_timer>, 154 - base = 0xffff88003fd0d6f0, 155 - state = 1, 156 - start_pid = 0, 157 - start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, 158 - start_comm = "swapper/2\000\000\000\000\000\000" 148 + _softexpires = 1228461000000, 149 + function = 0xffffffff8137ab20 <tick_nohz_handler>, 150 + base = 0xffff888231d9b4c0, 151 + state = 1 '\001', 152 + is_rel = 0 '\000', 153 + is_soft = 0 '\000', 154 + is_hard = 1 '\001' 159 155 } 160 156 161 157
+15 -19
Documentation/translations/zh_CN/dev-tools/gdb-kernel-debugging.rst
··· 120 120 121 121 - 对当前或指定的CPU使用per-cpu函数:: 122 122 123 - (gdb) p $lx_per_cpu("runqueues").nr_running 123 + (gdb) p $lx_per_cpu(runqueues).nr_running 124 124 $3 = 1 125 - (gdb) p $lx_per_cpu("runqueues", 2).nr_running 125 + (gdb) p $lx_per_cpu(runqueues, 2).nr_running 126 126 $4 = 0 127 127 128 128 - 使用container_of查看更多hrtimers信息:: 129 129 130 - (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next 131 - (gdb) p *$container_of($next, "struct hrtimer", "node") 130 + (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost 131 + (gdb) p *$container_of($leftmost, "struct hrtimer", "node") 132 132 $5 = { 133 133 node = { 134 134 node = { 135 - __rb_parent_color = 18446612133355256072, 136 - rb_right = 0x0 <irq_stack_union>, 137 - rb_left = 0x0 <irq_stack_union> 135 + __rb_parent_color = 18446612686384860673, 136 + rb_right = 0xffff888231da8b00, 137 + rb_left = 0x0 138 138 }, 139 - expires = { 140 - tv64 = 1835268000000 141 - } 139 + expires = 1228461000000 142 140 }, 143 - _softexpires = { 144 - tv64 = 1835268000000 145 - }, 146 - function = 0xffffffff81078232 <tick_sched_timer>, 147 - base = 0xffff88003fd0d6f0, 148 - state = 1, 149 - start_pid = 0, 150 - start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, 151 - start_comm = "swapper/2\000\000\000\000\000\000" 141 + _softexpires = 1228461000000, 142 + function = 0xffffffff8137ab20 <tick_nohz_handler>, 143 + base = 0xffff888231d9b4c0, 144 + state = 1 '\001', 145 + is_rel = 0 '\000', 146 + is_soft = 0 '\000', 147 + is_hard = 1 '\001' 152 148 } 153 149 154 150
+15 -19
Documentation/translations/zh_TW/dev-tools/gdb-kernel-debugging.rst
··· 116 116 117 117 - 對當前或指定的CPU使用per-cpu函數:: 118 118 119 - (gdb) p $lx_per_cpu("runqueues").nr_running 119 + (gdb) p $lx_per_cpu(runqueues).nr_running 120 120 $3 = 1 121 - (gdb) p $lx_per_cpu("runqueues", 2).nr_running 121 + (gdb) p $lx_per_cpu(runqueues, 2).nr_running 122 122 $4 = 0 123 123 124 124 - 使用container_of查看更多hrtimers信息:: 125 125 126 - (gdb) set $next = $lx_per_cpu("hrtimer_bases").clock_base[0].active.next 127 - (gdb) p *$container_of($next, "struct hrtimer", "node") 126 + (gdb) set $leftmost = $lx_per_cpu(hrtimer_bases).clock_base[0].active.rb_root.rb_leftmost 127 + (gdb) p *$container_of($leftmost, "struct hrtimer", "node") 128 128 $5 = { 129 129 node = { 130 130 node = { 131 - __rb_parent_color = 18446612133355256072, 132 - rb_right = 0x0 <irq_stack_union>, 133 - rb_left = 0x0 <irq_stack_union> 131 + __rb_parent_color = 18446612686384860673, 132 + rb_right = 0xffff888231da8b00, 133 + rb_left = 0x0 134 134 }, 135 - expires = { 136 - tv64 = 1835268000000 137 - } 135 + expires = 1228461000000 138 136 }, 139 - _softexpires = { 140 - tv64 = 1835268000000 141 - }, 142 - function = 0xffffffff81078232 <tick_sched_timer>, 143 - base = 0xffff88003fd0d6f0, 144 - state = 1, 145 - start_pid = 0, 146 - start_site = 0xffffffff81055c1f <hrtimer_start_range_ns+20>, 147 - start_comm = "swapper/2\000\000\000\000\000\000" 137 + _softexpires = 1228461000000, 138 + function = 0xffffffff8137ab20 <tick_nohz_handler>, 139 + base = 0xffff888231d9b4c0, 140 + state = 1 '\001', 141 + is_rel = 0 '\000', 142 + is_soft = 0 '\000', 143 + is_hard = 1 '\001' 148 144 } 149 145 150 146
+2 -2
scripts/gdb/linux/cpus.py
··· 141 141 class PerCpu(gdb.Function): 142 142 """Return per-cpu variable. 143 143 144 - $lx_per_cpu("VAR"[, CPU]): Return the per-cpu variable called VAR for the 144 + $lx_per_cpu(VAR[, CPU]): Return the per-cpu variable called VAR for the 145 145 given CPU number. If CPU is omitted, the CPU of the current context is used. 146 146 Note that VAR has to be quoted as string.""" 147 147 ··· 158 158 class PerCpuPtr(gdb.Function): 159 159 """Return per-cpu pointer. 160 160 161 - $lx_per_cpu_ptr("VAR"[, CPU]): Return the per-cpu pointer called VAR for the 161 + $lx_per_cpu_ptr(VAR[, CPU]): Return the per-cpu pointer called VAR for the 162 162 given CPU number. If CPU is omitted, the CPU of the current context is used. 163 163 Note that VAR has to be quoted as string.""" 164 164