From: Eric Biggers <ebiggers@kernel.org>
To: stable@vger.kernel.org
Cc: linux-hardening@vger.kernel.org, linux-fscrypt@vger.kernel.org,
linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Ricardo Ribalda <ribalda@chromium.org>,
Richard Fitzgerald <rf@opensource.cirrus.com>,
Ben Dooks <ben.dooks@codethink.co.uk>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH 6.12 4/7] default_gfp(): avoid using the "newfangled" __VA_OPT__ trick
Date: Thu, 16 Jul 2026 21:43:00 -0700 [thread overview]
Message-ID: <20260717044303.425265-5-ebiggers@kernel.org> (raw)
In-Reply-To: <20260717044303.425265-1-ebiggers@kernel.org>
From: Linus Torvalds <torvalds@linux-foundation.org>
commit 551d44200152cb26f75d2ef990aeb6185b7e37fd upstream.
The default_gfp() helper that I added is not wrong, but it turns out
that it causes unnecessary headaches for 'sparse' which doesn't support
the use of __VA_OPT__ (introduced in C++20 and C23, and supported by gcc
and clang for a long time).
We do already use __VA_OPT__ in some other cases in the kernel (drm/xe
and btrfs), but it has been fairly limited. Now it triggers for pretty
much everything, and sparse ends up not working at all.
We can use the traditional gcc ',##__VA_ARGS__' syntax instead: it may
not be the "C standard" way and is slightly less natural in this
context, but it is the traditional model for this and avoids the sparse
problem.
Reported-and-tested-by: Ricardo Ribalda <ribalda@chromium.org>
Reported-and-tested-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Reported-by: Ben Dooks <ben.dooks@codethink.co.uk>
Fixes: e19e1b480ac7 ("add default_gfp() helper macro and use it in the new *alloc_obj() helpers")
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
include/linux/gfp.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/gfp.h b/include/linux/gfp.h
index abe4282fbdb1..c7621a0714c1 100644
--- a/include/linux/gfp.h
+++ b/include/linux/gfp.h
@@ -13,8 +13,8 @@ struct vm_area_struct;
struct mempolicy;
/* Helper macro to avoid gfp flags if they are the default one */
-#define __default_gfp(a,...) a
-#define default_gfp(...) __default_gfp(__VA_ARGS__ __VA_OPT__(,) GFP_KERNEL)
+#define __default_gfp(a,b,...) b
+#define default_gfp(...) __default_gfp(,##__VA_ARGS__,GFP_KERNEL)
/* Convert GFP flags to their corresponding migrate type */
#define GFP_MOVABLE_MASK (__GFP_RECLAIMABLE|__GFP_MOVABLE)
--
2.55.0
next prev parent reply other threads:[~2026-07-17 4:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-17 4:42 [PATCH 6.12 0/7] Backport object allocation APIs and two fscrypt fixes Eric Biggers
2026-07-17 4:42 ` [PATCH 6.12 1/7] slab: Introduce kmalloc_obj() and family Eric Biggers
2026-07-17 4:42 ` [PATCH 6.12 2/7] slab: Introduce kmalloc_flex() " Eric Biggers
2026-07-17 4:42 ` [PATCH 6.12 3/7] add default_gfp() helper macro and use it in the new *alloc_obj() helpers Eric Biggers
2026-07-17 4:43 ` Eric Biggers [this message]
2026-07-17 4:43 ` [PATCH 6.12 5/7] slab: recognize @GFP parameter as optional in kernel-doc Eric Biggers
2026-07-17 4:43 ` [PATCH 6.12 6/7] fscrypt: Fix key setup in edge case with multiple data unit sizes Eric Biggers
2026-07-17 4:43 ` [PATCH 6.12 7/7] fscrypt: Replace mk_users keyring with simple list Eric Biggers
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=20260717044303.425265-5-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=ben.dooks@codethink.co.uk \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rf@opensource.cirrus.com \
--cc=ribalda@chromium.org \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.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