Skip to contentSkip to conversation

scripts/gdb: timerlist fixes

PATCH RESEND In review Florian Fainelli 2 participants 6 messages Apr 6, 2023 – Apr 8, 2023 GDB kernel debugging helper scripts

lore
Share & tools
lore
#0 lore raw

cover scripts/gdb: timerlist fixes

Hi Andrew,

Since you have been collecting my patches touching scripts/gdb, (re)sending those fixes from Amjad that restore a functional "lx-timerlist" scripts.

Thanks!

Amjad Ouled-Ameur (3):
scripts/gdb: timerlist: use range instead of xrange scripts/gdb: timerlist: fix rb_node access scripts/gdb: timerlist: convert int chunks to str

 scripts/gdb/linux/timerlist.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH RESEND 1/3 scripts/gdb: timerlist: use range instead of xrange

From: Amjad Ouled-Ameur <[email protected]>

xrange has been renamed to range in Python 3. Therefore, timerlist currently fails with NameError exception:

Python Exception <class 'NameError'> name 'xrange' is not defined.

Use range instead of xrange.

---
 scripts/gdb/linux/timerlist.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/timerlist.py +1 -1
index 071d0dd5a634..fac951236dc4 100644
@@ -73,7 +73,7 @@ def print_cpu(hrtimer_bases, cpu, max_clock_bases):
     ts = cpus.per_cpu(tick_sched_ptr, cpu)
 
     text = "cpu: {}\n".format(cpu)
-    for i in xrange(max_clock_bases):
+    for i in range(max_clock_bases):
         text += " clock {}:\n".format(i)
         text += print_base(cpu_base['clock_base'][i])
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH RESEND 2/3 scripts/gdb: timerlist: fix rb_node access

In reply to Florian Fainelli

From: Amjad Ouled-Ameur <[email protected]>

"struct timerqueue_head" no longer has "next" member since v5.4-rc1:
commit 511885d7061e ("lib/timerqueue: Rely on rbtree semantics for next timer")

Therefore, access "rb_node" through active->rb_root->rb_root->rb_node.

Moreoever, remove curr.address.cast() on rb_node as this breaks the code and is not necessary.

---
 scripts/gdb/linux/timerlist.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/gdb/linux/timerlist.py +1 -2
index fac951236dc4..d16909f8df35 100644
@@ -43,8 +43,7 @@ def print_timer(rb_node, idx):
 
 
 def print_active_timers(base):
-    curr = base['active']['next']['node']
-    curr = curr.address.cast(rbtree.rb_node_type.get_type().pointer())
+    curr = base['active']['rb_root']['rb_root']['rb_node']
     idx = 0
     while curr:
         yield print_timer(curr, idx)
Signature · 1 line
2.34.1
#3 lore raw

PATCH RESEND 3/3 scripts/gdb: timerlist: convert int chunks to str

In reply to Florian Fainelli

From: Amjad Ouled-Ameur <[email protected]>

join() expects strings but integers are given.

Convert chunks list to strings before passing it to join()

---
 scripts/gdb/linux/timerlist.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/gdb/linux/timerlist.py +1 -1
index d16909f8df35..98bb9a239283 100644
@@ -172,7 +172,7 @@ def pr_cpumask(mask):
     if 0 < extra <= 4:
         chunks[0] = chunks[0][0]  # Cut off the first 0
 
-    return "".join(chunks)
+    return "".join(str(chunks))
 
 
 class LxTimerList(gdb.Command):
Signature · 1 line
2.34.1
#4 lore raw
In reply to Florian Fainelli
Quoted 3 lines · On Thu, 6 Apr 2023 15:12:14 -0700 Florian Fainelli <[email protected]>…

Since you have been collecting my patches touching scripts/gdb, (re)sending those fixes from Amjad that restore a functional "lx-timerlist" scripts.

The first two issues appear to have already been fixed:

https://lore.kernel.org/all/TYCP286MB21463BD277330B26DDC18903C6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u
https://lore.kernel.org/all/TYCP286MB2146EE1180A4D5176CBA8AB2C6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u
https://lore.kernel.org/all/TYCP286MB214640FF0E7F04AC3926A39EC6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u

Thanks, I'll queue up the third patch.

(And I'm going to have to redo the above three patches and rebase, because I now see hotmail's Message-ID's fooled my Link: extraction script, grr)

While I'm there, I'm wondering if the xrange patch should be backported to -stable kernels. We want gdb to work well with Python3 on older kernels, yes?

Also, I added your Signed-off-by: to "scripts/gdb: timerlist: convert int chunks to str", since you were on the patch delivery path.

#5 lore raw
Quoted 11 lines · Andrew Morton
Quoted 3 lines · On Thu, 6 Apr 2023 15:12:14 -0700 Florian Fainelli <[email protected]>…

Since you have been collecting my patches touching scripts/gdb, (re)sending those fixes from Amjad that restore a functional "lx-timerlist" scripts.

The first two issues appear to have already been fixed:

https://lore.kernel.org/all/TYCP286MB21463BD277330B26DDC18903C6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u
https://lore.kernel.org/all/TYCP286MB2146EE1180A4D5176CBA8AB2C6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u
https://lore.kernel.org/all/TYCP286MB214640FF0E7F04AC3926A39EC6819@TYCP286MB2146.JPNP286.PROD.OUTLOOK.COM/T/#u

Oh yes, indeed there was a prior submission by Peng.

Quoted 11 lines

Thanks, I'll queue up the third patch.

(And I'm going to have to redo the above three patches and rebase, because I now see hotmail's Message-ID's fooled my Link: extraction script, grr)

While I'm there, I'm wondering if the xrange patch should be backported to -stable kernels. We want gdb to work well with Python3 on older kernels, yes?

I would say so, yes.

Quoted 5 lines

Also, I added your Signed-off-by: to "scripts/gdb: timerlist: convert int chunks to str", since you were on the patch delivery path.

Thanks!

Signature · 1 line
Florian