mm: treat memory.low value inclusive

This change “mm: treat memory.low value inclusive” (commit 5f93ad6) in Linux kernel is authored by Roman Gushchin <guro [at] fb.com> on Thu Jun 7 17:06:26 2018 -0700.

Description of "mm: treat memory.low value inclusive"

The change “mm: treat memory.low value inclusive” introduces changes as follows.

mm: treat memory.low value inclusive

If memcg's usage is equal to the memory.low value, avoid reclaiming from
this cgroup while there is a surplus of reclaimable memory.

This sounds more logical and also matches memory.high and memory.max
behavior: both are inclusive.

Empty cgroups are not considered protected, so MEMCG_LOW events are not
emitted for empty cgroups, if there is no more reclaimable memory in the
system.

Link: http://lkml.kernel.org/r/20180406122132.GA7185@castle
Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Linux kernel releases containing commit 5f93ad6

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "mm: treat memory.low value inclusive"

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 mm/memcontrol.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
 
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index d0261059aab9..8bab4660e6aa 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5344,14 +5344,14 @@ struct cgroup_subsys memory_cgrp_subsys = {
 };
 
 /**
- * mem_cgroup_low - check if memory consumption is below the normal range
+ * mem_cgroup_low - check if memory consumption is in the normal range
  * @root: the top ancestor of the sub-tree being checked
  * @memcg: the memory cgroup to check
  *
  * WARNING: This function is not stateless! It can only be used as part
  *          of a top-down tree iteration, not for isolated queries.
  *
- * Returns %true if memory consumption of @memcg is below the normal range.
+ * Returns %true if memory consumption of @memcg is in the normal range.
  *
  * @root is exclusive; it is never low when looked at directly
  *
@@ -5445,7 +5445,7 @@ bool mem_cgroup_low(struct mem_cgroup *root, struct mem_cgroup *memcg)
 	elow = min(elow, parent_elow * low_usage / siblings_low_usage);
 exit:
 	memcg->memory.elow = elow;
-	return usage < elow;
+	return usage && usage <= elow;
 }
 
 /**

The commit for this change in Linux stable tree is 5f93ad6 (patch).

Last modified: 2020/02/09