Blame SOURCES/0002-memory-Fix-for-kmem-n-option-to-display-NID-correctl.patch

3e5f3d
From ec44b902d3467e7b86ee39e2d7d472b9cb202148 Mon Sep 17 00:00:00 2001
3e5f3d
From: Kazuhito Hagio <k-hagio-ab@nec.com>
3e5f3d
Date: Mon, 31 May 2021 14:08:28 +0900
3e5f3d
Subject: [PATCH 2/2] memory: Fix for "kmem -n" option to display NID correctly
3e5f3d
3e5f3d
The nid member of struct memory_block is a 4-byte integer, but read
3e5f3d
and printed as a 8-byte integer on 64-bit machines.  Without the
3e5f3d
patch, the option displays wrong NIDs.
3e5f3d
3e5f3d
  crash> kmem -n
3e5f3d
  ...
3e5f3d
     MEM_BLOCK        NAME          PHYSICAL RANGE       NODE  STATE   START_SECTION_NO
3e5f3d
   ffff9edeff2b9400   memory0             0 -   7fffffff 14195095130662240256  ONLINE  0
3e5f3d
   ffff9edeff2bb400   memory2     100000000 -  17fffffff 14195094718345379840  ONLINE  32
3e5f3d
3e5f3d
The issue seems to appear on Linux 5.12 and later kernels that contain
3e5f3d
commit e9a2e48e8704c ("drivers/base/memory: don't store phys_device
3e5f3d
in memory blocks"), which changed the arrangement of the members of
3e5f3d
struct memory_block.
3e5f3d
3e5f3d
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
3e5f3d
---
3e5f3d
 memory.c | 4 ++--
3e5f3d
 1 file changed, 2 insertions(+), 2 deletions(-)
3e5f3d
3e5f3d
diff --git a/memory.c b/memory.c
3e5f3d
index 2c4f9790f498..cbe90eebe748 100644
3e5f3d
--- a/memory.c
3e5f3d
+++ b/memory.c
3e5f3d
@@ -17568,13 +17568,13 @@ print_memory_block(ulong memory_block)
3e5f3d
 
3e5f3d
 	if (MEMBER_EXISTS("memory_block", "nid")) {
3e5f3d
 		readmem(memory_block + OFFSET(memory_block_nid), KVADDR, &nid,
3e5f3d
-			sizeof(void *), "memory_block nid", FAULT_ON_ERROR);
3e5f3d
+			sizeof(int), "memory_block nid", FAULT_ON_ERROR);
3e5f3d
 		fprintf(fp, " %s %s %s %s  %s %s\n",
3e5f3d
 			mkstring(buf1, VADDR_PRLEN, LJUST|LONG_HEX,
3e5f3d
 			MKSTR(memory_block)),
3e5f3d
 			mkstring(buf2, 12, CENTER, name),
3e5f3d
 			parangebuf,
3e5f3d
-			mkstring(buf5, strlen("NODE"), CENTER|LONG_DEC,
3e5f3d
+			mkstring(buf5, strlen("NODE"), CENTER|INT_DEC,
3e5f3d
 			MKSTR(nid)),
3e5f3d
 			mkstring(buf6, strlen("OFFLINE"), LJUST,
3e5f3d
 			statebuf),
3e5f3d
-- 
3e5f3d
2.30.2
3e5f3d