Re: [PATCH v2 1/4] perf trace: Allocate syscall stats only if summary is on

From: Ian Rogers
Date: Tue Feb 04 2025 - 10:59:23 EST


On Mon, Feb 3, 2025 at 6:59 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
>
> On Sat, Feb 01, 2025 at 10:57:00PM -0800, Ian Rogers wrote:
> > On Wed, Jan 29, 2025 at 7:05 PM Namhyung Kim <namhyung@xxxxxxxxxx> wrote:
> > >
> > > The syscall stats are used only when summary is requested. Let's avoid
> > > unnecessary operations. Pass 'trace' pointer to check summary and give
> > > output file together.
> >
> > I don't think this last sentence makes sense.
>
> Thanks for your review. I'd say: Pass 'trace' pointer instead of doing
> 'summary' option and 'output' file pointer separately.

This still doesn't make sense. There is lazier initialization:
```
- ttrace->syscall_stats = intlist__new(NULL);
+ if (trace->summary)
+ ttrace->syscall_stats = intlist__new(NULL);
```
and there are functions that take a FILE* but now we're going to use
the one in trace instead:
```
@@ -1568,7 +1569,7 @@ static struct thread_trace *thread__trace(struct
thread *thread, FILE *fp)

return ttrace;
fail:
- color_fprintf(fp, PERF_COLOR_RED,
+ color_fprintf(trace->output, PERF_COLOR_RED,
"WARNING: not enough memory, dropping samples!\n");
return NULL;
```
So why does the one passed to trace still exist? Unfortunately names
like "fp" and "output" are not intention revealing.

Anyway, from the commit message and the code I don't understand what
this change is trying to do.

Thanks,
Ian