lkml.org 
[lkml]   [2018]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH] perf/core: exposing type of context-switch-out event
Date
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

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
kernel/events/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 57898102847f..e3ca597f4e2b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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 */
\
 
 \ /
  Last update: 2018-03-01 16:41    [W:0.053 / U:0.356 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site