Re: [PATCH v2 02/24] objtool: Introduce CFI hash

From: Peter Zijlstra
Date: Wed Aug 25 2021 - 08:51:01 EST


On Wed, Aug 25, 2021 at 12:13:43PM +0200, Peter Zijlstra wrote:
> On Fri, Aug 20, 2021 at 03:27:55PM -0700, Josh Poimboeuf wrote:
> > > +static struct cfi_state *cfi_alloc(void)
> > > +{
> > > + struct cfi_state *cfi = calloc(sizeof(struct cfi_state), 1);
> > > + if (!cfi) {
> > > + WARN("calloc failed");
> > > + exit(1);
> > > + }
> > > + nr_cfi++;
> > > + init_cfi_state(cfi);
> > > + return cfi;
> > > +}
> >
> > I'm thinking this should also add it to the hash. i.e. I don't think
> > there's a scenario where you'd alloc a cfi and not want to add it to the
> > hash. The more sharing the better.
>

> @@ -1666,9 +1666,8 @@ static int read_unwind_hints(struct objt
> continue;
> }
>
> - cfi = insn->cfip;
> - if (!cfi)
> - cfi = insn->cfip = cfi_alloc();

Urgh, the problem is that this runs before we allocate the hash-table!
Lemme try and re-order thing.