diff mbox series

[net-next,v2,3/5] netconsole: append msgid to sysdata

Message ID 20250612-netconsole-msgid-v2-3-d4c1abc84bac@gmail.com
State New
Headers show
Series [net-next,v2,1/5] netconsole: introduce 'msgid' as a new sysdata field | expand

Commit Message

Gustavo Luiz Duarte June 12, 2025, 8:02 p.m. UTC
Add msgcounter to the netconsole_target struct to generate message IDs.
If the msgid_enabled attribute is true, increment msgcounter and append
msgid=<msgcounter> to sysdata buffer before sending the message.

Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>
---
 drivers/net/netconsole.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Jakub Kicinski June 14, 2025, 7:51 p.m. UTC | #1
On Thu, 12 Jun 2025 13:02:16 -0700 Gustavo Luiz Duarte wrote:
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 3bf8777fcd01..baa9862c1bc3 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -155,6 +155,8 @@ struct netconsole_target {
>  	size_t			userdata_length;
>  	/* bit-wise with sysdata_feature bits */
>  	u32			sysdata_fields;
> +	/* protected by target_list_lock */
> +	u32			msgcounter;
>  #endif

kdoc is complaining that:

drivers/net/netconsole.c:167 struct member 'msgcounter' not described in 'netconsole_target'
Gustavo Luiz Duarte June 16, 2025, 4:07 p.m. UTC | #2
On Sat, Jun 14, 2025 at 8:51 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 12 Jun 2025 13:02:16 -0700 Gustavo Luiz Duarte wrote:
> > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> > index 3bf8777fcd01..baa9862c1bc3 100644
> > --- a/drivers/net/netconsole.c
> > +++ b/drivers/net/netconsole.c
> > @@ -155,6 +155,8 @@ struct netconsole_target {
> >       size_t                  userdata_length;
> >       /* bit-wise with sysdata_feature bits */
> >       u32                     sysdata_fields;
> > +     /* protected by target_list_lock */
> > +     u32                     msgcounter;
> >  #endif
>
> kdoc is complaining that:
>
> drivers/net/netconsole.c:167 struct member 'msgcounter' not described in 'netconsole_target'

Good catch. I'm sending v3 to fix this (will also add kdoc check to my
pre-send checklist).
Thanks for the review!
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 3bf8777fcd01..baa9862c1bc3 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -155,6 +155,8 @@  struct netconsole_target {
 	size_t			userdata_length;
 	/* bit-wise with sysdata_feature bits */
 	u32			sysdata_fields;
+	/* protected by target_list_lock */
+	u32			msgcounter;
 #endif
 	struct netconsole_target_stats stats;
 	bool			enabled;
@@ -1345,6 +1347,14 @@  static int sysdata_append_release(struct netconsole_target *nt, int offset)
 			 init_utsname()->release);
 }
 
+static int sysdata_append_msgid(struct netconsole_target *nt, int offset)
+{
+	wrapping_assign_add(nt->msgcounter, 1);
+	return scnprintf(&nt->extradata_complete[offset],
+			 MAX_EXTRADATA_ENTRY_LEN, " msgid=%u\n",
+			 nt->msgcounter);
+}
+
 /*
  * prepare_extradata - append sysdata at extradata_complete in runtime
  * @nt: target to send message to
@@ -1367,6 +1377,8 @@  static int prepare_extradata(struct netconsole_target *nt)
 		extradata_len += sysdata_append_taskname(nt, extradata_len);
 	if (nt->sysdata_fields & SYSDATA_RELEASE)
 		extradata_len += sysdata_append_release(nt, extradata_len);
+	if (nt->sysdata_fields & SYSDATA_MSGID)
+		extradata_len += sysdata_append_msgid(nt, extradata_len);
 
 	WARN_ON_ONCE(extradata_len >
 		     MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS);