Skip to content

Commit 58056f7

Browse files
shakeelbtorvalds
authored andcommitted
memcg, kmem: further deprecate kmem.limit_in_bytes
The deprecation process of kmem.limit_in_bytes started with the commit 0158115 ("memcg, kmem: deprecate kmem.limit_in_bytes") which also explains in detail the motivation behind the deprecation. To summarize, it is the unexpected behavior on hitting the kmem limit. This patch moves the deprecation process to the next stage by disallowing to set the kmem limit. In future we might just remove the kmem.limit_in_bytes file completely. [[email protected]: s/ENOTSUPP/EOPNOTSUPP/] [[email protected]: mark cancel_charge() inline] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Shakeel Butt <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Roman Gushchin <[email protected]> Acked-by: Michal Hocko <[email protected]> Reviewed-by: Muchun Song <[email protected]> Cc: Vasily Averin <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 16f6bf2 commit 58056f7

File tree

2 files changed

+7
-43
lines changed

2 files changed

+7
-43
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,8 @@ Brief summary of control files.
8787
memory.oom_control set/show oom controls.
8888
memory.numa_stat show the number of memory usage per numa
8989
node
90-
memory.kmem.limit_in_bytes set/show hard limit for kernel memory
91-
This knob is deprecated and shouldn't be
92-
used. It is planned that this be removed in
93-
the foreseeable future.
90+
memory.kmem.limit_in_bytes This knob is deprecated and writing to
91+
it will return -ENOTSUPP.
9492
memory.kmem.usage_in_bytes show current kernel memory allocation
9593
memory.kmem.failcnt show the number of kernel memory usage
9694
hits limits
@@ -518,11 +516,6 @@ will be charged as a new owner of it.
518516
charged file caches. Some out-of-use page caches may keep charged until
519517
memory pressure happens. If you want to avoid that, force_empty will be useful.
520518

521-
Also, note that when memory.kmem.limit_in_bytes is set the charges due to
522-
kernel pages will still be seen. This is not considered a failure and the
523-
write will still return success. In this case, it is expected that
524-
memory.kmem.usage_in_bytes == memory.usage_in_bytes.
525-
526519
5.2 stat file
527520
-------------
528521

mm/memcontrol.c

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2771,8 +2771,7 @@ static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
27712771
return try_charge_memcg(memcg, gfp_mask, nr_pages);
27722772
}
27732773

2774-
#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
2775-
static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
2774+
static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
27762775
{
27772776
if (mem_cgroup_is_root(memcg))
27782777
return;
@@ -2781,7 +2780,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
27812780
if (do_memsw_account())
27822781
page_counter_uncharge(&memcg->memsw, nr_pages);
27832782
}
2784-
#endif
27852783

27862784
static void commit_charge(struct page *page, struct mem_cgroup *memcg)
27872785
{
@@ -3000,7 +2998,6 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
30002998
static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
30012999
unsigned int nr_pages)
30023000
{
3003-
struct page_counter *counter;
30043001
struct mem_cgroup *memcg;
30053002
int ret;
30063003

@@ -3010,21 +3007,8 @@ static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
30103007
if (ret)
30113008
goto out;
30123009

3013-
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
3014-
!page_counter_try_charge(&memcg->kmem, nr_pages, &counter)) {
3015-
3016-
/*
3017-
* Enforce __GFP_NOFAIL allocation because callers are not
3018-
* prepared to see failures and likely do not have any failure
3019-
* handling code.
3020-
*/
3021-
if (gfp & __GFP_NOFAIL) {
3022-
page_counter_charge(&memcg->kmem, nr_pages);
3023-
goto out;
3024-
}
3025-
cancel_charge(memcg, nr_pages);
3026-
ret = -ENOMEM;
3027-
}
3010+
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
3011+
page_counter_charge(&memcg->kmem, nr_pages);
30283012
out:
30293013
css_put(&memcg->css);
30303014

@@ -3714,17 +3698,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
37143698
}
37153699
#endif /* CONFIG_MEMCG_KMEM */
37163700

3717-
static int memcg_update_kmem_max(struct mem_cgroup *memcg,
3718-
unsigned long max)
3719-
{
3720-
int ret;
3721-
3722-
mutex_lock(&memcg_max_mutex);
3723-
ret = page_counter_set_max(&memcg->kmem, max);
3724-
mutex_unlock(&memcg_max_mutex);
3725-
return ret;
3726-
}
3727-
37283701
static int memcg_update_tcp_max(struct mem_cgroup *memcg, unsigned long max)
37293702
{
37303703
int ret;
@@ -3790,10 +3763,8 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
37903763
ret = mem_cgroup_resize_max(memcg, nr_pages, true);
37913764
break;
37923765
case _KMEM:
3793-
pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. "
3794-
"Please report your usecase to [email protected] if you "
3795-
"depend on this functionality.\n");
3796-
ret = memcg_update_kmem_max(memcg, nr_pages);
3766+
/* kmem.limit_in_bytes is deprecated. */
3767+
ret = -EOPNOTSUPP;
37973768
break;
37983769
case _TCP:
37993770
ret = memcg_update_tcp_max(memcg, nr_pages);

0 commit comments

Comments
 (0)