[Crash-utility] [PATCH] Fix for "kmem -n" option to display NID correctly

lijiang lijiang at redhat.com
Tue Jun 1 09:59:04 UTC 2021


On Mon, May 31, 2021 at 1:08 PM HAGIO KAZUHITO(萩尾 一仁) <k-hagio-ab at nec.com>
wrote:

> The nid member of struct memory_block is a 4-byte integer, but read
> and printed as a 8-byte integer on 64-bit machines.  Without the patch,
> the option displays wrong NIDs.
>

Good findings, Kazu.
Acked-by: Lianbo Jiang <lijiang at redhat.com>


>   crash> kmem -n
>   ...
>      MEM_BLOCK        NAME          PHYSICAL RANGE       NODE  STATE
>  START_SECTION_NO
>    ffff9edeff2b9400   memory0             0 -   7fffffff
> 14195095130662240256  ONLINE  0
>    ffff9edeff2bb400   memory2     100000000 -  17fffffff
> 14195094718345379840  ONLINE  32
>
> The issue seems to appear on Linux 5.12 and later kernels that contain
> commit e9a2e48e8704c ("drivers/base/memory: don't store phys_device in
> memory blocks"), which changed the arrangement of the members of struct
> memory_block.
>
> Signed-off-by: Kazuhito Hagio <k-hagio-ab at nec.com>
> ---
>  memory.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/memory.c b/memory.c
> index 8c6bbe409922..600f2de336d9 100644
> --- a/memory.c
> +++ b/memory.c
> @@ -17564,13 +17564,13 @@ print_memory_block(ulong memory_block)
>
>         if (MEMBER_EXISTS("memory_block", "nid")) {
>                 readmem(memory_block + OFFSET(memory_block_nid), KVADDR,
> &nid,
> -                       sizeof(void *), "memory_block nid",
> FAULT_ON_ERROR);
> +                       sizeof(int), "memory_block nid", FAULT_ON_ERROR);
>                 fprintf(fp, " %s %s %s %s  %s %s\n",
>                         mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX,
>                         MKSTR(memory_block)),
>                         mkstring(buf2, 12, CENTER, name),
>                         parangebuf,
> -                       mkstring(buf5, strlen("NODE"), CENTER|LONG_DEC,
> +                       mkstring(buf5, strlen("NODE"), CENTER|INT_DEC,
>                         MKSTR(nid)),
>                         mkstring(buf6, strlen("OFFLINE"), LJUST,
>                         statebuf),
> --
> 2.27.0
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/crash-utility/attachments/20210601/bc2193b0/attachment.htm>


More information about the Crash-utility mailing list