Skip to content

Commit 0158115

Browse files
Michal Hockotorvalds
Michal Hocko
authored andcommitted
memcg, kmem: deprecate kmem.limit_in_bytes
Cgroup v1 memcg controller has exposed a dedicated kmem limit to users which turned out to be really a bad idea because there are paths which cannot shrink the kernel memory usage enough to get below the limit (e.g. because the accounted memory is not reclaimable). There are cases when the failure is even not allowed (e.g. __GFP_NOFAIL). This means that the kmem limit is in excess to the hard limit without any way to shrink and thus completely useless. OOM killer cannot be invoked to handle the situation because that would lead to a premature oom killing. As a result many places might see ENOMEM returning from kmalloc and result in unexpected errors. E.g. a global OOM killer when there is a lot of free memory because ENOMEM is translated into VM_FAULT_OOM in #PF path and therefore pagefault_out_of_memory would result in OOM killer. Please note that the kernel memory is still accounted to the overall limit along with the user memory so removing the kmem specific limit should still allow to contain kernel memory consumption. Unlike the kmem one, though, it invokes memory reclaim and targeted memcg oom killing if necessary. Start the deprecation process by crying to the kernel log. Let's see whether there are relevant usecases and simply return to EINVAL in the second stage if nobody complains in few releases. [[email protected]: tweak documentation text] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Michal Hocko <[email protected]> Reviewed-by: Shakeel Butt <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Vladimir Davydov <[email protected]> Cc: Andrey Ryabinin <[email protected]> Cc: Thomas Lindroth <[email protected]> Cc: Tetsuo Handa <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 4d0e323 commit 0158115

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Documentation/admin-guide/cgroup-v1/memory.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ Brief summary of control files.
8585
memory.oom_control set/show oom controls.
8686
memory.numa_stat show the number of memory usage per numa
8787
node
88-
8988
memory.kmem.limit_in_bytes set/show hard limit for kernel memory
89+
This knob is deprecated and shouldn't be
90+
used. It is planned that this be removed in
91+
the foreseeable future.
9092
memory.kmem.usage_in_bytes show current kernel memory allocation
9193
memory.kmem.failcnt show the number of kernel memory usage
9294
hits limits

mm/memcontrol.c

+3
Original file line numberDiff line numberDiff line change
@@ -3637,6 +3637,9 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
36373637
ret = mem_cgroup_resize_max(memcg, nr_pages, true);
36383638
break;
36393639
case _KMEM:
3640+
pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. "
3641+
"Please report your usecase to [email protected] if you "
3642+
"depend on this functionality.\n");
36403643
ret = memcg_update_kmem_max(memcg, nr_pages);
36413644
break;
36423645
case _TCP:

0 commit comments

Comments
 (0)