linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Brendan Jackman <jackmanb@google.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>,
	 David Rientjes <rientjes@google.com>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Brendan Jackman <jackmanb@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>, Zi Yan <ziy@nvidia.com>,
	 Harry Yoo <harry.yoo@oracle.com>, Hao Li <hao.li@linux.dev>,
	 Christoph Lameter <cl@gentwo.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	 Uladzislau Rezki <urezki@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 5/5] mm: Change gfp_t to unsigned long
Date: Thu, 19 Mar 2026 16:03:28 +0000	[thread overview]
Message-ID: <20260319-gfp64-v1-5-2c73b8d42b7f@google.com> (raw)
In-Reply-To: <20260319-gfp64-v1-0-2c73b8d42b7f@google.com>

GFP flag bits are starting to get scarce. There are upcoming features
that can tolerate being 64-bit only, which offers a simple way to escape
GFP bit scarcity: just make gfp_t 64 bits on 64 bit systems.

Update mm-internal printk formats to use %lx - external format strings
have already been decoupled from the size of gfp_t. Also
lib/test_lockup.c which uses the arg in a module_param_unsafe()
invocation where gfp_t doesn't work.

Some care needs to be taken here with code that converts between ALLOC_*
flags and GFP flags since the former are still unsigned int. The current
code is fine but just to be safe, add a BUILD_BUG_ON() for each GFP
flag that gets converted this way.

Signed-off-by: Brendan Jackman <jackmanb@google.com>
---
 include/linux/types.h | 2 +-
 lib/test_lockup.c     | 2 +-
 mm/oom_kill.c         | 2 +-
 mm/page_alloc.c       | 5 ++++-
 mm/page_owner.c       | 4 ++--
 mm/slab_common.c      | 2 +-
 mm/slub.c             | 2 +-
 mm/vmalloc.c          | 2 +-
 8 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/include/linux/types.h b/include/linux/types.h
index 7e71d260763c7..a8490c1381f99 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -160,7 +160,7 @@ typedef u64 dma_addr_t;
 typedef u32 dma_addr_t;
 #endif
 
-typedef unsigned int __bitwise gfp_t;
+typedef unsigned long __bitwise gfp_t;
 typedef unsigned int __bitwise slab_flags_t;
 typedef unsigned int __bitwise fmode_t;
 
diff --git a/lib/test_lockup.c b/lib/test_lockup.c
index c3fd87d6c2dd0..7adc03ac0b39d 100644
--- a/lib/test_lockup.c
+++ b/lib/test_lockup.c
@@ -130,7 +130,7 @@ module_param(alloc_pages_order, uint, 0400);
 MODULE_PARM_DESC(alloc_pages_order, "page order to allocate");
 
 static gfp_t alloc_pages_gfp = GFP_KERNEL;
-module_param_unsafe(alloc_pages_gfp, uint, 0400);
+module_param_unsafe(alloc_pages_gfp, unsigned long, 0400);
 MODULE_PARM_DESC(alloc_pages_gfp, "allocate pages with this gfp_mask, default GFP_KERNEL");
 
 static bool alloc_pages_atomic;
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 5c6c95c169ee8..272ecce090f75 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -458,7 +458,7 @@ static void dump_oom_victim(struct oom_control *oc, struct task_struct *victim)
 
 static void dump_header(struct oom_control *oc)
 {
-	pr_warn("%s invoked oom-killer: gfp_mask=%#x(%pGg), order=%d, oom_score_adj=%d\n",
+	pr_warn("%s invoked oom-killer: gfp_mask=%#lx(%pGg), order=%d, oom_score_adj=%d\n",
 		current->comm, oc->gfp_mask, &oc->gfp_mask, oc->order,
 			current->signal->oom_score_adj);
 	if (!IS_ENABLED(CONFIG_COMPACTION) && oc->order)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2d4b6f1a554ed..f0b9e8a950ee7 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -4036,7 +4036,7 @@ void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...)
 	va_start(args, fmt);
 	vaf.fmt = fmt;
 	vaf.va = &args;
-	pr_warn("%s: %pV, mode:%#x(%pGg), nodemask=%*pbl",
+	pr_warn("%s: %pV, mode:%#lx(%pGg), nodemask=%*pbl",
 			current->comm, &vaf, gfp_mask, &gfp_mask,
 			nodemask_pr_args(nodemask));
 	va_end(args);
@@ -4504,6 +4504,9 @@ gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order)
 	 */
 	BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_MIN_RESERVE);
 	BUILD_BUG_ON(__GFP_KSWAPD_RECLAIM != (__force gfp_t) ALLOC_KSWAPD);
+	/* Alloc flags are unsigned int, gfp_t may be larger. */
+	BUILD_BUG_ON(___GFP_HIGH_BIT >= BITS_PER_TYPE(typeof(alloc_flags)));
+	BUILD_BUG_ON(___GFP_KSWAPD_RECLAIM_BIT >= BITS_PER_TYPE(typeof(alloc_flags)));
 
 	/*
 	 * The caller may dip into page reserves a bit more if the caller
diff --git a/mm/page_owner.c b/mm/page_owner.c
index 8178e0be557f8..70afbdb945b1e 100644
--- a/mm/page_owner.c
+++ b/mm/page_owner.c
@@ -558,7 +558,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn,
 		return -ENOMEM;
 
 	ret = scnprintf(kbuf, count,
-			"Page allocated via order %u, mask %#x(%pGg), pid %d, tgid %d (%s), ts %llu ns\n",
+			"Page allocated via order %u, mask %#lx(%pGg), pid %d, tgid %d (%s), ts %llu ns\n",
 			page_owner->order, page_owner->gfp_mask,
 			&page_owner->gfp_mask, page_owner->pid,
 			page_owner->tgid, page_owner->comm,
@@ -630,7 +630,7 @@ void __dump_page_owner(const struct page *page)
 	else
 		pr_alert("page_owner tracks the page as freed\n");
 
-	pr_alert("page last allocated via order %u, migratetype %s, gfp_mask %#x(%pGg), pid %d, tgid %d (%s), ts %llu, free_ts %llu\n",
+	pr_alert("page last allocated via order %u, migratetype %s, gfp_mask %#lx(%pGg), pid %d, tgid %d (%s), ts %llu, free_ts %llu\n",
 		 page_owner->order, migratetype_names[mt], gfp_mask, &gfp_mask,
 		 page_owner->pid, page_owner->tgid, page_owner->comm,
 		 page_owner->ts_nsec, page_owner->free_ts_nsec);
diff --git a/mm/slab_common.c b/mm/slab_common.c
index d5a70a831a2a5..548e0d0f9aab3 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -1028,7 +1028,7 @@ gfp_t kmalloc_fix_flags(gfp_t flags)
 	gfp_t invalid_mask = flags & GFP_SLAB_BUG_MASK;
 
 	flags &= ~GFP_SLAB_BUG_MASK;
-	pr_warn("Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n",
+	pr_warn("Unexpected gfp: %#lx (%pGg). Fixing up to gfp: %#lx (%pGg). Fix your code!\n",
 			invalid_mask, &invalid_mask, flags, &flags);
 	dump_stack();
 
diff --git a/mm/slub.c b/mm/slub.c
index 2b2d33cc735cb..083f4e9de3ecb 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -4235,7 +4235,7 @@ slab_out_of_memory(struct kmem_cache *s, gfp_t gfpflags, int nid)
 	if ((gfpflags & __GFP_NOWARN) || !__ratelimit(&slub_oom_rs))
 		return;
 
-	pr_warn("SLUB: Unable to allocate memory on CPU %u (of node %d) on node %d, gfp=%#x(%pGg)\n",
+	pr_warn("SLUB: Unable to allocate memory on CPU %u (of node %d) on node %d, gfp=%#lx(%pGg)\n",
 		cpu, cpu_to_node(cpu), nid, gfpflags, &gfpflags);
 	pr_warn("  cache: %s, object size: %u, buffer size: %u, default order: %u, min order: %u\n",
 		s->name, s->object_size, s->size, oo_order(s->oo),
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 61caa55a44027..e353e281fa95d 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3949,7 +3949,7 @@ static gfp_t vmalloc_fix_flags(gfp_t flags)
 	gfp_t invalid_mask = flags & ~GFP_VMALLOC_SUPPORTED;
 
 	flags &= GFP_VMALLOC_SUPPORTED;
-	WARN_ONCE(1, "Unexpected gfp: %#x (%pGg). Fixing up to gfp: %#x (%pGg). Fix your code!\n",
+	WARN_ONCE(1, "Unexpected gfp: %#lx (%pGg). Fixing up to gfp: %#lx (%pGg). Fix your code!\n",
 		  invalid_mask, &invalid_mask, flags, &flags);
 	return flags;
 }

-- 
2.51.2



  parent reply	other threads:[~2026-03-19 16:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 16:03 [PATCH 0/5] mm: Switch " Brendan Jackman
2026-03-19 16:03 ` [PATCH 1/5] drm/managed: Use special gfp_t format specifier Brendan Jackman
2026-03-19 16:03 ` [PATCH 2/5] iwlegacy: 3945-mac: " Brendan Jackman
2026-03-19 16:03 ` [PATCH 3/5] mm/kfence: " Brendan Jackman
2026-03-19 16:03 ` [PATCH 4/5] net/rds: " Brendan Jackman
2026-03-19 16:03 ` Brendan Jackman [this message]
2026-03-22 13:25   ` [PATCH 5/5] mm: Change gfp_t to unsigned long kernel test robot
2026-03-22 15:39   ` kernel test robot
2026-03-22 18:47   ` kernel test robot
2026-03-19 16:56 ` [PATCH 0/5] mm: Switch " Matthew Wilcox
2026-03-19 18:40   ` Brendan Jackman
2026-03-19 21:39     ` Matthew Wilcox
2026-03-20  9:48       ` Brendan Jackman
2026-03-20 10:02         ` Vlastimil Babka (SUSE)
2026-03-20 13:22         ` Brendan Jackman
2026-03-19 17:03 ` Vlastimil Babka (SUSE)
2026-03-19 17:38   ` Brendan Jackman
2026-03-19 19:58     ` Vlastimil Babka (SUSE)
2026-03-20  9:56       ` Brendan Jackman
2026-03-19 18:30 ` Zi Yan
2026-03-20  9:37 ` Brendan Jackman
2026-03-20 16:26   ` Andrew Morton

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=20260319-gfp64-v1-5-2c73b8d42b7f@google.com \
    --to=jackmanb@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@gentwo.org \
    --cc=hannes@cmpxchg.org \
    --cc=hao.li@linux.dev \
    --cc=harry.yoo@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=urezki@gmail.com \
    --cc=vbabka@kernel.org \
    --cc=ziy@nvidia.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