[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250704152537.55724-8-urezki@gmail.com>
Date: Fri, 4 Jul 2025 17:25:37 +0200
From: "Uladzislau Rezki (Sony)" <urezki@...il.com>
To: linux-mm@...ck.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Michal Hocko <mhocko@...nel.org>,
LKML <linux-kernel@...r.kernel.org>,
Baoquan He <bhe@...hat.com>,
Uladzislau Rezki <urezki@...il.com>
Subject: [RFC 7/7] mm: Drop __GFP_DIRECT_RECLAIM flag if PF_MEMALLOC is set
The memory allocator already avoids reclaim when PF_MEMALLOC is set.
Clear __GFP_DIRECT_RECLAIM explicitly to suppress might_alloc() warnings
to make more correct behavior.
Signed-off-by: Uladzislau Rezki (Sony) <urezki@...il.com>
---
include/linux/sched/mm.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index b13474825130..40757173acb1 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -246,12 +246,14 @@ static inline bool in_vfork(struct task_struct *tsk)
* PF_MEMALLOC_NOIO implies GFP_NOIO
* PF_MEMALLOC_NOFS implies GFP_NOFS
* PF_MEMALLOC_PIN implies !GFP_MOVABLE
+ * PF_MEMALLOC implies !__GFP_DIRECT_RECLAIM
*/
static inline gfp_t current_gfp_context(gfp_t flags)
{
unsigned int pflags = READ_ONCE(current->flags);
- if (unlikely(pflags & (PF_MEMALLOC_NOIO | PF_MEMALLOC_NOFS | PF_MEMALLOC_PIN))) {
+ if (unlikely(pflags & (PF_MEMALLOC_NOIO | PF_MEMALLOC_NOFS |
+ PF_MEMALLOC_PIN | PF_MEMALLOC))) {
/*
* NOIO implies both NOIO and NOFS and it is a weaker context
* so always make sure it makes precedence
@@ -263,6 +265,9 @@ static inline gfp_t current_gfp_context(gfp_t flags)
if (pflags & PF_MEMALLOC_PIN)
flags &= ~__GFP_MOVABLE;
+
+ if (pflags & PF_MEMALLOC)
+ flags &= ~__GFP_DIRECT_RECLAIM;
}
return flags;
}
--
2.39.5
Powered by blists - more mailing lists