[Devel] [PATCH RH7] memcg: force accounting to specifeid memcg
Vasily Averin
vvs at virtuozzo.com
Fri Aug 6 15:27:53 MSK 2021
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);
}
--
1.8.3.1
More information about the Devel
mailing list