perf/core: exposing type of context-switch-out event
RFC PATCH 1/1 perf/core: exposing type of context-switch-out event
Hi,
This patch prototypes exposing the type of context-switch-out event using PERF_RECORD_MISC_EXT_RESERVED bit for PERF_RECORD_SWITCH[_CPU_WIDE] records.
Types of context-switch-out events introduced by the patch meant to be
a) preempted (task->state == TASK_RUNNING) or b) yielded == !preempted;
The changes have been manually tested on Fedora 27 with the patched kernel:git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
--- kernel/events/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/events/core.c +3 -1
@@ -7216,6 +7216,8 @@ static void perf_event_switch(struct task_struct *task, struct task_struct *next_prev, bool sched_in) {struct perf_switch_event switch_event; +__u16 switch_type = sched_in ?0 :PERF_RECORD_MISC_SWITCH_OUT | + (task->state ==TASK_RUNNING ?0 :PERF_RECORD_MISC_EXT_RESERVED );/* N.B. caller checks nr_switch_events != 0 */
@@ -7225,7 +7227,7 @@ static void perf_event_switch(struct task_struct *task, .event_id = { .header = {/* .type */ - .misc = sched_in ? 0 : PERF_RECORD_MISC_SWITCH_OUT, + .misc = switch_type, /* .size */ },/* .next_prev_pid */
Quoted 4 lines · Alexey Budankov
Hi,
This patch prototypes exposing the type of context-switch-out event using
PERF_RECORD_MISC_EXT_RESERVEDbit for PERF_RECORD_SWITCH[_CPU_WIDE] records.
It would be better to define an actually named bit in perf_event.h. It can be the same value.
Also we would need a patch for perf script / perf report -D to print this information.
The rest looks good to me.
-Andi
Quoted 6 lines · On Donnerstag, 1. März 2018 19:08:05 CET Andi Kleen wrote:
Quoted 5 lines · Alexey Budankov
Hi,
This patch prototypes exposing the type of context-switch-out event using
PERF_RECORD_MISC_EXT_RESERVEDbit for PERF_RECORD_SWITCH[_CPU_WIDE] records.
Quoted 7 lines
It would be better to define an actually named bit in
perf_event.h. It can be the same value.Also we would need a patch for perf script / perf report -D to print this information.
The rest looks good to me.
Please also add documentation Documentation/perf.data-file-format.txt, but I just noticed that not even PERF_RECORD_SWITCH is documented there...
Otherwise I also think that this would be a very nice feature addition!
Signature · 4 lines
Milian Wolff | [email protected] | Senior Software Engineer KDAB (Deutschland) GmbH, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt, C++ and OpenGL Experts
Quoted 2 lines
Please also add documentation
Documentation/perf.data-file-format.txt, but I just noticed that not evenPERF_RECORD_SWITCHis documented there...
That file only covers fields not generated by the kernel, but this is coming from the kernel.
Kernel records are documented in the manpage, but Vince usually updates that on his own.
-Andi
Quoted 8 lines · On Donnerstag, 1. März 2018 20:36:59 CET Andi Kleen wrote:
Quoted 2 lines
Please also add documentation
Documentation/perf.data-file-format.txt, but I just noticed that not evenPERF_RECORD_SWITCHis documented there...That file only covers fields not generated by the kernel, but this is coming from the kernel.
Kernel records are documented in the manpage, but Vince usually updates that on his own.
Ah, TIL - thanks for that tip! But I still think it would be good to have a complete documentation of the perf.data file format in one place. I guess patches would be welcome to add more aspects of the file format there, even if it's generated by the kernel? That helps for thirdparty tools that parse the perf.data files (like perfparser used by QtCreator and hotspot).
Cheers
Signature · 4 lines
Milian Wolff | [email protected] | Senior Software Engineer KDAB (Deutschland) GmbH, a KDAB Group company Tel: +49-30-521325470 KDAB - The Qt, C++ and OpenGL Experts