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

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

Commit 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.

Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
---
 kernel/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 66dbca1ba577..a014b2063af1 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -8276,7 +8276,7 @@  static void perf_event_comm_event(struct perf_comm_event *comm_event)
 	perf_iterate_sb(perf_event_comm_output,
 			comm_event,
 			NULL,
-			false);
+			true);
 }
 
 void perf_event_comm(struct task_struct *task, bool exec)
@@ -8755,7 +8755,7 @@  static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
 	perf_iterate_sb(perf_event_mmap_output,
 			mmap_event,
 			NULL,
-			false);
+			true);
 
 	kfree(buf);
 }