-
Notifications
You must be signed in to change notification settings - Fork 54.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
2 changed files
with
7 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
|
||
#if defined(CONFIG_MEMCG_KMEM) || defined(CONFIG_MMU) | ||
static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages) | ||
static inline void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages) | ||
{ | ||
if (mem_cgroup_is_root(memcg)) | ||
return; | ||
|
@@ -2781,7 +2780,6 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages) | |
if (do_memsw_account()) | ||
page_counter_uncharge(&memcg->memsw, nr_pages); | ||
} | ||
#endif | ||
|
||
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, | ||
unsigned int nr_pages) | ||
{ | ||
struct page_counter *counter; | ||
struct mem_cgroup *memcg; | ||
int ret; | ||
|
||
|
@@ -3010,21 +3007,8 @@ static int obj_cgroup_charge_pages(struct obj_cgroup *objcg, gfp_t gfp, | |
if (ret) | ||
goto out; | ||
|
||
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && | ||
!page_counter_try_charge(&memcg->kmem, nr_pages, &counter)) { | ||
|
||
/* | ||
* 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; | ||
} | ||
if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) | ||
page_counter_charge(&memcg->kmem, nr_pages); | ||
out: | ||
css_put(&memcg->css); | ||
|
||
|
@@ -3714,17 +3698,6 @@ static void memcg_offline_kmem(struct mem_cgroup *memcg) | |
} | ||
#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) | ||
{ | ||
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); | ||
break; | ||
case _KMEM: | ||
pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. " | ||
"Please report your usecase to [email protected] if you " | ||
"depend on this functionality.\n"); | ||
ret = memcg_update_kmem_max(memcg, nr_pages); | ||
/* kmem.limit_in_bytes is deprecated. */ | ||
ret = -EOPNOTSUPP; | ||
break; | ||
case _TCP: | ||
ret = memcg_update_tcp_max(memcg, nr_pages); | ||
|