Re: [PATCH] perf intel-pt: don't zero the whole perf_sample

From: Tavian Barnes
Date: Mon Jan 13 2025 - 11:29:29 EST


On Mon, Jan 13, 2025 at 3:15 AM Adrian Hunter <adrian.hunter@xxxxxxxxx> wrote:
> On 11/01/25 19:56, Tavian Barnes wrote:
> > C designated initializers like
> >
> > struct perf_sample sample = { .ip = 0, };
> >
> > set every unmentioned field of the struct to zero. But since
> > sizeof(struct perf_sample) == 1384, this takes a long time.
> >
> > struct perf_sample does not need to be fully initialized, and even
>
> Yes it does need to be fully initialized. Leaving members
> uninitialized in the hope that they never get used adds to
> code complexity e.g. how do you know they never are used,
> or future members never will be used.

Right, please ignore this patch then. I thought I had seen other
cases where perf_sample was not fully initialized but I wasn't reading
the code carefully enough. Sorry for the noise!