Re: synchronization model: was: Re: [PATCH printk-rework 09/14] printk: introduce a kmsg_dump iterator

Petr Mladek
2021-02-26T09:50:15Z

On Fri 2021-02-26 09:36:21, John Ogness wrote:
> On 2021-02-25, Petr Mladek <pmladek@suse.com> wrote:
> > IMHO, a better design would be:
> >
> > 1. dumper->dump() callback should have only one parameter @reason.
> > The callback should define its own iterator, buffer, and
> > do the dump.
>
> Unfortunately this won't work because drivers/mtd/mtdoops.c is using the
> dumper parameter for container_of().

Ah, I have missed this.

mtdoops code is generic even though everything is static so that there
is always only one instance. But this use case makes sense in general.

> So we will need 2 parameters: dumper and reason.
>
> Can we agree to proceed with 2 parameters in the callback?

Yup, go for it.

> > 2. dumpe->dump() callback should synchronize the entire operation
> > using its own locks. Only the callback knows whether it is
> > safe to do more dumps in parallel. Only the callback knows
> > whether it is called only during panic() when no locks
> > are needed.
>
> Agreed. I implemented this part for the v3 series.

Great!

Best Regards,
Petr