Re: [PATCH v2] tracing/ipv4/ipv6: Use static array for name field in fib*_lookup_table event
From: David Ahern
Date: Mon Jul 04 2022 - 15:09:20 EST
On 7/4/22 7:14 AM, Steven Rostedt wrote:
> From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>
>
> The fib_lookup_table and fib6_lookup_table events declare name as a
> dynamic_array, but also give it a fixed size, which defeats the purpose of
> the dynamic array, especially since the dynamic array also includes meta
> data in the event to specify its size.
>
> Since the size of the name is at most 16 bytes (defined by IFNAMSIZ),
> it is not worth spending the effort to determine the size of the string.
>
> Just use a fixed size array and copy into it. This will save 4 bytes that
> are used for the meta data that saves the size and position of a dynamic
> array, and even slightly speed up the event processing.
>
> Cc: David Ahern <dsahern@xxxxxxxxx>
> Cc: David S. Miller <davem@xxxxxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
> ---
> Changes since v1: https://lkml.kernel.org/r/20220703102359.30f12e39@xxxxxxxxxxxxxxxxxxxx
> - Just use a fixed size array instead of calculating the
> size needed for the dynamic allocation.
>
> include/trace/events/fib.h | 6 +++---
> include/trace/events/fib6.h | 8 ++++----
> 2 files changed, 7 insertions(+), 7 deletions(-)
>
Reviewed-by: David Ahern <dsahern@xxxxxxxxxx>