2022-07-14 16:47:19

by Steven Rostedt

[permalink] [raw]
Subject: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper

From: "Steven Rostedt (Google)" <[email protected]>

Instead of open coding a __dynamic_array() with a fixed length (which
defeats the purpose of the dynamic array in the first place). Use the new
__vstring() helper that will use a va_list and only write enough of the
string into the ring buffer that is needed.

Link: https://lkml.kernel.org/r/[email protected]

Cc: Marek Lindner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Simon Wunderlich <[email protected]>
Cc: Antonio Quartulli <[email protected]>
Cc: Sven Eckelmann <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
net/batman-adv/trace.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/trace.h b/net/batman-adv/trace.h
index d673ebdd0426..67d2a8a0196c 100644
--- a/net/batman-adv/trace.h
+++ b/net/batman-adv/trace.h
@@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg,
TP_STRUCT__entry(
__string(device, bat_priv->soft_iface->name)
__string(driver, KBUILD_MODNAME)
- __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
+ __vstring(msg, vaf->fmt, vaf->va)
),

TP_fast_assign(
__assign_str(device, bat_priv->soft_iface->name);
__assign_str(driver, KBUILD_MODNAME);
- WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
- BATADV_MAX_MSG_LEN,
- vaf->fmt,
- *vaf->va) >= BATADV_MAX_MSG_LEN);
+ __assign_vstr(msg, vaf->fmt, vaf->va);
),

TP_printk(
--
2.35.1


2022-07-24 22:21:47

by Sven Eckelmann

[permalink] [raw]
Subject: Re: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper

On Thursday, 14 July 2022 18:43:13 CEST Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <[email protected]>
>
> Instead of open coding a __dynamic_array() with a fixed length (which
> defeats the purpose of the dynamic array in the first place).

Please also make sure to remove the define of BATADV_MAX_MSG_LEN

Kind regards,
Sven

[...]
> --- a/net/batman-adv/trace.h
> +++ b/net/batman-adv/trace.h
> @@ -40,16 +40,13 @@ TRACE_EVENT(batadv_dbg,
> TP_STRUCT__entry(
> __string(device, bat_priv->soft_iface->name)
> __string(driver, KBUILD_MODNAME)
> - __dynamic_array(char, msg, BATADV_MAX_MSG_LEN)
> + __vstring(msg, vaf->fmt, vaf->va)
> ),
>
> TP_fast_assign(
> __assign_str(device, bat_priv->soft_iface->name);
> __assign_str(driver, KBUILD_MODNAME);
> - WARN_ON_ONCE(vsnprintf(__get_dynamic_array(msg),
> - BATADV_MAX_MSG_LEN,
> - vaf->fmt,
> - *vaf->va) >= BATADV_MAX_MSG_LEN);
> + __assign_vstr(msg, vaf->fmt, vaf->va);
> ),
>
> TP_printk(
>


Attachments:
signature.asc (849.00 B)
This is a digitally signed message part.

2022-07-24 23:17:01

by Steven Rostedt

[permalink] [raw]
Subject: Re: [for-next][PATCH 17/23] batman-adv: tracing: Use the new __vstring() helper

On Sun, 24 Jul 2022 23:31:01 +0200
Sven Eckelmann <[email protected]> wrote:

> On Thursday, 14 July 2022 18:43:13 CEST Steven Rostedt wrote:
> > From: "Steven Rostedt (Google)" <[email protected]>
> >
> > Instead of open coding a __dynamic_array() with a fixed length (which
> > defeats the purpose of the dynamic array in the first place).
>
> Please also make sure to remove the define of BATADV_MAX_MSG_LEN

I usually do not like to rebase my for-next and just add on a patch to
do something like this, but for this series I'll make an exception.

-- Steve