[Devel] [PATCH RH7] memcg: fixes accounting for allocations called in "disabled BH" context

Vasily Averin vvs at virtuozzo.com
Mon Oct 5 10:34:03 MSK 2020


in_interrupt() check includes "have BH disabled" case,
as result allocations called with disabled BH are not accounted to
proper memory cgroup.
https://jira.sw.ru/browse/PSBM-108292
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
---
 include/linux/memcontrol.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 485a3d354b78..5e16658a356f 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -644,7 +644,7 @@ memcg_kmem_newpage_charge(struct page *page, gfp_t gfp, int order)
 	 */
 	if (gfp & __GFP_NOFAIL)
 		return true;
-	if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
+	if (!in_task() || (!current->mm) || (current->flags & PF_KTHREAD))
 		return true;
 
 	/* If the test is dying, just let it go. */
@@ -682,7 +682,7 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp)
 		return cachep;
 	if (gfp & __GFP_NOFAIL)
 		return cachep;
-	if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD))
+	if (!in_task() || (!current->mm) || (current->flags & PF_KTHREAD))
 		return cachep;
 	if (unlikely(fatal_signal_pending(current)))
 		return cachep;
-- 
2.17.1



More information about the Devel mailing list