Re: [PATCH] perf/ftrace : Fix repetitious traces when specify a target task
From: chengjian (D)
Date: Tue Oct 10 2017 - 08:20:05 EST
On 2017/10/10 19:33, Peter Zijlstra wrote:
No, this _cannot_ be right. The whole point of the @task argument was to
deliver the event multiple times -- maybe not to the same event, but it
needs to be delivered multiple times in some cases. Therefore this is
broken.
But now you've got me looking at 75e8387685f6, which also looks
completely insane.
.
the demo is like this
```cpp
// bug_fork.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc,char** argv){
pid_t pid;
printf("parent pid = %d\n", getpid( ));
pid = fork( );
if(pid < 0)
{
perror("fork error");
exit(-1);
}
else if(pid == 0)// fork return 0 in child process
{
printf("child pid = %d\n", getpid( ));
exit(0);
}
else // return child pid in parent process
{
//sleep(1);
//count++;
}
return EXIT_SUCCESS;
}
```
the parent only wakeup_new child process once, but perf match a lot when
use per-cpu maped.
In my opition, perf stat use per-thread-map, it will match twice.
sudo perf stat -e sched:sched_wakeup_new ./bug_fork
parent pid = 86155
child pid = 86156
Performance counter stats for './bug_fork':
2 sched:sched_wakeup_new
0.001112926 seconds time elapsed
Does it meen a match for trace parent(86155), a match for trace child(86156)
and what cases should the events be delivered multiple times?
Thanks...