Skip to contentSkip to conversation

mm: slub: only warn once when allocating slab obj extensions fails

PATCH In review Usama Arif 7 participants 7 messages May 23, 2025 – Jun 2, 2025

Subsystems (2)
lore
Share & tools
lore

Usama Arif

author
#0 lore raw

PATCH v3 1/1 mm: slub: only warn once when allocating slab obj extensions fails

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

---
v2 -> v3:
- Put warning back, but only warn once with pr_warn_once. v1 -> v2:
- remove the warning completely. We will have a way in the future to indicate that the mem alloc profile is inaccurate.

---
 mm/slub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mm/slub.c +5 -3
index dc9e729e1d26..36d7c43a6f2a 100644
@@ -2102,10 +2102,12 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
 
 	slab = virt_to_slab(p);
 	if (!slab_obj_exts(slab) &&
-	    WARN(alloc_slab_obj_exts(slab, s, flags, false),
-		 "%s, %s: Failed to create slab extension vector!\n",
-		 __func__, s->name))
+	    alloc_slab_obj_exts(slab, s, flags, false)) {
+		pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
+			__func__, s->name);
 		return NULL;
+	}
+
 
 	return slab_obj_exts(slab) + obj_to_index(s, slab, p);
 }
Signature · 1 line
2.47.1
Reviewed-by on v3 1/1
#1 lore raw
Quoted 8 lines · Usama Arif

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

Reviewed-by on v3 1/1
#2 lore raw
In reply to Usama Arif
Quoted 8 lines · On Fri, 23 May 2025 17:52:40 +0100 Usama Arif <[email protected]> wrote:

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

Thanks,
SJ

[...]

#3 lore raw
In reply to Usama Arif
Quoted 25 lines · Usama Arif

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

---
v2 -> v3:
- Put warning back, but only warn once with pr_warn_once. v1 -> v2:
- remove the warning completely. We will have a way in the future to indicate that the mem alloc profile is inaccurate.

---
 mm/slub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mm/slub.c +0 -0
index dc9e729e1d26..36d7c43a6f2a 100644
@@ -2102,10 +2102,12 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
 
 	slab = virt_to_slab(p);

mm/slub.c prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p) · line 2110

Quoted 10 lines
mm/slub.c +5 -3
 	if (!slab_obj_exts(slab) &&
-	    WARN(alloc_slab_obj_exts(slab, s, flags, false),
-		 "%s, %s: Failed to create slab extension vector!\n",
-		 __func__, s->name))
+	    alloc_slab_obj_exts(slab, s, flags, false)) {
+		pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
+			__func__, s->name);
 		return NULL;
+	}
+

I've removed the extra line locally.

Added to slab/for-next, thanks.

Quoted 3 lines
mm/slub.c +0 -0
 	return slab_obj_exts(slab) + obj_to_index(s, slab, p);
 }
Acked-by on v3 1/1
#4 lore raw
In reply to Usama Arif
Quoted 9 lines · Usama Arif

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

---

Quoted 32 lines

v2 -> v3:
- Put warning back, but only warn once with pr_warn_once. v1 -> v2:
- remove the warning completely. We will have a way in the future to indicate that the mem alloc profile is inaccurate.

---
 mm/slub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mm/slub.c +5 -3
index dc9e729e1d26..36d7c43a6f2a 100644
@@ -2102,10 +2102,12 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
 
 	slab = virt_to_slab(p);
 	if (!slab_obj_exts(slab) &&
-	    WARN(alloc_slab_obj_exts(slab, s, flags, false),
-		 "%s, %s: Failed to create slab extension vector!\n",
-		 __func__, s->name))
+	    alloc_slab_obj_exts(slab, s, flags, false)) {
+		pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
+			__func__, s->name);
 		return NULL;
+	}
+
 
 	return slab_obj_exts(slab) + obj_to_index(s, slab, p);
 }
Signature · 1 line
2.47.1
Signature · 2 lines
Cheers,
Harry / Hyeonggon
#5 lore raw
Quoted 7 lines · Harry Yoo
Quoted 5 lines · Usama Arif

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

Quoted 6 lines
Quoted 4 lines

---

Quoted 37 lines
Quoted 31 lines

v2 -> v3:
- Put warning back, but only warn once with pr_warn_once. v1 -> v2:
- remove the warning completely. We will have a way in the future to indicate that the mem alloc profile is inaccurate.

---
 mm/slub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mm/slub.c +5 -4
index dc9e729e1d26..36d7c43a6f2a 100644
@@ -2102,10 +2102,12 @@ prepare_slab_obj_exts_hook(struct kmem_cache *s, gfp_t flags, void *p)
 
      slab = virt_to_slab(p);
      if (!slab_obj_exts(slab) &&
-         WARN(alloc_slab_obj_exts(slab, s, flags, false),
-              "%s, %s: Failed to create slab extension vector!\n",
-              __func__, s->name))
+         alloc_slab_obj_exts(slab, s, flags, false)) {
+             pr_warn_once("%s, %s: Failed to create slab extension vector!\n",
+                     __func__, s->name);
              return NULL;
+     }
+
 
      return slab_obj_exts(slab) + obj_to_index(s, slab, p);
 }
--
Quoted 2 lines

2.47.1

--
Cheers,
Harry / Hyeonggon

reviewer Acked-by on v3 1/1
#6 lore raw
In reply to Usama Arif
Quoted 8 lines · Usama Arif

In memory bound systems, a large number of warnings for failing this allocation repeatedly may mask any real issues in the system during memory pressure being reported in dmesg. Change this to warning only once.

Thanks!