Skip to contentSkip to conversation

Fixes related to lx-slabinfo, lx-slabtrace

PATCH Applied Illia Ostapyshyn 3 participants 5 messages Apr 27 – Apr 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Fixes related to lx-slabinfo, lx-slabtrace

Hi all,

calling slab-related commands in gdb scripts currently fails because of two reasons. Firstly, x86 mm page ops try to cast symbols without type information to int, which causes an exception. Secondly, struct kmem_cache was changed in commit 55f8b4518d14b743 ("scripts/gdb:
implement x86_page_ops in mm.py") to factor out per-node data into a separate struct, which the gdb scripts do not reflect yet.

These two patches fix these issues.

Illia Ostapyshyn (2):
scripts/gdb: mm: Cast untyped symbols in x86_page_ops scripts/gdb: slab: Update field names of struct kmem_cache

 scripts/gdb/linux/mm.py   | 6 +++---
 scripts/gdb/linux/slab.py | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731

Signature · 1 line
2.51.2
#1 lore raw

PATCH 1/2 scripts/gdb: mm: Cast untyped symbols in x86_page_ops

The symbols phys_base, _text, and _end, used in x86_page_ops are either defined in assembly or implicitly by the linker. Thus, they lack type information and cause a conversion error after gdb.parse_and_eval. Explicitly cast these expressions to unsigned long.

Fixes 55f8b4518d14 ("scripts/gdb: implement x86_page_ops in mm.py")
---
 scripts/gdb/linux/mm.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/gdb/linux/mm.py +3 -3
index d78908f6664d..dffadccbb01d 100644
@@ -40,11 +40,11 @@ class x86_page_ops():
 
         self.PAGE_OFFSET = int(gdb.parse_and_eval("page_offset_base"))
         self.VMEMMAP_START = int(gdb.parse_and_eval("vmemmap_base"))
-        self.PHYS_BASE = int(gdb.parse_and_eval("phys_base"))
+        self.PHYS_BASE = int(gdb.parse_and_eval("(unsigned long) phys_base"))
         self.START_KERNEL_map = 0xffffffff80000000
 
-        self.KERNEL_START = gdb.parse_and_eval("_text")
-        self.KERNEL_END = gdb.parse_and_eval("_end")
+        self.KERNEL_START = gdb.parse_and_eval("(unsigned long) &_text")
+        self.KERNEL_END = gdb.parse_and_eval("(unsigned long) &_end")
 
         self.VMALLOC_START = int(gdb.parse_and_eval("vmalloc_base"))
         if self.VMALLOC_START == 0xffffc90000000000:
Signature · 1 line
2.51.2
#2 lore raw

PATCH 2/2 scripts/gdb: slab: Update field names of struct kmem_cache

In reply to Illia Ostapyshyn

The commit 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node") reorganized the struct kmem_cache to factor out the per-node fields to the new struct kmem_cache_per_node_ptrs. This causes the gdb scripts for lx-slabinfo and lx-slabtrace fail as they still reference the old structure.

Adjust the gdb scripts to match the current state of struct kmem_cache.

Fixes 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node")
---
 scripts/gdb/linux/slab.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/gdb/linux/slab.py +2 -2
index 0e2d93867fe2..ddde25aeca8d 100644
@@ -196,7 +196,7 @@ def slabtrace(alloc, cache_name):
 
     if target_cache['flags'] & SLAB_STORE_USER:
         for i in range(0, nr_node_ids):
-            cache_node = target_cache['node'][i]
+            cache_node = target_cache['per_node']['node'][i]
             if cache_node['nr_slabs']['counter'] == 0:
                 continue
             process_slab(loc_track, cache_node['partial'], alloc, target_cache)
@@ -300,7 +300,7 @@ def slabinfo():
         nr_free = 0
         nr_slabs = 0
         for i in range(0, nr_node_ids):
-            cache_node = cache['node'][i]
+            cache_node = cache['per_node']['node'][i]
             try:
                 nr_slabs += cache_node['nr_slabs']['counter']
                 nr_objs = int(cache_node['total_objects']['counter'])
Signature · 1 line
2.51.2
maintainer Acked-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] scripts/gdb: slab: Update field names of struct kmem_cache

Quoted 11 lines · Illia Ostapyshyn

The commit 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node") reorganized the struct kmem_cache to factor out the per-node fields to the new struct kmem_cache_per_node_ptrs. This causes the gdb scripts for lx-slabinfo and lx-slabtrace fail as they still reference the old structure.

Adjust the gdb scripts to match the current state of struct kmem_cache.

Fixes 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node")

---

Looks good to me,

Signature · 2 lines
Cheers,
Harry / Hyeonggon
maintainer Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] scripts/gdb: slab: Update field names of struct kmem_cache

In reply to Illia Ostapyshyn
Quoted 10 lines · Illia Ostapyshyn

The commit 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node") reorganized the struct kmem_cache to factor out the per-node fields to the new struct kmem_cache_per_node_ptrs. This causes the gdb scripts for lx-slabinfo and lx-slabtrace fail as they still reference the old structure.

Adjust the gdb scripts to match the current state of struct kmem_cache.

Fixes 5ba6bc27b1f9 ("slab: decouple pointer to barn from kmem_cache_node")

Thanks!

Quoted 26 lines
---
 scripts/gdb/linux/slab.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/gdb/linux/slab.py +2 -2
index 0e2d93867fe2..ddde25aeca8d 100644
@@ -196,7 +196,7 @@ def slabtrace(alloc, cache_name):
 
     if target_cache['flags'] & SLAB_STORE_USER:
         for i in range(0, nr_node_ids):
-            cache_node = target_cache['node'][i]
+            cache_node = target_cache['per_node']['node'][i]
             if cache_node['nr_slabs']['counter'] == 0:
                 continue
             process_slab(loc_track, cache_node['partial'], alloc, target_cache)
@@ -300,7 +300,7 @@ def slabinfo():
         nr_free = 0
         nr_slabs = 0
         for i in range(0, nr_node_ids):
-            cache_node = cache['node'][i]
+            cache_node = cache['per_node']['node'][i]
             try:
                 nr_slabs += cache_node['nr_slabs']['counter']
                 nr_objs = int(cache_node['total_objects']['counter'])