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

Configure Feed

Select the types of activity you want to include in your feed.

scripts/gdb/tasks: fix lx-ps command error

Since commit 8e1f385104ac ("kill task_struct->thread_group") remove
the thread_group, we will encounter below issue.

(gdb) lx-ps
TASK PID COMM
0xffff800086503340 0 swapper/0
Python Exception <class 'gdb.error'>: There is no member named thread_group.
Error occurred in Python: There is no member named thread_group.

We use signal->thread_head to iterate all threads instead.

[Kuan-Ying.Lee@mediatek.com: v2]
Link: https://lkml.kernel.org/r/20231129065142.13375-2-Kuan-Ying.Lee@mediatek.com
Link: https://lkml.kernel.org/r/20231127070404.4192-2-Kuan-Ying.Lee@mediatek.com
Fixes: 8e1f385104ac ("kill task_struct->thread_group")
Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Chinwen Chang <chinwen.chang@mediatek.com>
Cc: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Qun-Wei Lin <qun-wei.lin@mediatek.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kuan-Ying Lee and committed by
Andrew Morton
854f2764 97219cc3

+7 -11
+7 -11
scripts/gdb/linux/tasks.py
··· 13 13 14 14 import gdb 15 15 16 - from linux import utils 16 + from linux import utils, lists 17 17 18 18 19 19 task_type = utils.CachedType("struct task_struct") ··· 22 22 def task_lists(): 23 23 task_ptr_type = task_type.get_type().pointer() 24 24 init_task = gdb.parse_and_eval("init_task").address 25 - t = g = init_task 25 + t = init_task 26 26 27 27 while True: 28 - while True: 29 - yield t 28 + thread_head = t['signal']['thread_head'] 29 + for thread in lists.list_for_each_entry(thread_head, task_ptr_type, 'thread_node'): 30 + yield thread 30 31 31 - t = utils.container_of(t['thread_group']['next'], 32 - task_ptr_type, "thread_group") 33 - if t == g: 34 - break 35 - 36 - t = g = utils.container_of(g['tasks']['next'], 37 - task_ptr_type, "tasks") 32 + t = utils.container_of(t['tasks']['next'], 33 + task_ptr_type, "tasks") 38 34 if t == init_task: 39 35 return 40 36