%pGg produces nice readable output and decouples the format string from the size of gfp_t. Signed-off-by: Brendan Jackman --- drivers/gpu/drm/drm_managed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c index 247f468731de0..a9da94319b052 100644 --- a/drivers/gpu/drm/drm_managed.c +++ b/drivers/gpu/drm/drm_managed.c @@ -232,8 +232,8 @@ void *drmm_kmalloc(struct drm_device *dev, size_t size, gfp_t gfp) dr = alloc_dr(NULL, size, gfp, dev_to_node(dev->dev)); if (!dr) { - drm_dbg_drmres(dev, "failed to allocate %zu bytes, %u flags\n", - size, gfp); + drm_dbg_drmres(dev, "failed to allocate %zu bytes, %pGg\n", + size, &gfp); return NULL; } dr->node.name = kstrdup_const("kmalloc", gfp); -- 2.51.2 %pGg produces nice readable output and decouples the format string from the size of gfp_t. Signed-off-by: Brendan Jackman --- drivers/net/wireless/intel/iwlegacy/3945-mac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlegacy/3945-mac.c b/drivers/net/wireless/intel/iwlegacy/3945-mac.c index c148654aa9533..ced85eb7522e9 100644 --- a/drivers/net/wireless/intel/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/intel/iwlegacy/3945-mac.c @@ -1002,9 +1002,9 @@ il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR("Failed to allocate SKB buffer with %0x." + IL_ERR("Failed to allocate SKB buffer with %pGg." "Only %u free buffers remaining.\n", - priority, rxq->free_count); + &priority, rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ -- 2.51.2 %pGg produces nice readable output and decouples the format string from the size of gfp_t. Signed-off-by: Brendan Jackman --- mm/kfence/kfence_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kfence/kfence_test.c b/mm/kfence/kfence_test.c index 5725a367246d9..10424cd25e5a6 100644 --- a/mm/kfence/kfence_test.c +++ b/mm/kfence/kfence_test.c @@ -263,7 +263,7 @@ static void *test_alloc(struct kunit *test, size_t size, gfp_t gfp, enum allocat break; } - kunit_info(test, "%s: size=%zu, gfp=%x, policy=%s, cache=%i\n", __func__, size, gfp, + kunit_info(test, "%s: size=%zu, gfp=%pGg, policy=%s, cache=%i\n", __func__, size, &gfp, policy_name, !!test_cache); /* -- 2.51.2 %pGg produces nice readable output and decouples the format string from the size of gfp_t. Signed-off-by: Brendan Jackman --- net/rds/tcp_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c index 49f96ee0c40f6..ffe843ca219c7 100644 --- a/net/rds/tcp_recv.c +++ b/net/rds/tcp_recv.c @@ -275,7 +275,7 @@ static int rds_tcp_read_sock(struct rds_conn_path *cp, gfp_t gfp) desc.count = 1; /* give more than one skb per call */ tcp_read_sock(sock->sk, &desc, rds_tcp_data_recv); - rdsdebug("tcp_read_sock for tc %p gfp 0x%x returned %d\n", tc, gfp, + rdsdebug("tcp_read_sock for tc %p gfp %pGg returned %d\n", tc, &gfp, desc.error); if (skb_queue_empty_lockless(&sock->sk->sk_receive_queue) && -- 2.51.2 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 --- 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