printk: kmsg_dump: Mark registered flag as private
PATCH 1/1 printk: kmsg_dump: Mark registered flag as private
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.
--- include/linux/kmsg_dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/kmsg_dump.h +1 -1
@@ -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
Quoted 17 lines · Ahmed S. Darwish
The 'registered' flag is internally used by
kmsg_dump_register()andkmsg_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 <[email protected]>--- include/linux/kmsg_dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/kmsg_dump.h +0
-0
include/linux/kmsg_dump.h enum kmsg_dump_reason { · line 42
Quoted 8 lines
include/linux/kmsg_dump.h +1
-1@@ -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
Quoted 13 lines · Sergey Senozhatsky
Quoted 12 lines · Ahmed S. Darwish
The 'registered' flag is internally used by
kmsg_dump_register()andkmsg_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 <[email protected]>--- include/linux/kmsg_dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
include/linux/kmsg_dump.h enum kmsg_dump_reason { · line 42
Quoted 13 lines
include/linux/kmsg_dump.h +1
-1@@ -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.
Quoted 2 lines
$ 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?
Quoted 1 line
include/linux/uwb.h: * specific (private) DevAddr (UWB_RSV_TARGET_DEVADDR).
Best Regards,
Petr
Quoted 7 lines · Petr Mladek
Quoted 7 lines
Quoted 6 lines
* @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)
*/
structkmsg_dumper{
structlist_headlist;
[..]
Quoted 3 lines
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;
};Quoted 3 lines
Well, I am not sure if it is worth it. Andrew?
Agreed.
-ss
Hi,
Quoted 31 lines · Sergey Senozhatsky
Quoted 17 lines · Ahmed S. Darwish
The 'registered' flag is internally used by
kmsg_dump_register()andkmsg_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 <[email protected]>--- include/linux/kmsg_dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/kmsg_dump.h +0
-0include/linux/kmsg_dump.h enum kmsg_dump_reason { · line 42
Quoted 8 lines
include/linux/kmsg_dump.h +1
-1@@ -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?
Quoted 4 lines
$ 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