Re: [PATCH] printk: kmsg_dump: Mark registered flag as private

From: Ahmed S. Darwish
Date: Tue Mar 12 2019 - 16:05:49 EST


Hi,

On Mon, Mar 11, 2019 at 09:49:05PM +0900, Sergey Senozhatsky wrote:
> On (03/10/19 21:03), Ahmed S. Darwish wrote:
> > The 'registered' flag is internally used by kmsg_dump_register()
> > and kmsg_dump_unregister() to track multiple registrations of the
> > same dumper.
> >
> > It's protected by printk's internal dump_list_lock, and must thus
> > be accessed only from there. Mark it as private.
> >
> > Signed-off-by: Ahmed S. Darwish <darwish.07@xxxxxxxxx>
> > ---
> > include/linux/kmsg_dump.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
> > index 2e7a1e032c71..7c08cb58259a 100644
> > --- a/include/linux/kmsg_dump.h
> > +++ b/include/linux/kmsg_dump.h
> > @@ -36,7 +36,7 @@ enum kmsg_dump_reason {
> > * @dump: Call into dumping code which will retrieve the data with
> > * through the record iterator
> > * @max_reason: filter for highest reason number that should be dumped
> > - * @registered: Flag that specifies if this is already registered
> > + * @registered: Flag that specifies if this is already registered (private)
> > */
> > struct kmsg_dumper {
> > struct list_head list;
>
>
> Do we really do this thing?
>
>
> $ git grep "(private)" include/linux/
> include/linux/kmsg_dump.h: * @list: Entry in the dumper list (private)
> include/linux/uwb.h: * specific (private) DevAddr (UWB_RSV_TARGET_DEVADDR).
>

Hmmm, while writing a kmsg_dumper for [1], I noticed that struct
kmsg_dumper is:

/**
* struct kmsg_dumper - kernel crash message dumper structure
* @list: Entry in the dumper list (private) <== *
* ...
* @registered: Flag that specifies if this is already registered
*/
struct kmsg_dumper {
struct list_head list;
...
bool registered;
/* private state of the kmsg iterator */ <== *
...
};

_All_ private members are annotated (<== *), so this gave the
impression that 'bool registered' was public..

Then I discovered from printk.c code that it's actually private,
and protected by the printk's internal dump_list_lock...

So this trivial patch was submitted for consistency.

thanks,

[1] 20190310013142.GA3376@darwi-home-pc">https://lore.kernel.org/lkml/20190310013142.GA3376@darwi-home-pc

--
darwi
http://darwish.chasingpointers.com