[0/2] perf/core: deliver PERF_RECORD_COMM and PERF_RECORD_MMAP side-band events to all online cpus

Message ID 20230620155515.101222-1-yangjihong1@huawei.com
Headers
Series perf/core: deliver PERF_RECORD_COMM and PERF_RECORD_MMAP side-band events to all online cpus |

Message

Yang Jihong June 20, 2023, 3:55 p.m. UTC
  Tasks are migrated between cores due to scheduling.
If perf samples specified CPUs, PERF_RECORD_COMM and PERF_RECORD_MMAP
events need be deliver to all cores to avoids the problem that the comm
and symbols cannot be parsed due to task migration to the target core.

The specific scenarios are as follows:

         CPU0                                 CPU1
  perf record -C 0 start
                              taskA starts to be created and executed
                                -> PERF_RECORD_COMM and PERF_RECORD_MMAP
                                   events only deliver to CPU1
                              ......
                                |
                          migrate to CPU0
                                |
  Running on CPU0    <----------/
  ...

  perf record -C 0 stop

Now perf samples the PC of taskA. However, perf does not record the
PERF_RECORD_COMM and PERF_RECORD_COMM events of taskA.
Therefore, the comm and symbols of taskA cannot be parsed.

Yang Jihong (2):
  perf/core: perf_iterate_sb_cpu() supports to receive side-band events
    for all oneline cpus
  perf/core: deliver PERF_RECORD_COMM and PERF_RECORD_MMAP side-band
    events to all online cpus

 kernel/events/core.c | 58 +++++++++++++++++++++++++++++++-------------
 1 file changed, 41 insertions(+), 17 deletions(-)
  

Comments

Adrian Hunter June 20, 2023, 6:49 p.m. UTC | #1
On 20/06/23 18:55, Yang Jihong wrote:
> Tasks are migrated between cores due to scheduling.
> If perf samples specified CPUs, PERF_RECORD_COMM and PERF_RECORD_MMAP
> events need be deliver to all cores to avoids the problem that the comm
> and symbols cannot be parsed due to task migration to the target core.
> 
> The specific scenarios are as follows:
> 
>          CPU0                                 CPU1
>   perf record -C 0 start
>                               taskA starts to be created and executed
>                                 -> PERF_RECORD_COMM and PERF_RECORD_MMAP
>                                    events only deliver to CPU1
>                               ......
>                                 |
>                           migrate to CPU0
>                                 |
>   Running on CPU0    <----------/
>   ...
> 
>   perf record -C 0 stop
> 
> Now perf samples the PC of taskA. However, perf does not record the
> PERF_RECORD_COMM and PERF_RECORD_COMM events of taskA.
> Therefore, the comm and symbols of taskA cannot be parsed.

perf record deals with this for PERF_RECORD_TEXT_POKE, by opening
the corresponding "dummy" event on each CPU irrespective of whether
the main events are on selected CPUs.  Refer
evlist__add_dummy_on_all_cpus().

So this could be handled by perf record.

> 
> Yang Jihong (2):
>   perf/core: perf_iterate_sb_cpu() supports to receive side-band events
>     for all oneline cpus
>   perf/core: deliver PERF_RECORD_COMM and PERF_RECORD_MMAP side-band
>     events to all online cpus
> 
>  kernel/events/core.c | 58 +++++++++++++++++++++++++++++++-------------
>  1 file changed, 41 insertions(+), 17 deletions(-)
>
  
Yang Jihong June 23, 2023, 5:48 a.m. UTC | #2
Hello,

On 2023/6/21 2:49, Adrian Hunter wrote:
> On 20/06/23 18:55, Yang Jihong wrote:
>> Tasks are migrated between cores due to scheduling.
>> If perf samples specified CPUs, PERF_RECORD_COMM and PERF_RECORD_MMAP
>> events need be deliver to all cores to avoids the problem that the comm
>> and symbols cannot be parsed due to task migration to the target core.
>>
>> The specific scenarios are as follows:
>>
>>           CPU0                                 CPU1
>>    perf record -C 0 start
>>                                taskA starts to be created and executed
>>                                  -> PERF_RECORD_COMM and PERF_RECORD_MMAP
>>                                     events only deliver to CPU1
>>                                ......
>>                                  |
>>                            migrate to CPU0
>>                                  |
>>    Running on CPU0    <----------/
>>    ...
>>
>>    perf record -C 0 stop
>>
>> Now perf samples the PC of taskA. However, perf does not record the
>> PERF_RECORD_COMM and PERF_RECORD_COMM events of taskA.
>> Therefore, the comm and symbols of taskA cannot be parsed.
> 
> perf record deals with this for PERF_RECORD_TEXT_POKE, by opening
> the corresponding "dummy" event on each CPU irrespective of whether
> the main events are on selected CPUs.  Refer
> evlist__add_dummy_on_all_cpus().
> 
> So this could be handled by perf record.

Okay, I'll take a look at it and use this solution to deal with it.

Thanks,
Yang