Skip to contentSkip to conversation

mm: memcontrol: fix order calculation in try_charge()

PATCH In review Jerome Marchand 3 participants 4 messages Sep 15, 2015 – Sep 18, 2015

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

PATCH 1/1 mm: memcontrol: fix order calculation in try_charge()

Since commit <6539cc05386> (mm: memcontrol: fold mem_cgroup_do_charge()), the order to pass to mem_cgroup_oom() is calculated by passing the number of pages to get_order() instead of the expected size in bytes. AFAICT, it only affects the value displayed in the oom warning message. This patch fix this.

---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
index 1742a2d..91bf094 100644
@@ -2032,7 +2032,8 @@ retry:
 
 	mem_cgroup_events(mem_over_limit, MEMCG_OOM, 1);
 
-	mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(nr_pages));
+	mem_cgroup_oom(mem_over_limit, gfp_mask,
+		       get_order(nr_pages * PAGE_SIZE));
 nomem:
 	if (!(gfp_mask & __GFP_NOFAIL))
 		return -ENOMEM;
Signature · 1 line
1.9.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jerome Marchand

Since commit <6539cc05386> (mm: memcontrol: fold mem_cgroup_do_charge()), the order to pass to mem_cgroup_oom() is calculated by passing the number of pages to get_order() instead of the expected size in bytes. AFAICT, it only affects the value displayed in the oom warning message. This patch fix this.

We haven't noticed that just because the OOM is enabled only for page faults of order-0 (single page) and get_order work just fine. Thanks for noticing this. If we ever start triggering OOM on different orders this would be broken.

Quoted 1 line

Btw. a quick git grep shows that at least gart_iommu_init is using number of pages as well. I haven't checked it does that intentionally, though.

Thanks!

Quoted 20 lines
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
index 1742a2d..91bf094 100644
@@ -2032,7 +2032,8 @@ retry:
 
 	mem_cgroup_events(mem_over_limit, MEMCG_OOM, 1);
 
-	mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(nr_pages));
+	mem_cgroup_oom(mem_over_limit, gfp_mask,
+		       get_order(nr_pages * PAGE_SIZE));
 nomem:
 	if (!(gfp_mask & __GFP_NOFAIL))
 		return -ENOMEM;
Signature · 1 line
1.9.3
Signature · 2 lines
Michal Hocko
SUSE Labs
maintainer
#2 lore raw

[CC Andrew - the patch was posted here
http://lkml.kernel.org/r/1442318757-7141-1-git-send-email-jmarchan%40redhat.com]

Quoted 46 lines · Michal Hocko
Quoted 5 lines · Jerome Marchand

Since commit <6539cc05386> (mm: memcontrol: fold mem_cgroup_do_charge()), the order to pass to mem_cgroup_oom() is calculated by passing the number of pages to get_order() instead of the expected size in bytes. AFAICT, it only affects the value displayed in the oom warning message. This patch fix this.

We haven't noticed that just because the OOM is enabled only for page faults of order-0 (single page) and get_order work just fine. Thanks for noticing this. If we ever start triggering OOM on different orders this would be broken.

Quoted 1 line

Btw. a quick git grep shows that at least gart_iommu_init is using number of pages as well. I haven't checked it does that intentionally, though.

Thanks!

Quoted 20 lines
---
 mm/memcontrol.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
index 1742a2d..91bf094 100644
@@ -2032,7 +2032,8 @@ retry:
 
 	mem_cgroup_events(mem_over_limit, MEMCG_OOM, 1);
 
-	mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(nr_pages));
+	mem_cgroup_oom(mem_over_limit, gfp_mask,
+		       get_order(nr_pages * PAGE_SIZE));
 nomem:
 	if (!(gfp_mask & __GFP_NOFAIL))
 		return -ENOMEM;
Signature · 1 line
1.9.3
Signature · 2 lines
Michal Hocko
SUSE Labs
Signature · 8 lines
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
maintainer Acked-by on v1 1/1
#3 lore raw
In reply to Jerome Marchand
Quoted 7 lines · Jerome Marchand

Since commit <6539cc05386> (mm: memcontrol: fold mem_cgroup_do_charge()), the order to pass to mem_cgroup_oom() is calculated by passing the number of pages to get_order() instead of the expected size in bytes. AFAICT, it only affects the value displayed in the oom warning message. This patch fix this.

Thanks, Jerome. One minor thing:

mm/memcontrol.c retry: · line 2036

Quoted 7 lines
mm/memcontrol.c +2 -1
@@ -2032,7 +2032,8 @@ retry:
 
 	mem_cgroup_events(mem_over_limit, MEMCG_OOM, 1);
 
-	mem_cgroup_oom(mem_over_limit, gfp_mask, get_order(nr_pages));
+	mem_cgroup_oom(mem_over_limit, gfp_mask,
+		       get_order(nr_pages * PAGE_SIZE));

fls(nr_pages)?

get_order() is basically fls(x / PAGE_SIZE).