From: Kent Overstreet <kent.overstreet@linux.dev>
To: linux-mm@kvack.org
Cc: Kent Overstreet <kent.overstreet@linux.dev>,
Vlastimil Babka <vbabka@suse.cz>,
Matthew Wilcox <willy@infradead.org>,
Michal Hocko <mhocko@kernel.org>,
"Darrick J . Wong" <djwong@kernel.org>
Subject: [PATCH 2/2] mm: introduce PF_MEMALLOC_NOWARN
Date: Fri, 26 Jan 2024 17:07:56 -0500 [thread overview]
Message-ID: <20240126220756.395187-2-kent.overstreet@linux.dev> (raw)
In-Reply-To: <20240126220756.395187-1-kent.overstreet@linux.dev>
If we're using PF_MEMALLOC, we might have a fallback and might not to
warn about a failing allocation - thus we need a PF_* equivalent of
__GFP_NOWARN.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
---
include/linux/sched.h | 8 ++++----
include/linux/sched/mm.h | 8 +++++++-
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index cdb8ea53c365..36a5046ea3fa 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1632,11 +1632,11 @@ extern struct pid *cad_pid;
#define PF_KSWAPD 0x00020000 /* I am kswapd */
#define PF_MEMALLOC_NOFS 0x00040000 /* All allocation requests will inherit GFP_NOFS */
#define PF_MEMALLOC_NOIO 0x00080000 /* All allocation requests will inherit GFP_NOIO */
-#define PF_LOCAL_THROTTLE 0x00100000 /* Throttle writes only against the bdi I write to,
+#define PF_MEMALLOC_NOWARN 0x00100000 /* All allocation requests will inherit __GFP_NOWARN */
+#define PF_LOCAL_THROTTLE 0x00200000 /* Throttle writes only against the bdi I write to,
* I am cleaning dirty pages from some other bdi. */
-#define PF_KTHREAD 0x00200000 /* I am a kernel thread */
-#define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */
-#define PF__HOLE__00800000 0x00800000
+#define PF_KTHREAD 0x00400000 /* I am a kernel thread */
+#define PF_RANDOMIZE 0x00800000 /* Randomize virtual address space */
#define PF__HOLE__01000000 0x01000000
#define PF__HOLE__02000000 0x02000000
#define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index f00d7ecc2adf..817f5c1bf3d5 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -236,7 +236,10 @@ 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_NOWARN |
+ PF_MEMALLOC_PIN))) {
/*
* NOIO implies both NOIO and NOFS and it is a weaker context
* so always make sure it makes precedence
@@ -246,6 +249,9 @@ static inline gfp_t current_gfp_context(gfp_t flags)
else if (pflags & PF_MEMALLOC_NOFS)
flags &= ~__GFP_FS;
+ if (pflags & PF_MEMALLOC_NOWARN)
+ flags |= __GFP_NOWARN;
+
if (pflags & PF_MEMALLOC_PIN)
flags &= ~__GFP_MOVABLE;
}
--
2.43.0
next prev parent reply other threads:[~2024-01-26 22:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-26 22:07 [PATCH 1/2] mm: introduce memalloc_flags_{save,restore} Kent Overstreet
2024-01-26 22:07 ` Kent Overstreet [this message]
2024-01-28 15:45 ` [PATCH 2/2] mm: introduce PF_MEMALLOC_NOWARN Michal Hocko
2024-01-28 19:43 ` Kent Overstreet
2024-01-29 10:48 ` Michal Hocko
2024-02-01 11:03 ` Kent Overstreet
2024-02-01 15:59 ` Michal Hocko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240126220756.395187-2-kent.overstreet@linux.dev \
--to=kent.overstreet@linux.dev \
--cc=djwong@kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.