Re: [PATCH v6 06/24] tracing: Add events to trace remotes

Steven Rostedt
2025-09-09T21:47:08Z

On Thu, 21 Aug 2025 09:13:54 +0100
Vincent Donnefort <vdonnefort@google.com> wrote:

> @@ -265,16 +272,19 @@ static struct trace_remote_iterator *trace_remote_iter(struct trace_remote *remo
> static bool trace_remote_iter_next(struct trace_remote_iterator *iter)
> {
> struct trace_buffer *trace_buffer = iter->remote->trace_buffer;
> + struct ring_buffer_event *rb_evt;
> int cpu = iter->cpu;
>
> if (cpu != RING_BUFFER_ALL_CPUS) {
> if (ring_buffer_empty_cpu(trace_buffer, cpu))
> return false;
>
> - if (!ring_buffer_peek(trace_buffer, cpu, &iter->ts, &iter->lost_events))
> + rb_evt = ring_buffer_peek(trace_buffer, cpu, &iter->ts, &iter->lost_events);
> + if (!rb_evt)
> return false;
>
> iter->evt_cpu = cpu;
> + iter->evt = (struct remote_event_hdr *)&rb_evt->array[1];

Hmm, shouldn't this use ring_buffer_event_data(rb_evt) instead?

If the events get big, then it would be array[2]. But the
ring_buffer_event_data() hides that detail.

> return true;
> }
>
> @@ -286,7 +296,8 @@ static bool trace_remote_iter_next(struct trace_remote_iterator *iter)
> if (ring_buffer_empty_cpu(trace_buffer, cpu))
> continue;
>
> - if (!ring_buffer_peek(trace_buffer, cpu, &ts, &lost_events))
> + rb_evt = ring_buffer_peek(trace_buffer, cpu, &ts, &lost_events);

Ditto.

> + if (!rb_evt)
> continue;
>
> if (ts >= iter->ts)
> @@ -294,14 +305,18 @@ static bool trace_remote_iter_next(struct trace_remote_iterator *iter)
>
> iter->ts = ts;
> iter->evt_cpu = cpu;
> + iter->evt = (struct remote_event_hdr *)&rb_evt->array[1];

Ditto.

-- Steve

> iter->lost_events = lost_events;
> }
>
> return iter->ts != U64_MAX;
> }
>
> +static struct remote_event *trace_remote_find_event(struct trace_remote *remote, unsigned short id);
> +
> static int trace_remote_iter_print(struct trace_remote_iterator *iter)
> {
> + struct remote_event *evt;
> unsigned long usecs_rem;
> u64 ts = iter->ts;
>