Re: [PATCH 1/4] genirq/irq_sim: dispose of remaining mappings before removing the domain

From: Andy Shevchenko
Date: Tue Aug 15 2023 - 12:54:18 EST


On Tue, Aug 15, 2023 at 09:09:10AM -0700, Yury Norov wrote:
> On Tue, Aug 15, 2023 at 01:38:49PM +0300, Andy Shevchenko wrote:
> > On Sat, Aug 12, 2023 at 09:44:54PM +0200, Bartosz Golaszewski wrote:

...

> > > @@ -16,12 +17,14 @@ struct irq_sim_work_ctx {
> > > unsigned int irq_count;
> > > unsigned long *pending;
> > > struct irq_domain *domain;
> > > + struct list_head irqs;
> > > };
> > >
> > > struct irq_sim_irq_ctx {
> > > int irqnum;
> > > bool enabled;
> > > struct irq_sim_work_ctx *work_ctx;
> >
> > > + struct list_head siblings;
> >
> > You can reduce the code size by moving this to be the first member.
> > Not sure about struct irq_sim_work_ctx, you can play with bloat-o-meter.
>
> Pahole you meant?

No. I meant bloat-o-meter.

...

> But as Bartosz said in the other email, "it's just good practice
> resulting from years of" kernel coding to have:
> - members declared strongly according to the logic of the code, and
> if no strong preference:

> - list head be the first element of the structure, to let compiler
> avoid generating offsets when traversing lists;

Exactly.

> - put elements of greater size at the beginning, so no holes will be
> emitted like in the example above.
>
> So I'd suggest:
>
> struct irq_sim_irq_ctx {
> struct list_head siblings;
> struct irq_sim_work_ctx *work_ctx;
> int irqnum;
> bool enabled;
> }

Yes, I like this.

--
With Best Regards,
Andy Shevchenko