mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Seongjun Hong <hsj0512@snu.ac.kr>, kbingham@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scripts/gdb: support lx-slabinfo on x86
Date: Sun, 1 Feb 2026 13:59:39 +0100	[thread overview]
Message-ID: <e5207d4b-3177-4ee5-a6db-e095e3a5ce6e@siemens.com> (raw)
In-Reply-To: <20260201120653.621524-1-hsj0512@snu.ac.kr>

On 01.02.26 13:06, Seongjun Hong wrote:
> The lx-slabinfo command failed on x86 because x86_page_ops was not
> implemented. This patch implements x86_page_ops in mm.py.
> 
> Additionally, CONFIG_PAGE_SHIFT is required for the calculation but
> was only available for ARM64 in constants.py.in. This patch moves
> it to be available for all architectures.
> 
> Signed-off-by: Seongjun Hong <hsj0512@snu.ac.kr>
> ---
>  scripts/gdb/linux/constants.py.in |  2 +-
>  scripts/gdb/linux/mm.py           | 25 ++++++++++++++++++++++++-
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/gdb/linux/constants.py.in b/scripts/gdb/linux/constants.py.in
> index c3886739a028..11fd4ba6ba85 100644
> --- a/scripts/gdb/linux/constants.py.in
> +++ b/scripts/gdb/linux/constants.py.in
> @@ -150,8 +150,8 @@ LX_CONFIG(CONFIG_ARM64_64K_PAGES)
>  if IS_BUILTIN(CONFIG_ARM64):
>      LX_VALUE(CONFIG_ARM64_PA_BITS)
>      LX_VALUE(CONFIG_ARM64_VA_BITS)
> -    LX_VALUE(CONFIG_PAGE_SHIFT)
>      LX_VALUE(CONFIG_ARCH_FORCE_MAX_ORDER)
> +LX_VALUE(CONFIG_PAGE_SHIFT)
>  LX_CONFIG(CONFIG_SPARSEMEM)
>  LX_CONFIG(CONFIG_SPARSEMEM_EXTREME)
>  LX_CONFIG(CONFIG_SPARSEMEM_VMEMMAP)
> diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
> index 7571aebbe650..d6e84e4bf102 100644
> --- a/scripts/gdb/linux/mm.py
> +++ b/scripts/gdb/linux/mm.py
> @@ -26,8 +26,31 @@ class page_ops():
>              raise gdb.GdbError('Only support CONFIG_SPARSEMEM_VMEMMAP now')
>          if constants.LX_CONFIG_ARM64 and utils.is_target_arch('aarch64'):
>              self.ops = aarch64_page_ops()
> +        elif utils.is_target_arch('x86_64') or utils.is_target_arch('x86-64'):
> +            self.ops = x86_page_ops()
>          else:
> -            raise gdb.GdbError('Only support aarch64 now')
> +            raise gdb.GdbError('Only support aarch64 and x86_64 now')
> +
> +class x86_page_ops():
> +    def __init__(self):
> +        self.MAX_NUMNODES = 1 << constants.LX_CONFIG_NODES_SHIFT
> +        self.struct_page_size = utils.get_page_type().sizeof
> +        self.PAGE_SHIFT = constants.LX_CONFIG_PAGE_SHIFT
> +        self.PAGE_SIZE = 1 << self.PAGE_SHIFT
> +        self.PAGE_OFFSET = int(gdb.parse_and_eval("page_offset_base"))
> +        self.VMEMMAP_START = int(gdb.parse_and_eval("vmemmap_base"))
> +
> +    def page_to_virt(self, page):
> +        page_ptr = page.cast(utils.get_page_type().pointer())
> +        vmemmap_ptr = gdb.Value(self.VMEMMAP_START).cast(utils.get_page_type().pointer())
> +        idx = int(page_ptr - vmemmap_ptr)
> +        return self.PAGE_OFFSET + (idx * self.PAGE_SIZE)
> +
> +    def page_address(self, page):
> +        return self.page_to_virt(page)
> +
> +    def folio_address(self, folio):
> +        return self.page_address(folio['page'].address)
>  
>  class aarch64_page_ops():
>      def __init__(self):

Thanks for the contribution! From my quick (re-)reading, there are more
page_ops than what you implement above. I think command like
lx-pfn_to_page will now cause splats rather than a nicer "not
implemented yet". Could you add the missing ops or handle those cases
more gracefully for now?

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center

      reply	other threads:[~2026-02-01 12:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01 12:06 Seongjun Hong
2026-02-01 12:59 ` Jan Kiszka [this message]

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=e5207d4b-3177-4ee5-a6db-e095e3a5ce6e@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=hsj0512@snu.ac.kr \
    --cc=kbingham@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®