memcg, kmem: further deprecate kmem.limit_in_bytes
The deprecation process of kmem.limit_in_bytes started with the commit
0158115f70
("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.
[akpm@linux-foundation.org: s/ENOTSUPP/EOPNOTSUPP/]
[arnd@arndb.de: mark cancel_charge() inline]
Link: https://lkml.kernel.org/r/20211022070542.679839-1-arnd@kernel.org
Link: https://lkml.kernel.org/r/20211019153408.2916808-1-shakeelb@google.com
Signed-off-by: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Roman Gushchin <guro@fb.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: Vasily Averin <vvs@virtuozzo.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
16f6bf266c
commit
58056f7750
2 changed files with 7 additions and 43 deletions
|
@ -87,10 +87,8 @@ Brief summary of control files.
|
||||||
memory.oom_control set/show oom controls.
|
memory.oom_control set/show oom controls.
|
||||||
memory.numa_stat show the number of memory usage per numa
|
memory.numa_stat show the number of memory usage per numa
|
||||||
node
|
node
|
||||||
memory.kmem.limit_in_bytes set/show hard limit for kernel memory
|
memory.kmem.limit_in_bytes This knob is deprecated and writing to
|
||||||
This knob is deprecated and shouldn't be
|
it will return -ENOTSUPP.
|
||||||
used. It is planned that this be removed in
|
|
||||||
the foreseeable future.
|
|
||||||
memory.kmem.usage_in_bytes show current kernel memory allocation
|
memory.kmem.usage_in_bytes show current kernel memory allocation
|
||||||
memory.kmem.failcnt show the number of kernel memory usage
|
memory.kmem.failcnt show the number of kernel memory usage
|
||||||
hits limits
|
hits limits
|
||||||
|
@ -518,11 +516,6 @@ will be charged as a new owner of it.
|
||||||
charged file caches. Some out-of-use page caches may keep charged until
|
charged file caches. Some out-of-use page caches may keep charged until
|
||||||
memory pressure happens. If you want to avoid that, force_empty will be useful.
|
memory pressure happens. If you want to avoid that, force_empty will be useful.
|
||||||
|
|
||||||
Also, note that when memory.kmem.limit_in_bytes is set the charges due to
|
|
||||||
kernel pages will still be seen. This is not considered a failure and the
|
|
||||||
write will still return success. In this case, it is expected that
|
|
||||||
memory.kmem.usage_in_bytes == memory.usage_in_bytes.
|
|
||||||
|
|
||||||
5.2 stat file
|
5.2 stat file
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
|
@ -2771,8 +2771,7 @@ static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
|
||||||
return try_charge_memcg(memcg, gfp_mask, nr_pages);
|
return try_charge_memcg(memcg, gfp_mask, nr_pages);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU)
|
static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
|
||||||
static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
|
|
||||||
{
|
{
|
||||||
if (mem_cgroup_is_root(memcg))
|
if (mem_cgroup_is_root(memcg))
|
||||||
return;
|
return;
|
||||||
|
@ -2781,7 +2780,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
|
||||||
if (do_memsw_account())
|
if (do_memsw_account())
|
||||||
page_counter_uncharge(&memcg->memsw, nr_pages);
|
page_counter_uncharge(&memcg->memsw, nr_pages);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static void commit_charge(struct page *page, struct mem_cgroup *memcg)
|
static void commit_charge(struct page *page, struct mem_cgroup *memcg)
|
||||||
{
|
{
|
||||||
|
@ -3000,7 +2998,6 @@ static void obj_cgroup_uncharge_pages(struct obj_cgroup *objcg,
|
||||||
static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
|
static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
|
||||||
unsigned int nr_pages)
|
unsigned int nr_pages)
|
||||||
{
|
{
|
||||||
struct page_counter *counter;
|
|
||||||
struct mem_cgroup *memcg;
|
struct mem_cgroup *memcg;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -3010,21 +3007,8 @@ static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) &&
|
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys))
|
||||||
!page_counter_try_charge(&memcg->kmem, nr_pages, &counter)) {
|
page_counter_charge(&memcg->kmem, nr_pages);
|
||||||
|
|
||||||
/*
|
|
||||||
* Enforce __GFP_NOFAIL allocation because callers are not
|
|
||||||
* prepared to see failures and likely do not have any failure
|
|
||||||
* handling code.
|
|
||||||
*/
|
|
||||||
if (gfp & __GFP_NOFAIL) {
|
|
||||||
page_counter_charge(&memcg->kmem, nr_pages);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
cancel_charge(memcg, nr_pages);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
}
|
|
||||||
out:
|
out:
|
||||||
css_put(&memcg->css);
|
css_put(&memcg->css);
|
||||||
|
|
||||||
|
@ -3714,17 +3698,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_MEMCG_KMEM */
|
#endif /* CONFIG_MEMCG_KMEM */
|
||||||
|
|
||||||
static int memcg_update_kmem_max(struct mem_cgroup *memcg,
|
|
||||||
unsigned long max)
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
mutex_lock(&memcg_max_mutex);
|
|
||||||
ret = page_counter_set_max(&memcg->kmem, max);
|
|
||||||
mutex_unlock(&memcg_max_mutex);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int memcg_update_tcp_max(struct mem_cgroup *memcg, unsigned long max)
|
static int memcg_update_tcp_max(struct mem_cgroup *memcg, unsigned long max)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -3790,10 +3763,8 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
|
||||||
ret = mem_cgroup_resize_max(memcg, nr_pages, true);
|
ret = mem_cgroup_resize_max(memcg, nr_pages, true);
|
||||||
break;
|
break;
|
||||||
case _KMEM:
|
case _KMEM:
|
||||||
pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. "
|
/* kmem.limit_in_bytes is deprecated. */
|
||||||
"Please report your usecase to linux-mm@kvack.org if you "
|
ret = -EOPNOTSUPP;
|
||||||
"depend on this functionality.\n");
|
|
||||||
ret = memcg_update_kmem_max(memcg, nr_pages);
|
|
||||||
break;
|
break;
|
||||||
case _TCP:
|
case _TCP:
|
||||||
ret = memcg_update_tcp_max(memcg, nr_pages);
|
ret = memcg_update_tcp_max(memcg, nr_pages);
|
||||||
|
|
Loading…
Add table
Reference in a new issue