Skip to contentSkip to conversation

tools/mm/slabinfo: Fix trace disabling logic

PATCH In review Kaushlendra Kumar 2 participants 3 messages Dec 8, 2025

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

PATCH 1/1 tools/mm/slabinfo: Fix trace disabling logic

When tracing is disabled (!tracing) but the slab has tracing enabled (s->trace), the code should disable tracing by writing 0, not enable it by writing 1. Fix the inverted logic to correctly turn off tracing.

---
 tools/mm/slabinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/mm/slabinfo.c +1 -1
index 80cdbd3db82d..7c51d283504d 100644
@@ -798,7 +798,7 @@ static void slab_debug(struct slabinfo *s)
 			fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
 	}
 	if (!tracing && s->trace)
-		set_obj(s, "trace", 1);
+		set_obj(s, "trace", 0);
 }
 
 static void totals(void)
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Kaushlendra Kumar

When tracing is disabled (!tracing) but the slab has tracing enabled (s->trace), the code should disable tracing by writing 0, not enable it by writing 1. Fix the inverted logic to correctly turn off tracing.

---

After commit 060807f841ac9 ("mm, slub: make remaining slub_debug related attributes read-only"), enabling or disabling debug option at runtime is not supported anymore. slabinfo's -d and -dA flags are not supposed work on recent kernels.

As it turns out enabling or disabling debug features at runtime is not a good idea anyway, could you please working on dropping the feature instead?

Quoted 18 lines
 tools/mm/slabinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/mm/slabinfo.c +1 -1
index 80cdbd3db82d..7c51d283504d 100644
@@ -798,7 +798,7 @@ static void slab_debug(struct slabinfo *s)
 			fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
 	}
 	if (!tracing && s->trace)
-		set_obj(s, "trace", 1);
+		set_obj(s, "trace", 0);
 }
 
 static void totals(void)
Signature · 1 line
2.34.1
Signature · 2 lines
Cheers,
Harry / Hyeonggon
#2 lore raw
Quoted 8 lines · Harry Hyeonggon Yoo
Quoted 6 lines · Kaushlendra Kumar

When tracing is disabled (!tracing) but the slab has tracing enabled (s->trace), the code should disable tracing by writing 0, not enable it by writing 1. Fix the inverted logic to correctly turn off tracing.

---

Quoted 7 lines

After commit 060807f841ac9 ("mm, slub: make remaining slub_debug related attributes read-only"), enabling or disabling debug option at runtime is not supported anymore. slabinfo's -d and -dA flags are not supposed work on recent kernels.

As it turns out enabling or disabling debug features at runtime is not a good idea anyway, could you please working on dropping the feature instead?

Thanks for the context. You're right-fixing inverted logic in code that's been non-functional since 060807f841ac9 doesn't add value.

I'll submit a cleanup series removing the obsolete runtime debug functionality:
- Remove -d/-dA options and related usage text
- Drop slab_debug() and set_obj() for debug attributes

-Kaushlendra