From: Brendan Jackman <jackmanb@google.com>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH 05/13] objtool: Increase per-function WARN_FUNC() rate limit
Date: Mon, 17 Mar 2025 09:15:02 +0000 [thread overview]
Message-ID: <Z9foFvqpmo0nX1XP@google.com> (raw)
In-Reply-To: <aec318d66c037a51c9f376d6fb0e8ff32812a037.1741975349.git.jpoimboe@kernel.org>
On Fri, Mar 14, 2025 at 12:29:03PM -0700, Josh Poimboeuf wrote:
> Increase the per-function WARN_FUNC() rate limit from 1 to 2. If the
> number of warnings for a given function goes beyond 2, print "skipping
> duplicate warning(s)". This helps root out additional warnings in a
> function that might be hiding behind the first one.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
> ---
> tools/objtool/check.c | 2 +-
> tools/objtool/include/objtool/elf.h | 2 +-
> tools/objtool/include/objtool/warn.h | 14 +++++++++++---
> 3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 6b9ad3afe389..3ddaefe97f55 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -4528,7 +4528,7 @@ static int disas_warned_funcs(struct objtool_file *file)
> char *funcs = NULL, *tmp;
>
> for_each_sym(file, sym) {
> - if (sym->warned) {
> + if (sym->warnings) {
> if (!funcs) {
> funcs = malloc(strlen(sym->name) + 1);
> strcpy(funcs, sym->name);
> diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
> index d7e815c2fd15..223ac1c24b90 100644
> --- a/tools/objtool/include/objtool/elf.h
> +++ b/tools/objtool/include/objtool/elf.h
> @@ -65,10 +65,10 @@ struct symbol {
> u8 return_thunk : 1;
> u8 fentry : 1;
> u8 profiling_func : 1;
> - u8 warned : 1;
> u8 embedded_insn : 1;
> u8 local_label : 1;
> u8 frame_pointer : 1;
> + u8 warnings : 2;
> struct list_head pv_target;
> struct reloc *relocs;
> };
> diff --git a/tools/objtool/include/objtool/warn.h b/tools/objtool/include/objtool/warn.h
> index ac04d3fe4dd9..6180288927fd 100644
> --- a/tools/objtool/include/objtool/warn.h
> +++ b/tools/objtool/include/objtool/warn.h
> @@ -53,14 +53,22 @@ static inline char *offstr(struct section *sec, unsigned long offset)
> free(_str); \
> })
>
> +#define WARN_LIMIT 2
> +
> #define WARN_INSN(insn, format, ...) \
> ({ \
> struct instruction *_insn = (insn); \
> - if (!_insn->sym || !_insn->sym->warned) \
> + BUILD_BUG_ON(WARN_LIMIT > 2); \
Shouldn't this be >3? Anyway, I think it would be clearer if the
coupling was more explicit, e.g:
diff --git i/tools/objtool/include/objtool/elf.h w/tools/objtool/include/objtool/elf.h
index 223ac1c24b90..a86e43d2056f 100644
--- i/tools/objtool/include/objtool/elf.h
+++ w/tools/objtool/include/objtool/elf.h
@@ -46,6 +46,8 @@ struct section {
struct reloc *relocs;
};
+#define STRUCT_SYMBOL_WARNING_BITS 2
+
struct symbol {
struct list_head list;
struct rb_node node;
@@ -68,7 +70,7 @@ struct symbol {
u8 embedded_insn : 1;
u8 local_label : 1;
u8 frame_pointer : 1;
- u8 warnings : 2;
+ u8 warnings : STRUCT_SYMBOL_WARNING_BITS;
struct list_head pv_target;
struct reloc *relocs;
};
diff --git i/tools/objtool/include/objtool/warn.h w/tools/objtool/include/objtool/warn.h
index e72b9d630551..2fba6866fd2d 100644
--- i/tools/objtool/include/objtool/warn.h
+++ w/tools/objtool/include/objtool/warn.h
@@ -56,6 +56,7 @@ static inline char *offstr(struct section *sec, unsigned long offset)
})
#define WARN_LIMIT 2
+static_assert(WARN_LIMIT < (1 << STRUCT_SYMBOL_WARNING_BITS), "symbol.warnings too small");
#define WARN_INSN(insn, format, ...) \
({
Or just drop the bitfield (surely it can't be that important to save a
byte here?) and use sizeof, e.g:
BUILD_BUG_ON(ilog2(WARN_LIMIT) > sizeof(_insn->sym->warnings));
next prev parent reply other threads:[~2025-03-17 9:15 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-14 19:28 [PATCH 00/13] Fail the build on objtool warnings Josh Poimboeuf
2025-03-14 19:28 ` [PATCH 01/13] x86/traps: Make exc_double_fault() consistently noreturn Josh Poimboeuf
2025-03-17 8:26 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 10:47 ` [PATCH 01/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 02/13] objtool: Fix error handling inconsistencies in check() Josh Poimboeuf
2025-03-17 8:29 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 10:47 ` [PATCH 02/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 03/13] objtool: Improve __noreturn annotation warning Josh Poimboeuf
2025-03-17 8:31 ` Brendan Jackman
2025-03-17 10:36 ` Miroslav Benes
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 04/13] objtool: Update documentation Josh Poimboeuf
2025-03-17 8:47 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 10:46 ` [PATCH 04/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 05/13] objtool: Increase per-function WARN_FUNC() rate limit Josh Poimboeuf
2025-03-17 9:15 ` Brendan Jackman [this message]
2025-03-17 12:29 ` Miroslav Benes
2025-03-18 10:59 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 06/13] objtool: Remove --unret dependency on --rethunk Josh Poimboeuf
2025-03-14 19:38 ` Peter Zijlstra
2025-03-14 19:52 ` Josh Poimboeuf
2025-03-14 19:58 ` Peter Zijlstra
2025-03-17 12:33 ` Miroslav Benes
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-14 19:29 ` [PATCH 07/13] objtool: Consolidate option validation Josh Poimboeuf
2025-03-17 9:19 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:35 ` [PATCH 07/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 08/13] objtool: Upgrade "Linked object detected" warning to error Josh Poimboeuf
2025-03-17 9:21 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:38 ` [PATCH 08/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 09/13] objtool: Add --output option Josh Poimboeuf
2025-03-17 9:40 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:48 ` [PATCH 09/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 10/13] objtool: Add --Werror option Josh Poimboeuf
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 12:53 ` [PATCH 10/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 11/13] objtool: Change "warning:" to "error:" for --Werror Josh Poimboeuf
2025-03-17 9:42 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 13:04 ` [PATCH 11/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 12/13] objtool: Create backup on error and print args Josh Poimboeuf
2025-03-17 9:53 ` Brendan Jackman
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 14:09 ` [PATCH 12/13] " Miroslav Benes
2025-03-14 19:29 ` [PATCH 13/13] objtool: Add CONFIG_OBJTOOL_WERROR Josh Poimboeuf
2025-03-16 0:41 ` Ingo Molnar
2025-03-16 1:49 ` Josh Poimboeuf
2025-03-16 11:56 ` Ingo Molnar
2025-03-18 4:55 ` Josh Poimboeuf
2025-03-17 10:46 ` [tip: objtool/core] " tip-bot2 for Josh Poimboeuf
2025-03-17 11:07 ` tip-bot2 for Josh Poimboeuf
2025-03-17 21:27 ` Ingo Molnar
2025-03-18 0:05 ` Josh Poimboeuf
2025-03-20 17:10 ` Steven Rostedt
2025-03-18 11:51 ` Ingo Molnar
2025-03-18 14:26 ` Josh Poimboeuf
2025-03-20 8:51 ` Ingo Molnar
2025-03-18 0:27 ` Josh Poimboeuf
2025-03-18 4:59 ` Josh Poimboeuf
2025-03-17 14:14 ` [PATCH 13/13] " Miroslav Benes
2025-03-23 7:50 ` Josh Poimboeuf
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=Z9foFvqpmo0nX1XP@google.com \
--to=jackmanb@google.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.