From: Zhongkun He <hezhongkun.hzk@bytedance.com>
To: akpm@linux-foundation.org, mhocko@suse.com
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Zhongkun He <hezhongkun.hzk@bytedance.com>
Subject: [PATCH] mm: rename the oldflags and parameter in memalloc_flags_*()
Date: Wed, 18 Jun 2025 15:03:28 +0800 [thread overview]
Message-ID: <20250618070328.2192849-1-hezhongkun.hzk@bytedance.com> (raw)
The variable name oldflags can indeed be misleading, because
it does not store the complete original value of flags.
Instead, it records which flags from the given set are not
currently set. So rename it.
Signed-off-by: Zhongkun He <hezhongkun.hzk@bytedance.com>
---
include/linux/sched/mm.h | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index b13474825130..6b4b54e8db92 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -322,21 +322,21 @@ static inline void might_alloc(gfp_t gfp_mask)
}
/**
- * memalloc_flags_save - Add a PF_* flag to current->flags, save old value
+ * memalloc_flags_save - Add a PF_* flag to current->flags, return saved flags mask
*
* This allows PF_* flags to be conveniently added, irrespective of current
* value, and then the old version restored with memalloc_flags_restore().
*/
-static inline unsigned memalloc_flags_save(unsigned flags)
+static inline unsigned int memalloc_flags_save(unsigned int flags_mask)
{
- unsigned oldflags = ~current->flags & flags;
- current->flags |= flags;
- return oldflags;
+ unsigned int saved_flags_mask = ~current->flags & flags_mask;
+
+ current->flags |= flags_mask;
+ return saved_flags_mask;
}
-static inline void memalloc_flags_restore(unsigned flags)
+static inline void memalloc_flags_restore(unsigned int flags_mask)
{
- current->flags &= ~flags;
+ current->flags &= ~flags_mask;
}
/**
--
2.39.5
next reply other threads:[~2025-06-18 7:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 7:03 Zhongkun He [this message]
2025-06-18 23:43 ` Andrew Morton
2025-06-19 0:07 ` Kent Overstreet
2025-06-19 3:17 ` [External] " Zhongkun He
2025-06-19 4:16 ` Kent Overstreet
2025-06-19 4:36 ` Zhongkun He
2025-06-19 2:50 ` Zhongkun He
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=20250618070328.2192849-1-hezhongkun.hzk@bytedance.com \
--to=hezhongkun.hzk@bytedance.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox