linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] Fix GDB command error
@ 2024-06-19  7:49 Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 1/6] scripts/gdb: redefine MAX_ORDER sanely Kuan-Ying Lee
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton; +Cc: linux-mm

This patchset fix some GDB command errors.

1. Since memory layout of AARCH64 has been changed,
   we need to modify the layout in GDB scripts as well.

2. Fix pool_index naming of stackdepot.

The patchset is based on next-20240618.

Kuan-Ying Lee (6):
  scripts/gdb: redefine MAX_ORDER sanely
  scripts/gdb: rework module VA range
  scripts/gdb: change the layout of vmemmap
  scripts/gdb: set vabits_actual based on TCR_EL1
  scripts/gdb: change VA_BITS_MIN when we use 16K page
  scripts/gdb: rename pool_index to pool_index_plus_1

 scripts/gdb/linux/mm.py         | 23 ++++++++++++++---------
 scripts/gdb/linux/stackdepot.py |  8 ++++++--
 2 files changed, 20 insertions(+), 11 deletions(-)

-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/6] scripts/gdb: redefine MAX_ORDER sanely
  2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
@ 2024-06-19  7:49 ` Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 2/6] scripts/gdb: rework module VA range Kuan-Ying Lee
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton, Jan Kiszka, Kieran Bingham,
	Michael Ellerman, Kirill A. Shutemov
  Cc: linux-mm, linux-kernel

Change the definition of MAX_ORDER to be inclusive.

Fixes: 23baf831a32c ("mm, treewide: redefine MAX_ORDER sanely")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
 scripts/gdb/linux/mm.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index 515730fd4c9d..30738f174fe2 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -59,9 +59,9 @@ class aarch64_page_ops():
         if str(constants.LX_CONFIG_ARCH_FORCE_MAX_ORDER).isdigit():
             self.MAX_ORDER = constants.LX_CONFIG_ARCH_FORCE_MAX_ORDER
         else:
-            self.MAX_ORDER = 11
+            self.MAX_ORDER = 10
 
-        self.MAX_ORDER_NR_PAGES = 1 << (self.MAX_ORDER - 1)
+        self.MAX_ORDER_NR_PAGES = 1 << (self.MAX_ORDER)
         self.PFN_SECTION_SHIFT = self.SECTION_SIZE_BITS - self.PAGE_SHIFT
         self.NR_MEM_SECTIONS = 1 << self.SECTIONS_SHIFT
         self.PAGES_PER_SECTION = 1 << self.PFN_SECTION_SHIFT
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/6] scripts/gdb: rework module VA range
  2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 1/6] scripts/gdb: redefine MAX_ORDER sanely Kuan-Ying Lee
@ 2024-06-19  7:49 ` Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 3/6] scripts/gdb: change the layout of vmemmap Kuan-Ying Lee
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton, Jan Kiszka, Kieran Bingham,
	Catalin Marinas, Ard Biesheuvel, Mark Rutland
  Cc: linux-mm, linux-kernel

After we enlarge the module VA range, we also change the module VA
range in gdb scripts.

Fixes: 3e35d303ab7d ("arm64: module: rework module VA range selection")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
 scripts/gdb/linux/mm.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index 30738f174fe2..e0461248abe2 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -33,7 +33,7 @@ class aarch64_page_ops():
     def __init__(self):
         self.SUBSECTION_SHIFT = 21
         self.SEBSECTION_SIZE = 1 << self.SUBSECTION_SHIFT
-        self.MODULES_VSIZE = 128 * 1024 * 1024
+        self.MODULES_VSIZE = 2 * 1024 * 1024 * 1024
 
         if constants.LX_CONFIG_ARM64_64K_PAGES:
             self.SECTION_SIZE_BITS = 29
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/6] scripts/gdb: change the layout of vmemmap
  2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 1/6] scripts/gdb: redefine MAX_ORDER sanely Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 2/6] scripts/gdb: rework module VA range Kuan-Ying Lee
@ 2024-06-19  7:49 ` Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 5/6] scripts/gdb: change VA_BITS_MIN when we use 16K page Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 6/6] scripts/gdb: rename pool_index to pool_index_plus_1 Kuan-Ying Lee
  4 siblings, 0 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton, Jan Kiszka, Kieran Bingham,
	Mark Rutland, Ard Biesheuvel, Catalin Marinas
  Cc: linux-mm, linux-kernel

We need to change the layout of vmemmap in gdb scripts after
commit 32697ff38287 ("arm64: vmemmap: Avoid base2 order of
struct page size to dimension region") changed it.

Fixes: 32697ff38287 ("arm64: vmemmap: Avoid base2 order of struct page size to dimension region")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
 scripts/gdb/linux/mm.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index e0461248abe2..f8b9be3f43e8 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -89,10 +89,10 @@ class aarch64_page_ops():
         self.MODULES_VADDR = self._PAGE_END(self.VA_BITS_MIN)
         self.MODULES_END = self.MODULES_VADDR + self.MODULES_VSIZE
 
-        self.VMEMMAP_SHIFT = (self.PAGE_SHIFT - self.STRUCT_PAGE_MAX_SHIFT)
-        self.VMEMMAP_SIZE = ((self._PAGE_END(self.VA_BITS_MIN) - self.PAGE_OFFSET) >> self.VMEMMAP_SHIFT)
-        self.VMEMMAP_START = (-(1 << (self.VA_BITS - self.VMEMMAP_SHIFT))) & 0xffffffffffffffff
-        self.VMEMMAP_END = self.VMEMMAP_START + self.VMEMMAP_SIZE
+        self.VMEMMAP_RANGE = self._PAGE_END(self.VA_BITS_MIN) - self.PAGE_OFFSET
+        self.VMEMMAP_SIZE = (self.VMEMMAP_RANGE >> self.PAGE_SHIFT) * self.struct_page_size
+        self.VMEMMAP_END = (-(1 * 1024 * 1024 * 1024)) & 0xffffffffffffffff
+        self.VMEMMAP_START = self.VMEMMAP_END - self.VMEMMAP_SIZE
 
         self.VMALLOC_START = self.MODULES_END
         self.VMALLOC_END = self.VMEMMAP_START - 256 * 1024 * 1024
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/6] scripts/gdb: change VA_BITS_MIN when we use 16K page
  2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
                   ` (2 preceding siblings ...)
  2024-06-19  7:49 ` [PATCH 3/6] scripts/gdb: change the layout of vmemmap Kuan-Ying Lee
@ 2024-06-19  7:49 ` Kuan-Ying Lee
  2024-06-19  7:49 ` [PATCH 6/6] scripts/gdb: rename pool_index to pool_index_plus_1 Kuan-Ying Lee
  4 siblings, 0 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton, Jan Kiszka, Kieran Bingham,
	Catalin Marinas, Ard Biesheuvel
  Cc: linux-mm, linux-kernel

Change VA_BITS_MIN when we use 16K page.

Fixes: 9684ec186f8f ("arm64: Enable LPA2 at boot if supported by the system")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
 scripts/gdb/linux/mm.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/scripts/gdb/linux/mm.py b/scripts/gdb/linux/mm.py
index 200def0e4b9a..7571aebbe650 100644
--- a/scripts/gdb/linux/mm.py
+++ b/scripts/gdb/linux/mm.py
@@ -47,7 +47,10 @@ class aarch64_page_ops():
 
         self.VA_BITS = constants.LX_CONFIG_ARM64_VA_BITS
         if self.VA_BITS > 48:
-            self.VA_BITS_MIN = 48
+            if constants.LX_CONFIG_ARM64_16K_PAGES:
+                self.VA_BITS_MIN = 47
+            else:
+                self.VA_BITS_MIN = 48
             tcr_el1 = gdb.execute("info registers $TCR_EL1", to_string=True)
             tcr_el1 = int(tcr_el1.split()[1], 16)
             self.vabits_actual = 64 - ((tcr_el1 >> 16) & 63)
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 6/6] scripts/gdb: rename pool_index to pool_index_plus_1
  2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
                   ` (3 preceding siblings ...)
  2024-06-19  7:49 ` [PATCH 5/6] scripts/gdb: change VA_BITS_MIN when we use 16K page Kuan-Ying Lee
@ 2024-06-19  7:49 ` Kuan-Ying Lee
  4 siblings, 0 replies; 6+ messages in thread
From: Kuan-Ying Lee @ 2024-06-19  7:49 UTC (permalink / raw)
  To: kuan-ying.lee, Andrew Morton, Jan Kiszka, Kieran Bingham,
	Vlastimil Babka, Marco Elver, Peter Collingbourne,
	Oscar Salvador
  Cc: linux-mm, linux-kernel

We encounter the following issue after commit a6c1d9cb9a68 ("stackdepot:
rename pool_index to pool_index_plus_1").

(gdb) lx-dump-page-owner --pfn 262144
...
Python Exception <class 'gdb.error'>: There is no member named pool_index.
Error occurred in Python: There is no member named pool_index.

We rename pool_index to pool_index_plus_1 to fix this issue.

Fixes: a6c1d9cb9a68 ("stackdepot: rename pool_index to pool_index_plus_1")
Signed-off-by: Kuan-Ying Lee <kuan-ying.lee@canonical.com>
---
 scripts/gdb/linux/stackdepot.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/gdb/linux/stackdepot.py b/scripts/gdb/linux/stackdepot.py
index 0281d9de4b7c..bb3a0f843931 100644
--- a/scripts/gdb/linux/stackdepot.py
+++ b/scripts/gdb/linux/stackdepot.py
@@ -27,14 +27,18 @@ def stack_depot_fetch(handle):
     offset = parts['offset'] << DEPOT_STACK_ALIGN
     pools_num = gdb.parse_and_eval('pools_num')
 
-    if parts['pool_index'] > pools_num:
+    if handle == 0:
+        raise gdb.GdbError("handle is 0\n")
+
+    pool_index = parts['pool_index_plus_1'] - 1
+    if 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')
 
     try:
-        pool = stack_pools[parts['pool_index']]
+        pool = stack_pools[pool_index]
         stack = (pool + gdb.Value(offset).cast(utils.get_size_t_type())).cast(stack_record_type.get_type().pointer())
         size = int(stack['size'].cast(utils.get_ulong_type()))
         return stack['entries'], size
-- 
2.34.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-06-19  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-19  7:49 [PATCH 0/6] Fix GDB command error Kuan-Ying Lee
2024-06-19  7:49 ` [PATCH 1/6] scripts/gdb: redefine MAX_ORDER sanely Kuan-Ying Lee
2024-06-19  7:49 ` [PATCH 2/6] scripts/gdb: rework module VA range Kuan-Ying Lee
2024-06-19  7:49 ` [PATCH 3/6] scripts/gdb: change the layout of vmemmap Kuan-Ying Lee
2024-06-19  7:49 ` [PATCH 5/6] scripts/gdb: change VA_BITS_MIN when we use 16K page Kuan-Ying Lee
2024-06-19  7:49 ` [PATCH 6/6] scripts/gdb: rename pool_index to pool_index_plus_1 Kuan-Ying Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox