[Devel] [PATCH RHEL7 COMMIT] memcg: force accounting to specified memcg
Vasily Averin
vvs at virtuozzo.com
Thu Sep 2 20:20:36 MSK 2021
The commit is pushed to "branch-rh7-3.10.0-1160.41.1.vz7.183.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.41.1.vz7.183.1
------>
commit 2d78ccbf71df61467989985bc5e94fe7e6bb6ca9
Author: Vasily Averin <vvs at virtuozzo.com>
Date: Thu Sep 2 20:20:36 2021 +0300
memcg: force accounting to specified memcg
Currently some allocations can silently bypass accounting to root memcg.
This happen for __GFP_ACCOUNT allocations and if current task got fatal signal.
In vz8 and upstream this check was removed, and such allocations
are accounted to specified memcg without any limits.
I hope this helps to prevent global OOM in few threads inide limited container
got fatal signals and by this way got approval for unlimited host memory allocations.
https://jira.sw.ru/browse/PSBM-132705
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
include/linux/memcontrol.h | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index f609a15..cffdd62 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -639,21 +639,9 @@ memcg_kmem_newpage_charge(struct page *page, gfp_t gfp, int order)
if (!(gfp & __GFP_ACCOUNT))
return true;
- /*
- * __GFP_NOFAIL allocations will move on even if charging is not
- * possible. Therefore we don't even try, and have this allocation
- * unaccounted. We could in theory charge it forcibly, but we hope
- * those allocations are rare, and won't be worth the trouble.
- */
- if (gfp & __GFP_NOFAIL)
- return true;
if (!in_task() || (!current->mm) || (current->flags & PF_KTHREAD))
return true;
- /* If the test is dying, just let it go. */
- if (unlikely(fatal_signal_pending(current)))
- return true;
-
return __memcg_kmem_newpage_charge(page, gfp, order);
}
@@ -683,12 +671,9 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
{
if (!memcg_kmem_enabled())
return cachep;
- if (gfp & __GFP_NOFAIL)
- return cachep;
+
if (!in_task() || (!current->mm) || (current->flags & PF_KTHREAD))
return cachep;
- if (unlikely(fatal_signal_pending(current)))
- return cachep;
return __memcg_kmem_get_cache(cachep, gfp);
}
More information about the Devel
mailing list