LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] printk: kmsg_dump: Mark registered flag as private
@ 2019-03-10 20:03 Ahmed S. Darwish
  2019-03-11 12:49 ` Sergey Senozhatsky
  0 siblings, 1 reply; 5+ messages in thread
From: Ahmed S. Darwish @ 2019-03-10 20:03 UTC (permalink / raw)
  To: Petr Mladek, Sergey Senozhatsky; +Cc: Steven Rostedt, John Ogness, linux-kernel

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@gmail.com>
---
 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;
--
2.21.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] printk: kmsg_dump: Mark registered flag as private
  2019-03-10 20:03 [PATCH] printk: kmsg_dump: Mark registered flag as private Ahmed S. Darwish
@ 2019-03-11 12:49 ` Sergey Senozhatsky
  2019-03-12  9:18   ` Petr Mladek
  2019-03-12 20:05   ` Ahmed S. Darwish
  0 siblings, 2 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2019-03-11 12:49 UTC (permalink / raw)
  To: Ahmed S. Darwish
  Cc: Petr Mladek, Sergey Senozhatsky, Steven Rostedt, John Ogness,
	linux-kernel

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@gmail.com>
> ---
>  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).

	-ss

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] printk: kmsg_dump: Mark registered flag as private
  2019-03-11 12:49 ` Sergey Senozhatsky
@ 2019-03-12  9:18   ` Petr Mladek
  2019-03-12  9:34     ` Sergey Senozhatsky
  2019-03-12 20:05   ` Ahmed S. Darwish
  1 sibling, 1 reply; 5+ messages in thread
From: Petr Mladek @ 2019-03-12  9:18 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Ahmed S. Darwish, Sergey Senozhatsky, Steven Rostedt,
	John Ogness, linux-kernel

On Mon 2019-03-11 21:49:05, 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@gmail.com>
> > ---
> >  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?

Good question.

> $ git grep "(private)" include/linux/
> include/linux/kmsg_dump.h: * @list:     Entry in the dumper list (private)

This is another field in the same structure. There are 4 other fields
that are described as private by extra comment. Thefore this patch
might make it more consistent.

Well, I am not sure if it is worth it. Andrew?

> include/linux/uwb.h: * specific (private) DevAddr (UWB_RSV_TARGET_DEVADDR).

Best Regards,
Petr

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] printk: kmsg_dump: Mark registered flag as private
  2019-03-12  9:18   ` Petr Mladek
@ 2019-03-12  9:34     ` Sergey Senozhatsky
  0 siblings, 0 replies; 5+ messages in thread
From: Sergey Senozhatsky @ 2019-03-12  9:34 UTC (permalink / raw)
  To: Petr Mladek
  Cc: Andrew Morton, Ahmed S. Darwish, Sergey Senozhatsky,
	Steven Rostedt, John Ogness, linux-kernel

On (03/12/19 10:18), Petr Mladek wrote:
> > >   * @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;
> > 
[..]
> This is another field in the same structure. There are 4 other fields
> that are described as private by extra comment. Thefore this patch
> might make it more consistent.

Well, no objections from my side. At the same time nothing in kmsg_dump.h
suggests that "(private)" stands for "protected by logbuf_lock". Even more,
that struct has another "private" members, which are protected by
logbuf_lock - cur_idx, next_idx, cur_srq, next_seq; except when they are
not (see kmsg_dump_get_line_nolock() and other _nolock() functions). So
"private" has conflicting meanings.

struct kmsg_dumper {
	struct list_head list;
	void (*dump)(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason);
	enum kmsg_dump_reason max_reason;
	bool active;
	bool registered;

	/* private state of the kmsg iterator */
	u32 cur_idx;
	u32 next_idx;
	u64 cur_seq;
	u64 next_seq;
};

> 
> Well, I am not sure if it is worth it. Andrew?
> 

Agreed.

	-ss

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] printk: kmsg_dump: Mark registered flag as private
  2019-03-11 12:49 ` Sergey Senozhatsky
  2019-03-12  9:18   ` Petr Mladek
@ 2019-03-12 20:05   ` Ahmed S. Darwish
  1 sibling, 0 replies; 5+ messages in thread
From: Ahmed S. Darwish @ 2019-03-12 20:05 UTC (permalink / raw)
  To: Sergey Senozhatsky; +Cc: Petr Mladek, Steven Rostedt, John Ogness, linux-kernel

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@gmail.com>
> > ---
> >  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] https://lore.kernel.org/lkml/20190310013142.GA3376@darwi-home-pc

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-10 20:03 [PATCH] printk: kmsg_dump: Mark registered flag as private Ahmed S. Darwish
2019-03-11 12:49 ` Sergey Senozhatsky
2019-03-12  9:18   ` Petr Mladek
2019-03-12  9:34     ` Sergey Senozhatsky
2019-03-12 20:05   ` Ahmed S. Darwish

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lkml.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lkml.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lkml.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lkml.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lkml.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lkml.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lkml.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lkml.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lkml.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lkml.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lkml.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lkml.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git