Skip to contentSkip to conversation

mm: memcg: fix unit conversion for K() macro in OOM log

PATCH Applied Shakeel Butt 4 participants 4 messages Dec 16, 2025 – Dec 17, 2025

Subsystems (3)
lore
Share & tools
lore

Shakeel Butt

author maintainer
#0 lore raw

PATCH 1/1 mm: memcg: fix unit conversion for K() macro in OOM log

The commit bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures") added functionality to dump memcg protections on OOM or allocation failures. It uses K() macro to dump the information and passes bytes to the macro. However the macro take number of pages instead of bytes. It is defined as:

#define K(x) ((x) << (PAGE_SHIFT-10))

Let's fix this.

Fixes bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures")
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index e2e49f4ec9e0..6f000f0e76d2 100644
@@ -5638,6 +5638,6 @@ void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg)
 		memcg = root_mem_cgroup;
 
 	pr_warn("Memory cgroup min protection %lukB -- low protection %lukB",
-		K(atomic_long_read(&memcg->memory.children_min_usage)*PAGE_SIZE),
-		K(atomic_long_read(&memcg->memory.children_low_usage)*PAGE_SIZE));
+		K(atomic_long_read(&memcg->memory.children_min_usage)),
+		K(atomic_long_read(&memcg->memory.children_low_usage)));
 }
Signature · 1 line
2.47.3
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Shakeel Butt

The commit bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures") added functionality to dump memcg protections on OOM or allocation failures. It uses K() macro to dump the information and passes bytes to the macro. However the macro take number of pages instead of bytes. It is defined as:

Quoted 7 lines

#define K(x) ((x) << (PAGE_SHIFT-10))

Let's fix this.

Fixes bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures")

Thanks.

Acked-by on v1 1/1
#2 lore raw
In reply to Shakeel Butt
Quoted 6 lines · Shakeel Butt

The commit bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures") added functionality to dump memcg protections on OOM or allocation failures. It uses K() macro to dump the information and passes bytes to the macro. However the macro take number of pages instead of bytes. It is defined as:

Quoted 7 lines

#define K(x) ((x) << (PAGE_SHIFT-10))

Let's fix this.

Fixes bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures")
Quoted 17 lines
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index e2e49f4ec9e0..6f000f0e76d2 100644
@@ -5638,6 +5638,6 @@ void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg)
 		memcg = root_mem_cgroup;
 
 	pr_warn("Memory cgroup min protection %lukB -- low protection %lukB",
-		K(atomic_long_read(&memcg->memory.children_min_usage)*PAGE_SIZE),
-		K(atomic_long_read(&memcg->memory.children_low_usage)*PAGE_SIZE));
+		K(atomic_long_read(&memcg->memory.children_min_usage)),
+		K(atomic_long_read(&memcg->memory.children_low_usage)));
 }
Acked-by on v1 1/1
#3 lore raw
In reply to Shakeel Butt
Quoted 6 lines · Shakeel Butt

The commit bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures") added functionality to dump memcg protections on OOM or allocation failures. It uses K() macro to dump the information and passes bytes to the macro. However the macro take number of pages instead of bytes. It is defined as:

Quoted 7 lines

#define K(x) ((x) << (PAGE_SHIFT-10))

Let's fix this.

Fixes bc8e51c05ad5 ("mm: memcg: dump memcg protection info on oom or alloc failures")

Thanks!

Quoted 20 lines
---
 mm/memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memcontrol.c +2 -2
index e2e49f4ec9e0..6f000f0e76d2 100644
@@ -5638,6 +5638,6 @@ void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg)
 		memcg = root_mem_cgroup;
 
 	pr_warn("Memory cgroup min protection %lukB -- low protection %lukB",
-		K(atomic_long_read(&memcg->memory.children_min_usage)*PAGE_SIZE),
-		K(atomic_long_read(&memcg->memory.children_low_usage)*PAGE_SIZE));
+		K(atomic_long_read(&memcg->memory.children_min_usage)),
+		K(atomic_long_read(&memcg->memory.children_low_usage)));
 }
Signature · 1 line
2.47.3
Signature · 2 lines
Michal Hocko
SUSE Labs