RE: [PATCH] perf tools: ignore zombie process for user profile

From: Liang, Kan
Date: Wed Dec 14 2016 - 13:31:10 EST




>
> On Wed, Dec 14, 2016 at 12:48:05PM -0500, kan.liang@xxxxxxxxx wrote:
> > From: Kan Liang <kan.liang@xxxxxxxxx>
> >
> > If user has zombie process, the perf record -u will error out.
> > Here is an example.
> > $ ./testd &
> > [1] 23796
> > $ sudo perf record -e cycles -u kan
> > Error:
> > The sys_perf_event_open() syscall returned with 3 (No such process)
> > for event (cycles).
> > /bin/dmesg may provide additional information.
> > No CONFIG_PERF_EVENTS=y kernel support configured?
> >
> > The source code of testd is as below.
> > int main() {
> >
> > if (fork())
> > {
> > while (1);
> > }
> > return 0;
> > }
> >
> > Zombie process is dead process. It is meaningless to profile it.
> > It's better to ignore it for user profile.
>
> I recently posted different patch for same issue:
> http://marc.info/?l=linux-kernel&m=148153895827359&w=2

The change as below make me confuse.
+ /* The system wide setup does not work with threads. */
+ if (!evsel->system_wide)
+ return false;
It looks the meaning of the comments is inconsistent with the code.


Your original patch doesn't work well with the issue.
But if I change the above code as below, the issue is fixed.
if (evsel->system_wide)
return false;

Thanks,
Kan