[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250919101727.16152-2-farbere@amazon.com>
Date: Fri, 19 Sep 2025 10:17:01 +0000
From: Eliav Farber <farbere@...zon.com>
To: <linux@...linux.org.uk>, <jdike@...toit.com>, <richard@....at>,
<anton.ivanov@...bridgegreys.com>, <dave.hansen@...ux.intel.com>,
<luto@...nel.org>, <peterz@...radead.org>, <tglx@...utronix.de>,
<mingo@...hat.com>, <bp@...en8.de>, <x86@...nel.org>, <hpa@...or.com>,
<tony.luck@...el.com>, <qiuxu.zhuo@...el.com>, <mchehab@...nel.org>,
<james.morse@....com>, <rric@...nel.org>, <harry.wentland@....com>,
<sunpeng.li@....com>, <alexander.deucher@....com>,
<christian.koenig@....com>, <airlied@...ux.ie>, <daniel@...ll.ch>,
<evan.quan@....com>, <james.qian.wang@....com>, <liviu.dudau@....com>,
<mihail.atanassov@....com>, <brian.starkey@....com>,
<maarten.lankhorst@...ux.intel.com>, <mripard@...nel.org>,
<tzimmermann@...e.de>, <robdclark@...il.com>, <sean@...rly.run>,
<jdelvare@...e.com>, <linux@...ck-us.net>, <fery@...ress.com>,
<dmitry.torokhov@...il.com>, <agk@...hat.com>, <snitzer@...hat.com>,
<dm-devel@...hat.com>, <rajur@...lsio.com>, <davem@...emloft.net>,
<kuba@...nel.org>, <peppe.cavallaro@...com>, <alexandre.torgue@...com>,
<joabreu@...opsys.com>, <mcoquelin.stm32@...il.com>, <malattia@...ux.it>,
<hdegoede@...hat.com>, <mgross@...ux.intel.com>, <intel-linux-scu@...el.com>,
<artur.paszkiewicz@...el.com>, <jejb@...ux.ibm.com>,
<martin.petersen@...cle.com>, <sakari.ailus@...ux.intel.com>,
<gregkh@...uxfoundation.org>, <clm@...com>, <josef@...icpanda.com>,
<dsterba@...e.com>, <jack@...e.com>, <tytso@....edu>,
<adilger.kernel@...ger.ca>, <dushistov@...l.ru>,
<luc.vanoostenryck@...il.com>, <rostedt@...dmis.org>, <pmladek@...e.com>,
<sergey.senozhatsky@...il.com>, <andriy.shevchenko@...ux.intel.com>,
<linux@...musvillemoes.dk>, <minchan@...nel.org>, <ngupta@...are.org>,
<akpm@...ux-foundation.org>, <kuznet@....inr.ac.ru>,
<yoshfuji@...ux-ipv6.org>, <pablo@...filter.org>, <kadlec@...filter.org>,
<fw@...len.de>, <jmaloy@...hat.com>, <ying.xue@...driver.com>,
<willy@...radead.org>, <farbere@...zon.com>, <sashal@...nel.org>,
<ruanjinjie@...wei.com>, <David.Laight@...LAB.COM>,
<herve.codina@...tlin.com>, <Jason@...c4.com>, <bvanassche@....org>,
<keescook@...omium.org>, <linux-arm-kernel@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-um@...ts.infradead.org>,
<linux-edac@...r.kernel.org>, <amd-gfx@...ts.freedesktop.org>,
<dri-devel@...ts.freedesktop.org>, <linux-arm-msm@...r.kernel.org>,
<freedreno@...ts.freedesktop.org>, <linux-hwmon@...r.kernel.org>,
<linux-input@...r.kernel.org>, <linux-media@...r.kernel.org>,
<netdev@...r.kernel.org>, <linux-stm32@...md-mailman.stormreply.com>,
<platform-driver-x86@...r.kernel.org>, <linux-scsi@...r.kernel.org>,
<linux-staging@...ts.linux.dev>, <linux-btrfs@...r.kernel.org>,
<linux-ext4@...r.kernel.org>, <linux-sparse@...r.kernel.org>,
<linux-mm@...ck.org>, <netfilter-devel@...r.kernel.org>,
<coreteam@...filter.org>, <tipc-discussion@...ts.sourceforge.net>,
<stable@...r.kernel.org>
CC: <jonnyc@...zon.com>, Arnd Bergmann <arnd@...db.de>, Dan Williams
<dan.j.williams@...el.com>, Eric Dumazet <edumazet@...gle.com>, "Isabella
Basso" <isabbasso@...eup.net>, Josh Poimboeuf <jpoimboe@...nel.org>, "Masami
Hiramatsu" <mhiramat@...nel.org>, Nathan Chancellor <nathan@...nel.org>,
Sander Vanheule <sander@...nheule.net>, Vlastimil Babka <vbabka@...e.cz>,
Yury Norov <yury.norov@...il.com>
Subject: [PATCH 01/27 5.10.y] overflow, tracing: Define the is_signed_type() macro once
From: Bart Van Assche <bvanassche@....org>
[ Upstream commit 92d23c6e94157739b997cacce151586a0d07bb8a ]
There are two definitions of the is_signed_type() macro: one in
<linux/overflow.h> and a second definition in <linux/trace_events.h>.
As suggested by Linus Torvalds, move the definition of the
is_signed_type() macro into the <linux/compiler.h> header file. Change
the definition of the is_signed_type() macro to make sure that it does
not trigger any sparse warnings with future versions of sparse for
bitwise types. See also:
https://lore.kernel.org/all/CAHk-=whjH6p+qzwUdx5SOVVHjS3WvzJQr6mDUwhEyTf6pJWzaQ@mail.gmail.com/
https://lore.kernel.org/all/CAHk-=wjQGnVfb4jehFR0XyZikdQvCZouE96xR_nnf5kqaM5qqQ@mail.gmail.com/
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Eric Dumazet <edumazet@...gle.com>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Isabella Basso <isabbasso@...eup.net>
Cc: "Jason A. Donenfeld" <Jason@...c4.com>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: Luc Van Oostenryck <luc.vanoostenryck@...il.com>
Cc: Masami Hiramatsu <mhiramat@...nel.org>
Cc: Nathan Chancellor <nathan@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Sander Vanheule <sander@...nheule.net>
Cc: Steven Rostedt <rostedt@...dmis.org>
Cc: Vlastimil Babka <vbabka@...e.cz>
Cc: Yury Norov <yury.norov@...il.com>
Signed-off-by: Bart Van Assche <bvanassche@....org>
Signed-off-by: Kees Cook <keescook@...omium.org>
Link: https://lore.kernel.org/r/20220826162116.1050972-3-bvanassche@acm.org
Signed-off-by: Eliav Farber <farbere@...zon.com>
---
include/linux/compiler.h | 6 ++++++
include/linux/overflow.h | 1 -
include/linux/trace_events.h | 2 --
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index bbd74420fa21..004a030d5ad2 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -245,6 +245,12 @@ static inline void *offset_to_ptr(const int *off)
/* &a[0] degrades to a pointer: a different type from an array */
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
+/*
+ * Whether 'type' is a signed type or an unsigned type. Supports scalar types,
+ * bool and also pointer types.
+ */
+#define is_signed_type(type) (((type)(-1)) < (__force type)1)
+
/*
* This is needed in functions which generate the stack canary, see
* arch/x86/kernel/smpboot.c::start_secondary() for an example.
diff --git a/include/linux/overflow.h b/include/linux/overflow.h
index 35af574d006f..66dd311ad8eb 100644
--- a/include/linux/overflow.h
+++ b/include/linux/overflow.h
@@ -32,7 +32,6 @@
* https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html -
* credit to Christian Biere.
*/
-#define is_signed_type(type) (((type)(-1)) < (type)1)
#define __type_half_max(type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))
#define type_max(T) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))
#define type_min(T) ((T)((T)-type_max(T)-(T)1))
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 5af2acb9fb7d..0c8c3cf36f96 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -700,8 +700,6 @@ extern int trace_add_event_call(struct trace_event_call *call);
extern int trace_remove_event_call(struct trace_event_call *call);
extern int trace_event_get_offsets(struct trace_event_call *call);
-#define is_signed_type(type) (((type)(-1)) < (type)1)
-
int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
int trace_set_clr_event(const char *system, const char *event, int set);
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
--
2.47.3
Powered by blists - more mailing lists