* [PATCH v2 0/3] Fix GDB commands error @ 2023-11-29 6:51 ` Kuan-Ying Lee 0 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, linux-kernel, linux-arm-kernel, linux-mediatek This patchset fix some issues of gdb command. Patch 1: - Fix lx-ps command error Patch 2: - Fix stackdepot usage error Patch 3: - Remove exception handling - Refine the printing format --- V1->V2: - Remove unnecessary variable. (Thanks Oleg) - Refine commit message. Kuan-Ying Lee (3): scripts/gdb/tasks: Fix lx-ps command error scripts/gdb/stackdepot: Rename pool_index to pools_num scripts/gdb: Remove exception handling and refine print format scripts/gdb/linux/page_owner.py | 58 ++++++++++++++------------------- scripts/gdb/linux/slab.py | 3 +- scripts/gdb/linux/stackdepot.py | 6 ++-- scripts/gdb/linux/tasks.py | 18 ++++------ 4 files changed, 36 insertions(+), 49 deletions(-) -- 2.18.0 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 0/3] Fix GDB commands error @ 2023-11-29 6:51 ` Kuan-Ying Lee 0 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, linux-kernel, linux-arm-kernel, linux-mediatek This patchset fix some issues of gdb command. Patch 1: - Fix lx-ps command error Patch 2: - Fix stackdepot usage error Patch 3: - Remove exception handling - Refine the printing format --- V1->V2: - Remove unnecessary variable. (Thanks Oleg) - Refine commit message. Kuan-Ying Lee (3): scripts/gdb/tasks: Fix lx-ps command error scripts/gdb/stackdepot: Rename pool_index to pools_num scripts/gdb: Remove exception handling and refine print format scripts/gdb/linux/page_owner.py | 58 ++++++++++++++------------------- scripts/gdb/linux/slab.py | 3 +- scripts/gdb/linux/stackdepot.py | 6 ++-- scripts/gdb/linux/tasks.py | 18 ++++------ 4 files changed, 36 insertions(+), 49 deletions(-) -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 6:51 ` Kuan-Ying Lee -1 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, Oleg Nesterov Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, Kuan-Ying Lee, stable, linux-kernel, linux-arm-kernel, linux-mediatek 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. Fixes: 8e1f385104ac ("kill task_struct->thread_group") Cc: stable@vger.kernel.org Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/tasks.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index 17ec19e9b5bf..aa5ab6251f76 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py @@ -13,7 +13,7 @@ import gdb -from linux import utils +from linux import utils, lists task_type = utils.CachedType("struct task_struct") @@ -22,19 +22,15 @@ task_type = utils.CachedType("struct task_struct") def task_lists(): task_ptr_type = task_type.get_type().pointer() init_task = gdb.parse_and_eval("init_task").address - t = g = init_task + t = init_task while True: - while True: - yield t + thread_head = t['signal']['thread_head'] + for thread in lists.list_for_each_entry(thread_head, task_ptr_type, 'thread_node'): + yield thread - t = utils.container_of(t['thread_group']['next'], - task_ptr_type, "thread_group") - if t == g: - break - - t = g = utils.container_of(g['tasks']['next'], - task_ptr_type, "tasks") + t = utils.container_of(t['tasks']['next'], + task_ptr_type, "tasks") if t == init_task: return -- 2.18.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error @ 2023-11-29 6:51 ` Kuan-Ying Lee 0 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, Oleg Nesterov Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, Kuan-Ying Lee, stable, linux-kernel, linux-arm-kernel, linux-mediatek 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. Fixes: 8e1f385104ac ("kill task_struct->thread_group") Cc: stable@vger.kernel.org Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/tasks.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/scripts/gdb/linux/tasks.py b/scripts/gdb/linux/tasks.py index 17ec19e9b5bf..aa5ab6251f76 100644 --- a/scripts/gdb/linux/tasks.py +++ b/scripts/gdb/linux/tasks.py @@ -13,7 +13,7 @@ import gdb -from linux import utils +from linux import utils, lists task_type = utils.CachedType("struct task_struct") @@ -22,19 +22,15 @@ task_type = utils.CachedType("struct task_struct") def task_lists(): task_ptr_type = task_type.get_type().pointer() init_task = gdb.parse_and_eval("init_task").address - t = g = init_task + t = init_task while True: - while True: - yield t + thread_head = t['signal']['thread_head'] + for thread in lists.list_for_each_entry(thread_head, task_ptr_type, 'thread_node'): + yield thread - t = utils.container_of(t['thread_group']['next'], - task_ptr_type, "thread_group") - if t == g: - break - - t = g = utils.container_of(g['tasks']['next'], - task_ptr_type, "tasks") + t = utils.container_of(t['tasks']['next'], + task_ptr_type, "tasks") if t == init_task: return -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 8:10 ` Oleg Nesterov -1 siblings, 0 replies; 16+ messages in thread From: Oleg Nesterov @ 2023-11-29 8:10 UTC (permalink / raw) To: Kuan-Ying Lee Cc: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On 11/29, Kuan-Ying Lee wrote: > > 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. Thanks again, Acked-by: Oleg Nesterov <oleg@redhat.com> > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > Cc: stable@vger.kernel.org Is it possible to merge this simple change before v6.7 ? Then "cc: stable" can be removed. Oleg. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error @ 2023-11-29 8:10 ` Oleg Nesterov 0 siblings, 0 replies; 16+ messages in thread From: Oleg Nesterov @ 2023-11-29 8:10 UTC (permalink / raw) To: Kuan-Ying Lee Cc: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On 11/29, Kuan-Ying Lee wrote: > > 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. Thanks again, Acked-by: Oleg Nesterov <oleg@redhat.com> > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > Cc: stable@vger.kernel.org Is it possible to merge this simple change before v6.7 ? Then "cc: stable" can be removed. Oleg. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error 2023-11-29 8:10 ` Oleg Nesterov @ 2023-11-29 22:15 ` Andrew Morton -1 siblings, 0 replies; 16+ messages in thread From: Andrew Morton @ 2023-11-29 22:15 UTC (permalink / raw) To: Oleg Nesterov Cc: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On Wed, 29 Nov 2023 09:10:09 +0100 Oleg Nesterov <oleg@redhat.com> wrote: > > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > > Cc: stable@vger.kernel.org > > Is it possible to merge this simple change before v6.7 ? > Then "cc: stable" can be removed. Yes, I shall do all that. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error @ 2023-11-29 22:15 ` Andrew Morton 0 siblings, 0 replies; 16+ messages in thread From: Andrew Morton @ 2023-11-29 22:15 UTC (permalink / raw) To: Oleg Nesterov Cc: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On Wed, 29 Nov 2023 09:10:09 +0100 Oleg Nesterov <oleg@redhat.com> wrote: > > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > > Cc: stable@vger.kernel.org > > Is it possible to merge this simple change before v6.7 ? > Then "cc: stable" can be removed. Yes, I shall do all that. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 22:33 ` Florian Fainelli -1 siblings, 0 replies; 16+ messages in thread From: Florian Fainelli @ 2023-11-29 22:33 UTC (permalink / raw) To: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, Oleg Nesterov Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On 11/28/23 22:51, Kuan-Ying Lee wrote: > 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. > > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > Cc: stable@vger.kernel.org > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error @ 2023-11-29 22:33 ` Florian Fainelli 0 siblings, 0 replies; 16+ messages in thread From: Florian Fainelli @ 2023-11-29 22:33 UTC (permalink / raw) To: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno, Andrew Morton, Oleg Nesterov Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, stable, linux-kernel, linux-arm-kernel, linux-mediatek On 11/28/23 22:51, Kuan-Ying Lee wrote: > 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. > > Fixes: 8e1f385104ac ("kill task_struct->thread_group") > Cc: stable@vger.kernel.org > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 2/3] scripts/gdb/stackdepot: Rename pool_index to pools_num 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 6:51 ` Kuan-Ying Lee -1 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, Andrey Konovalov, linux-kernel, linux-arm-kernel, linux-mediatek After stackdepot evicting support patchset[1], we rename pool_index to pools_num. To avoid from the below issue, we rename consistently in gdb scripts. Python Exception <class 'gdb.error'>: No symbol "pool_index" in current context. Error occurred in Python: No symbol "pool_index" in current context. [1] https://lore.kernel.org/linux-mm/cover.1700502145.git.andreyknvl@google.com/ Cc: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/stackdepot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/gdb/linux/stackdepot.py b/scripts/gdb/linux/stackdepot.py index 047d329a6a12..0281d9de4b7c 100644 --- a/scripts/gdb/linux/stackdepot.py +++ b/scripts/gdb/linux/stackdepot.py @@ -25,10 +25,10 @@ def stack_depot_fetch(handle): handle_parts_t = gdb.lookup_type("union handle_parts") parts = handle.cast(handle_parts_t) offset = parts['offset'] << DEPOT_STACK_ALIGN - pool_index_cached = gdb.parse_and_eval('pool_index') + pools_num = gdb.parse_and_eval('pools_num') - if parts['pool_index'] > pool_index_cached: - gdb.write("pool index %d out of bounds (%d) for stack id 0x%08x\n" % (parts['pool_index'], pool_index_cached, handle)) + if parts['pool_index'] > pools_num: + gdb.write("pool index %d out of bounds (%d) for stack id 0x%08x\n" % (parts['pool_index'], pools_num, handle)) return gdb.Value(0), 0 stack_pools = gdb.parse_and_eval('stack_pools') -- 2.18.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/3] scripts/gdb/stackdepot: Rename pool_index to pools_num @ 2023-11-29 6:51 ` Kuan-Ying Lee 0 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, Andrey Konovalov, linux-kernel, linux-arm-kernel, linux-mediatek After stackdepot evicting support patchset[1], we rename pool_index to pools_num. To avoid from the below issue, we rename consistently in gdb scripts. Python Exception <class 'gdb.error'>: No symbol "pool_index" in current context. Error occurred in Python: No symbol "pool_index" in current context. [1] https://lore.kernel.org/linux-mm/cover.1700502145.git.andreyknvl@google.com/ Cc: Andrey Konovalov <andreyknvl@google.com> Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/stackdepot.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/gdb/linux/stackdepot.py b/scripts/gdb/linux/stackdepot.py index 047d329a6a12..0281d9de4b7c 100644 --- a/scripts/gdb/linux/stackdepot.py +++ b/scripts/gdb/linux/stackdepot.py @@ -25,10 +25,10 @@ def stack_depot_fetch(handle): handle_parts_t = gdb.lookup_type("union handle_parts") parts = handle.cast(handle_parts_t) offset = parts['offset'] << DEPOT_STACK_ALIGN - pool_index_cached = gdb.parse_and_eval('pool_index') + pools_num = gdb.parse_and_eval('pools_num') - if parts['pool_index'] > pool_index_cached: - gdb.write("pool index %d out of bounds (%d) for stack id 0x%08x\n" % (parts['pool_index'], pool_index_cached, handle)) + if parts['pool_index'] > pools_num: + gdb.write("pool index %d out of bounds (%d) for stack id 0x%08x\n" % (parts['pool_index'], pools_num, handle)) return gdb.Value(0), 0 stack_pools = gdb.parse_and_eval('stack_pools') -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/3] scripts/gdb/stackdepot: Rename pool_index to pools_num 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 22:33 ` Florian Fainelli -1 siblings, 0 replies; 16+ messages in thread From: Florian Fainelli @ 2023-11-29 22:33 UTC (permalink / raw) To: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Andrey Konovalov, linux-kernel, linux-arm-kernel, linux-mediatek On 11/28/23 22:51, Kuan-Ying Lee wrote: > After stackdepot evicting support patchset[1], we rename > pool_index to pools_num. > > To avoid from the below issue, we rename consistently in > gdb scripts. > > Python Exception <class 'gdb.error'>: No symbol "pool_index" in current > context. > Error occurred in Python: No symbol "pool_index" in current context. > > [1] https://lore.kernel.org/linux-mm/cover.1700502145.git.andreyknvl@google.com/ > Cc: Andrey Konovalov <andreyknvl@google.com> > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/3] scripts/gdb/stackdepot: Rename pool_index to pools_num @ 2023-11-29 22:33 ` Florian Fainelli 0 siblings, 0 replies; 16+ messages in thread From: Florian Fainelli @ 2023-11-29 22:33 UTC (permalink / raw) To: Kuan-Ying Lee, Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Andrey Konovalov, linux-kernel, linux-arm-kernel, linux-mediatek On 11/28/23 22:51, Kuan-Ying Lee wrote: > After stackdepot evicting support patchset[1], we rename > pool_index to pools_num. > > To avoid from the below issue, we rename consistently in > gdb scripts. > > Python Exception <class 'gdb.error'>: No symbol "pool_index" in current > context. > Error occurred in Python: No symbol "pool_index" in current context. > > [1] https://lore.kernel.org/linux-mm/cover.1700502145.git.andreyknvl@google.com/ > Cc: Andrey Konovalov <andreyknvl@google.com> > Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> -- Florian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 3/3] scripts/gdb: Remove exception handling and refine print format 2023-11-29 6:51 ` Kuan-Ying Lee @ 2023-11-29 6:51 ` Kuan-Ying Lee -1 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, linux-kernel, linux-arm-kernel, linux-mediatek 1. When we crash on a page, we want to check what happened on this page instead of skipping this page by try-catch block. Thus, removing the try-catch block. 2. Remove redundant comma and print the task name properly. Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/page_owner.py | 58 ++++++++++++++------------------- scripts/gdb/linux/slab.py | 3 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/scripts/gdb/linux/page_owner.py b/scripts/gdb/linux/page_owner.py index 844fd5d0c912..8e713a09cfe7 100644 --- a/scripts/gdb/linux/page_owner.py +++ b/scripts/gdb/linux/page_owner.py @@ -122,27 +122,24 @@ class DumpPageOwner(gdb.Command): if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER_ALLOCATED)): gdb.write("page_owner is not allocated\n") - try: - page_owner = self.get_page_owner(page_ext) - gdb.write("Page last allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ - (page_owner["order"], page_owner["gfp_mask"],\ - page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ - page_owner["ts_nsec"], page_owner["free_ts_nsec"])) - gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) - if page_owner["handle"] == 0: - gdb.write('page_owner allocation stack trace missing\n') - else: - stackdepot.stack_depot_print(page_owner["handle"]) + page_owner = self.get_page_owner(page_ext) + gdb.write("Page last allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ + (page_owner["order"], page_owner["gfp_mask"],\ + page_owner["pid"], page_owner["tgid"], page_owner["comm"].string(),\ + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) + if page_owner["handle"] == 0: + gdb.write('page_owner allocation stack trace missing\n') + else: + stackdepot.stack_depot_print(page_owner["handle"]) - if page_owner["free_handle"] == 0: - gdb.write('page_owner free stack trace missing\n') - else: - gdb.write('page last free stack trace:\n') - stackdepot.stack_depot_print(page_owner["free_handle"]) - if page_owner['last_migrate_reason'] != -1: - gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) - except: - gdb.write("\n") + if page_owner["free_handle"] == 0: + gdb.write('page_owner free stack trace missing\n') + else: + gdb.write('page last free stack trace:\n') + stackdepot.stack_depot_print(page_owner["free_handle"]) + if page_owner['last_migrate_reason'] != -1: + gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) def read_page_owner(self): pfn = self.min_pfn @@ -173,18 +170,13 @@ class DumpPageOwner(gdb.Command): pfn += 1 continue - try: - page_owner = self.get_page_owner(page_ext) - gdb.write("Page allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ - (page_owner["order"], page_owner["gfp_mask"],\ - page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ - page_owner["ts_nsec"], page_owner["free_ts_nsec"])) - gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) - stackdepot.stack_depot_print(page_owner["handle"]) - pfn += (1 << page_owner["order"]) - continue - except: - gdb.write("\n") - pfn += 1 + page_owner = self.get_page_owner(page_ext) + gdb.write("Page allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ + (page_owner["order"], page_owner["gfp_mask"],\ + page_owner["pid"], page_owner["tgid"], page_owner["comm"].string(),\ + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) + stackdepot.stack_depot_print(page_owner["handle"]) + pfn += (1 << page_owner["order"]) DumpPageOwner() diff --git a/scripts/gdb/linux/slab.py b/scripts/gdb/linux/slab.py index f012ba38c7d9..0e2d93867fe2 100644 --- a/scripts/gdb/linux/slab.py +++ b/scripts/gdb/linux/slab.py @@ -228,8 +228,7 @@ def slabtrace(alloc, cache_name): nr_cpu = gdb.parse_and_eval('__num_online_cpus')['counter'] if nr_cpu > 1: gdb.write(" cpus=") - for i in loc['cpus']: - gdb.write("%d," % i) + gdb.write(','.join(str(cpu) for cpu in loc['cpus'])) gdb.write("\n") if constants.LX_CONFIG_STACKDEPOT: if loc['handle']: -- 2.18.0 ^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 3/3] scripts/gdb: Remove exception handling and refine print format @ 2023-11-29 6:51 ` Kuan-Ying Lee 0 siblings, 0 replies; 16+ messages in thread From: Kuan-Ying Lee @ 2023-11-29 6:51 UTC (permalink / raw) To: Jan Kiszka, Kieran Bingham, Matthias Brugger, AngeloGioacchino Del Regno Cc: casper.li, chinwen.chang, qun-wei.lin, linux-mm, akpm, Kuan-Ying Lee, linux-kernel, linux-arm-kernel, linux-mediatek 1. When we crash on a page, we want to check what happened on this page instead of skipping this page by try-catch block. Thus, removing the try-catch block. 2. Remove redundant comma and print the task name properly. Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com> --- scripts/gdb/linux/page_owner.py | 58 ++++++++++++++------------------- scripts/gdb/linux/slab.py | 3 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/scripts/gdb/linux/page_owner.py b/scripts/gdb/linux/page_owner.py index 844fd5d0c912..8e713a09cfe7 100644 --- a/scripts/gdb/linux/page_owner.py +++ b/scripts/gdb/linux/page_owner.py @@ -122,27 +122,24 @@ class DumpPageOwner(gdb.Command): if not (page_ext['flags'] & (1 << PAGE_EXT_OWNER_ALLOCATED)): gdb.write("page_owner is not allocated\n") - try: - page_owner = self.get_page_owner(page_ext) - gdb.write("Page last allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ - (page_owner["order"], page_owner["gfp_mask"],\ - page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ - page_owner["ts_nsec"], page_owner["free_ts_nsec"])) - gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) - if page_owner["handle"] == 0: - gdb.write('page_owner allocation stack trace missing\n') - else: - stackdepot.stack_depot_print(page_owner["handle"]) + page_owner = self.get_page_owner(page_ext) + gdb.write("Page last allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ + (page_owner["order"], page_owner["gfp_mask"],\ + page_owner["pid"], page_owner["tgid"], page_owner["comm"].string(),\ + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) + if page_owner["handle"] == 0: + gdb.write('page_owner allocation stack trace missing\n') + else: + stackdepot.stack_depot_print(page_owner["handle"]) - if page_owner["free_handle"] == 0: - gdb.write('page_owner free stack trace missing\n') - else: - gdb.write('page last free stack trace:\n') - stackdepot.stack_depot_print(page_owner["free_handle"]) - if page_owner['last_migrate_reason'] != -1: - gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) - except: - gdb.write("\n") + if page_owner["free_handle"] == 0: + gdb.write('page_owner free stack trace missing\n') + else: + gdb.write('page last free stack trace:\n') + stackdepot.stack_depot_print(page_owner["free_handle"]) + if page_owner['last_migrate_reason'] != -1: + gdb.write('page has been migrated, last migrate reason: %s\n' % self.migrate_reason_names[page_owner['last_migrate_reason']]) def read_page_owner(self): pfn = self.min_pfn @@ -173,18 +170,13 @@ class DumpPageOwner(gdb.Command): pfn += 1 continue - try: - page_owner = self.get_page_owner(page_ext) - gdb.write("Page allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ - (page_owner["order"], page_owner["gfp_mask"],\ - page_owner["pid"], page_owner["tgid"], page_owner["comm"],\ - page_owner["ts_nsec"], page_owner["free_ts_nsec"])) - gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) - stackdepot.stack_depot_print(page_owner["handle"]) - pfn += (1 << page_owner["order"]) - continue - except: - gdb.write("\n") - pfn += 1 + page_owner = self.get_page_owner(page_ext) + gdb.write("Page allocated via order %d, gfp_mask: 0x%x, pid: %d, tgid: %d (%s), ts %u ns, free_ts %u ns\n" %\ + (page_owner["order"], page_owner["gfp_mask"],\ + page_owner["pid"], page_owner["tgid"], page_owner["comm"].string(),\ + page_owner["ts_nsec"], page_owner["free_ts_nsec"])) + gdb.write("PFN: %d, Flags: 0x%x\n" % (pfn, page['flags'])) + stackdepot.stack_depot_print(page_owner["handle"]) + pfn += (1 << page_owner["order"]) DumpPageOwner() diff --git a/scripts/gdb/linux/slab.py b/scripts/gdb/linux/slab.py index f012ba38c7d9..0e2d93867fe2 100644 --- a/scripts/gdb/linux/slab.py +++ b/scripts/gdb/linux/slab.py @@ -228,8 +228,7 @@ def slabtrace(alloc, cache_name): nr_cpu = gdb.parse_and_eval('__num_online_cpus')['counter'] if nr_cpu > 1: gdb.write(" cpus=") - for i in loc['cpus']: - gdb.write("%d," % i) + gdb.write(','.join(str(cpu) for cpu in loc['cpus'])) gdb.write("\n") if constants.LX_CONFIG_STACKDEPOT: if loc['handle']: -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
end of thread, other threads:[~2023-11-29 22:34 UTC | newest] Thread overview: 16+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-29 6:51 [PATCH v2 0/3] Fix GDB commands error Kuan-Ying Lee 2023-11-29 6:51 ` Kuan-Ying Lee 2023-11-29 6:51 ` [PATCH v2 1/3] scripts/gdb/tasks: Fix lx-ps command error Kuan-Ying Lee 2023-11-29 6:51 ` Kuan-Ying Lee 2023-11-29 8:10 ` Oleg Nesterov 2023-11-29 8:10 ` Oleg Nesterov 2023-11-29 22:15 ` Andrew Morton 2023-11-29 22:15 ` Andrew Morton 2023-11-29 22:33 ` Florian Fainelli 2023-11-29 22:33 ` Florian Fainelli 2023-11-29 6:51 ` [PATCH v2 2/3] scripts/gdb/stackdepot: Rename pool_index to pools_num Kuan-Ying Lee 2023-11-29 6:51 ` Kuan-Ying Lee 2023-11-29 22:33 ` Florian Fainelli 2023-11-29 22:33 ` Florian Fainelli 2023-11-29 6:51 ` [PATCH v2 3/3] scripts/gdb: Remove exception handling and refine print format Kuan-Ying Lee 2023-11-29 6:51 ` Kuan-Ying Lee
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.