mm/memcontrol.c: fix order calculation in try_charge()
authorJerome Marchand <jmarchan@redhat.com>
Fri, 6 Nov 2015 02:47:29 +0000 (18:47 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 6 Nov 2015 03:34:48 +0000 (19:34 -0800)
Since commit 6539cc053869 ("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.

Michal said:

: 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.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/memcontrol.c

index b952abef6ff00b71070929a60854f81449e658d6..a1c05ff5892dd77b2aa3942dadb22ccdd7885e41 100644 (file)
@@ -2094,7 +2094,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;