Re: [PATCH 05/13] objtool: Increase per-function WARN_FUNC() rate limit

From: Brendan Jackman
Date: Tue Mar 18 2025 - 07:00:43 EST


On Mon Mar 17, 2025 at 12:29 PM UTC, Miroslav Benes wrote:
> > > 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:
>
> I think it is correct but I also think that the difference between bits
> and the actual number of "allowed" warnings can be confusing.

Oh, yeah sorry I did not read this properly. So it's using
(1<<nbits)-2 as the "report that we're skipping duplicates" special
value.

So IMO we need something like:

/* Subtract one because the warnings==WARN_LIMIT is used to report skipped warnings. */
static_assert(WARN_LIMIT < (1 << STRUCT_SYMBOL_WARNING_BITS) - 1, "symbol.warnings too small");