Skip to content

Commit 0a7fb6f

Browse files
jpoimboePeter Zijlstra
authored andcommitted
objtool: Increase per-function WARN_FUNC() rate limit
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 <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/aec318d66c037a51c9f376d6fb0e8ff32812a037.1741975349.git.jpoimboe@kernel.org
1 parent dd95beb commit 0a7fb6f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

tools/objtool/check.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ static int disas_warned_funcs(struct objtool_file *file)
45474547
char *funcs = NULL, *tmp;
45484548

45494549
for_each_sym(file, sym) {
4550-
if (sym->warned) {
4550+
if (sym->warnings) {
45514551
if (!funcs) {
45524552
funcs = malloc(strlen(sym->name) + 1);
45534553
strcpy(funcs, sym->name);

tools/objtool/include/objtool/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ struct symbol {
6565
u8 return_thunk : 1;
6666
u8 fentry : 1;
6767
u8 profiling_func : 1;
68-
u8 warned : 1;
6968
u8 embedded_insn : 1;
7069
u8 local_label : 1;
7170
u8 frame_pointer : 1;
71+
u8 warnings : 2;
7272
struct list_head pv_target;
7373
struct reloc *relocs;
7474
};

tools/objtool/include/objtool/warn.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,22 @@ static inline char *offstr(struct section *sec, unsigned long offset)
5353
free(_str); \
5454
})
5555

56+
#define WARN_LIMIT 2
57+
5658
#define WARN_INSN(insn, format, ...) \
5759
({ \
5860
struct instruction *_insn = (insn); \
59-
if (!_insn->sym || !_insn->sym->warned) \
61+
BUILD_BUG_ON(WARN_LIMIT > 2); \
62+
if (!_insn->sym || _insn->sym->warnings < WARN_LIMIT) { \
6063
WARN_FUNC(format, _insn->sec, _insn->offset, \
6164
##__VA_ARGS__); \
62-
if (_insn->sym) \
63-
_insn->sym->warned = 1; \
65+
if (_insn->sym) \
66+
_insn->sym->warnings++; \
67+
} else if (_insn->sym && _insn->sym->warnings == WARN_LIMIT) { \
68+
WARN_FUNC("skipping duplicate warning(s)", \
69+
_insn->sec, _insn->offset); \
70+
_insn->sym->warnings++; \
71+
} \
6472
})
6573

6674
#define BT_INSN(insn, format, ...) \

0 commit comments

Comments
 (0)