public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Potapenko <glider@google.com>
To: glider@google.com, dvyukov@google.com, elver@google.com,
	akpm@linux-foundation.org, mingo@kernel.org, linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com
Subject: [PATCH v1] mm: make __GFP_BITS_SHIFT independent of CONFIG_LOCKDEP
Date: Mon, 18 Sep 2023 17:32:41 +0200	[thread overview]
Message-ID: <20230918153241.2942764-1-glider@google.com> (raw)

The list of GFP flags is sparse already (see 0x200u and flags defined
based on CONFIG_KASAN_HW_TAGS), so it makes little sense to save one
bit at the end of it if CONFIG_LOCKDEP is undefined.

The dependence of __GFP_BITS_SHIFT on CONFIG_LOCKDEP also does not let us
add new flags after ___GFP_NOLOCKDEP.

Signed-off-by: Alexander Potapenko <glider@google.com>

---

An alternative to this patch would be putting all ___GFP_ flags into
enum, so that we they occupy as few bits as possible.
My understanding is that this is doable, because tools/perf/builtin-kmem.c
does not depend on the flag values, but maybe I am missing something?
---
 include/linux/gfp_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h
index 6583a58670c57..bb8d3b31e3b6d 100644
--- a/include/linux/gfp_types.h
+++ b/include/linux/gfp_types.h
@@ -249,7 +249,7 @@ typedef unsigned int __bitwise gfp_t;
 #define __GFP_NOLOCKDEP ((__force gfp_t)___GFP_NOLOCKDEP)
 
 /* Room for N __GFP_FOO bits */
-#define __GFP_BITS_SHIFT (26 + IS_ENABLED(CONFIG_LOCKDEP))
+#define __GFP_BITS_SHIFT (27)
 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
 
 /**
-- 
2.42.0.459.ge4e396fd5e-goog


                 reply	other threads:[~2023-09-18 15:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230918153241.2942764-1-glider@google.com \
    --to=glider@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox