lkml.org 
[lkml]   [2023]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tracing/synthetic: use union instead of casts
On Tue,  8 Aug 2023 16:21:48 +0200
Sven Schnelle <svens@linux.ibm.com> wrote:

> +struct trace_dynamic {
> + union {
> + u8 as_u8;
> + u16 as_u16;
> + u32 as_u32;
> + u64 as_u64;
> + struct {
> +#ifdef CONFIG_CPU_BIG_ENDIAN
> + u16 offset;
> + u16 len;
> +#else
> + u16 len;
> + u16 offset;
> +#endif
> + };
> + };
> +};
> +

The "dynamic" I was using wasn't about the fields were dynamic (union), but
because the field the offset/len combo represents is of dynamic size. It's
used all over the trace_events code.

I would have in include/linux/trace_events.h (right above struct trace_entry):

/* Used to find the offset and length of dynamic fields in trace events */
struct trace_dynamic_info {
#ifdef CONFIG_CPU_BIG_ENDIAN
u16 offset;
u16 len;
#else
u16 len;
u16 offset;
#endif
};

And then it kernel/trace/trace.h:

union trace_synthetic_field {
u8 as_u8;
u16 as_u16;
u32 as_u32;
u64 as_u64;
struct trace_dynamic_info as_dynamic;
};

I could work on the part of the trace_dynamic_info if you want.

-- Steve

\
 
 \ /
  Last update: 2023-08-08 20:20    [W:0.653 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site