linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pankaj Raghav <p.raghav@samsung.com>
To: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Kieran Bingham <kbingham@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Luis Chamberlain <mcgrof@kernel.org>
Cc: <chinwen.chang@mediatek.com>, <qun-wei.lin@mediatek.com>,
	<linux-mm@kvack.org>, <andrew.yang@mediatek.com>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH] scripts/gdb: fix 'lx-lsmod' show the wrong size
Date: Tue, 4 Jul 2023 14:11:45 +0200	[thread overview]
Message-ID: <aad3e8fb-d16b-3fab-f17b-3e6645c946cd@samsung.com> (raw)
In-Reply-To: <20230620094834.14688-1-Kuan-Ying.Lee@mediatek.com>

> 'lsmod' shows total core layout size, so we need to
> sum up all the sections in core layout in gdb scripts.
> 
> / # lsmod
> kasan_test 200704 0 - Live 0xffff80007f640000
> 
> Before patch:
> (gdb) lx-lsmod
> Address            Module                  Size  Used by
> 0xffff80007f640000 kasan_test             36864  0
> 
> After patch:
> (gdb) lx-lsmod
> Address            Module                  Size  Used by
> 0xffff80007f640000 kasan_test            200704  0
> 
> Fixes: b4aff7513df3 ("scripts/gdb: use mem instead of core_layout to get the module address")
> Signed-off-by: Kuan-Ying Lee <Kuan-Ying.Lee@mediatek.com>
> ---

Just one minor comment, but apart from that, feel free to add:

Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>

> diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
> index 261f28640f4c..84933c4c1083 100644
> --- a/scripts/gdb/linux/modules.py
> +++ b/scripts/gdb/linux/modules.py
> @@ -73,11 +73,17 @@ class LxLsmod(gdb.Command):
>                  "        " if utils.get_long_type().sizeof == 8 else ""))
>  
>          for module in module_list():
> -            layout = module['mem'][constants.LX_MOD_TEXT]
> +            total_size = 0
> +            for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1):
> +                layout = module['mem'][i]
> +                if i == constants.LX_MOD_TEXT:
> +                    text_addr = str(layout['base']).split()[0]
> +                total_size += layout['size']
> +
>              gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
> -                address=str(layout['base']).split()[0],
> +                address=text_addr,
>                  name=module['name'].string(),
> -                size=str(layout['size']),
> +                size=str(total_size),
>                  ref=str(module['refcnt']['counter'] - 1)))
>  
>              t = self._module_use_type.get_type().pointer()

We could slightly modify the code to remove the special condition with `i == constants.LX_MOD_TEXT`:

(I made changes on top of your patch)

diff --git a/scripts/gdb/linux/modules.py b/scripts/gdb/linux/modules.py
index 84933c4c1083..f76a43bfa15f 100644
--- a/scripts/gdb/linux/modules.py
+++ b/scripts/gdb/linux/modules.py
@@ -73,12 +73,12 @@ class LxLsmod(gdb.Command):
                 "        " if utils.get_long_type().sizeof == 8 else ""))

         for module in module_list():
+            text = module['mem'][constants.LX_MOD_TEXT]
+            text_addr = str(text['base']).split()[0]
             total_size = 0
+
             for i in range(constants.LX_MOD_TEXT, constants.LX_MOD_RO_AFTER_INIT + 1):
-                layout = module['mem'][i]
-                if i == constants.LX_MOD_TEXT:
-                    text_addr = str(layout['base']).split()[0]
-                total_size += layout['size']
+                total_size += module['mem'][i]['size']

             gdb.write("{address} {name:<19} {size:>8}  {ref}".format(
                 address=text_addr,


  parent reply	other threads:[~2023-07-04 12:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20230620094846eucas1p21dfc03b10384449dee5e67837ba3e72d@eucas1p2.samsung.com>
2023-06-20  9:48 ` Kuan-Ying Lee
2023-06-30  1:01   ` Kuan-Ying Lee (李冠穎)
2023-07-04 12:11   ` Pankaj Raghav [this message]
2023-07-10  8:51     ` Kuan-Ying Lee (李冠穎)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aad3e8fb-d16b-3fab-f17b-3e6645c946cd@samsung.com \
    --to=p.raghav@samsung.com \
    --cc=Kuan-Ying.Lee@mediatek.com \
    --cc=andrew.yang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chinwen.chang@mediatek.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kbingham@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=mcgrof@kernel.org \
    --cc=qun-wei.lin@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox