linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] perf/core: expose thread context switch out event type to user space
@ 2018-03-20 12:33 Alexey Budankov
  2018-03-20 13:04 ` [PATCH v1 1/3] perf/core: store context switch out type into Perf trace Alexey Budankov
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-20 12:33 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel


Implementation of exposing context-switch-out type event as a part 
of PERF_RECORD_SWITCH[_CPU_WIDE] record.

Introduced types of events assumed to be:
a) preempt: when task->state == TASK_RUNNING
b) yield: !preempt, encoding is done using new bit 
   PERF_RECORD_MISC_SWITCH_OUT_YIELD like this:
   
   event_header->misc &= 
	PERF_RECORD_MISC_SWITCH_OUT|PERF_RECORD_MISC_SWITCH_OUT_YIELD

Perf tool report and script commands output has been extended to decode 
new yield bit and the updated output looks like in the examples below.

The documentation has been updated to mention yield switch out events 
and its decoding symbols in perf script output.

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

perf report -D -i system-wide.perf: 

0x2646c0 [0x30]: event: 15
.
. ... raw event: size 48 bytes
.  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
.  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
.  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............

7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0

perf script --show-switch-events -F +misc -I -i system-wide.perf:

amplxe-perf  7680 [007] Sy    15663.273156: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0    
migration/5    39 [005] K     15663.273157:

---
 Alexey Budankov (3):
	perf/core: store context switch out type into Perf trace
	perf report: extend raw dump (-D) out with switch out event type
	perf script: extend misc field decoding with switch out event type
  
 include/uapi/linux/perf_event.h          |  5 +++++
 kernel/events/core.c                     |  4 +++-
 tools/include/uapi/linux/perf_event.h    |  5 +++++
 tools/perf/Documentation/perf-script.txt | 17 +++++++++--------
 tools/perf/builtin-script.c              |  5 ++++-
 tools/perf/util/event.c                  |  4 +++-
 6 files changed, 29 insertions(+), 11 deletions(-)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 1/3] perf/core: store context switch out type into Perf trace
  2018-03-20 12:33 [PATCH v1 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
@ 2018-03-20 13:04 ` Alexey Budankov
  2018-03-20 13:05 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov
  2018-03-20 13:06 ` [PATCH v1 3/3] perf script: extend misc field deconding " Alexey Budankov
  2 siblings, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-20 13:04 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel

Store thread context-switch-out event type into Perf trace as a part of 
PERF_RECORD_SWITCH[_CPU_WIDE] records.

Introduced types of switch-out events assumed to be 
a) preempt: task->state == TASK_RUNNING and b) yield: !preempt;

New yield event type is encoded using special 
PERF_RECORD_MISC_SWITCH_OUT_YIELD bit extending PERF_RECORD_MISC_SWITCH_OUT 
meaning traditional preemption switch out event:

    misc &= PERF_RECORD_MISC_SWITCH_OUT | PERF_RECORD_MISC_SWITCH_OUT_YIELD
	
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
 include/uapi/linux/perf_event.h       | 5 +++++
 kernel/events/core.c                  | 4 +++-
 tools/include/uapi/linux/perf_event.h | 5 +++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index 6f873503552d..0339c829cda5 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -654,6 +654,11 @@ struct perf_event_mmap_page {
  * perf_event_attr::precise_ip.
  */
 #define PERF_RECORD_MISC_EXACT_IP		(1 << 14)
+/*
+ * Indicates that thread explicitly yielded cpu due to
+ * a call of some synchronization API e.g. futex system call
+ */
+#define PERF_RECORD_MISC_SWITCH_OUT_YIELD	(1 << 14)
 /*
  * Reserve the last bit to indicate some extended misc field
  */
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 57898102847f..1faa6dde090c 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_SWITCH_OUT_YIELD);
 
 	/* 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 */
diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 6f873503552d..0339c829cda5 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -654,6 +654,11 @@ struct perf_event_mmap_page {
  * perf_event_attr::precise_ip.
  */
 #define PERF_RECORD_MISC_EXACT_IP		(1 << 14)
+/*
+ * Indicates that thread explicitly yielded cpu due to
+ * a call of some synchronization API e.g. futex system call
+ */
+#define PERF_RECORD_MISC_SWITCH_OUT_YIELD	(1 << 14)
 /*
  * Reserve the last bit to indicate some extended misc field
  */

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-20 12:33 [PATCH v1 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
  2018-03-20 13:04 ` [PATCH v1 1/3] perf/core: store context switch out type into Perf trace Alexey Budankov
@ 2018-03-20 13:05 ` Alexey Budankov
  2018-03-21 16:41   ` Jiri Olsa
  2018-03-20 13:06 ` [PATCH v1 3/3] perf script: extend misc field deconding " Alexey Budankov
  2 siblings, 1 reply; 9+ messages in thread
From: Alexey Budankov @ 2018-03-20 13:05 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel

Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
designating synchronization context switch out event:

perf report -D -i system-wide.perf: 

0x1b9c50 [0x30]: event: 15
.
. ... raw event: size 48 bytes
.  0000:  0f 00 00 00 00 20 30 00 01 1e 00 00 01 1e 00 00  ..... 0.........
.  0010:  00 00 00 00 00 00 00 00 85 ae d4 e3 3e 0e 00 00  ............>...
.  0020:  54 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  T...............

5 15663273127557 0x1b9c50 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:  7681/7681 

0x2646c0 [0x30]: event: 15
.
. ... raw event: size 48 bytes
.  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
.  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
.  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............

7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0

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

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index f0a6cbd033cc..af5a85d56446 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
 size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
 {
 	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
-	const char *in_out = out ? "OUT" : "IN ";
+	const char *in_out = !out ? "IN " :
+		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
+				"OUT" : "OUT yield";
 
 	if (event->header.type == PERF_RECORD_SWITCH)
 		return fprintf(fp, " %s\n", in_out);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 3/3] perf script: extend misc field deconding with switch out event type
  2018-03-20 12:33 [PATCH v1 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
  2018-03-20 13:04 ` [PATCH v1 1/3] perf/core: store context switch out type into Perf trace Alexey Budankov
  2018-03-20 13:05 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov
@ 2018-03-20 13:06 ` Alexey Budankov
  2 siblings, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-20 13:06 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen, linux-kernel

Append 'y' sign to 'S' tag designating the type of context switch out event so 
'S' means preemption context switch and 'Sy' means synchronization context 
switch. Documentation is extended to cover new presentation changes.

perf script --show-switch-events -F +misc -I -i system-wide.perf:

amplxe-perf  7681 [005] S     15663.273151: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:    39/39   
migration/5    39 [005]       15663.273152: PERF_RECORD_SWITCH_CPU_WIDE IN   prev pid/tid:  7681/7681 
amplxe-perf  7680 [007] K     15663.273153:          1                                                                                                                                       context-switch: 
                  aaa488 schedule ([kernel.kallsyms])
                  1a9f50 __poll_nocancel (inlined)

amplxe-perf  7680 [007] Sy    15663.273156: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0    
migration/5    39 [005] K     15663.273157:

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
 tools/perf/Documentation/perf-script.txt | 17 +++++++++--------
 tools/perf/builtin-script.c              |  5 ++++-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/tools/perf/Documentation/perf-script.txt b/tools/perf/Documentation/perf-script.txt
index 36ec0257f8d3..80e94cbbf520 100644
--- a/tools/perf/Documentation/perf-script.txt
+++ b/tools/perf/Documentation/perf-script.txt
@@ -228,14 +228,15 @@ OPTIONS
 	For sample events it's possible to display misc field with -F +misc option,
 	following letters are displayed for each bit:
 
-	  PERF_RECORD_MISC_KERNEL        K
-	  PERF_RECORD_MISC_USER          U
-	  PERF_RECORD_MISC_HYPERVISOR    H
-	  PERF_RECORD_MISC_GUEST_KERNEL  G
-	  PERF_RECORD_MISC_GUEST_USER    g
-	  PERF_RECORD_MISC_MMAP_DATA*    M
-	  PERF_RECORD_MISC_COMM_EXEC     E
-	  PERF_RECORD_MISC_SWITCH_OUT    S
+	  PERF_RECORD_MISC_KERNEL               K
+	  PERF_RECORD_MISC_USER                 U
+	  PERF_RECORD_MISC_HYPERVISOR           H
+	  PERF_RECORD_MISC_GUEST_KERNEL         G
+	  PERF_RECORD_MISC_GUEST_USER           g
+	  PERF_RECORD_MISC_MMAP_DATA*           M
+	  PERF_RECORD_MISC_COMM_EXEC            E
+	  PERF_RECORD_MISC_SWITCH_OUT           S
+	  PERF_RECORD_MISC_SWITCH_OUT_YIELD     Sy
 
 	  $ perf script -F +misc ...
 	   sched-messaging  1414 K     28690.636582:       4590 cycles ...
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index cce926aeb0c0..06d7fe73886f 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -657,8 +657,11 @@ static int perf_sample__fprintf_start(struct perf_sample *sample,
 			break;
 		case PERF_RECORD_SWITCH:
 		case PERF_RECORD_SWITCH_CPU_WIDE:
-			if (has(SWITCH_OUT))
+			if (has(SWITCH_OUT)) {
 				ret += fprintf(fp, "S");
+				if (sample->misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD)
+					ret += fprintf(fp, "y");
+			}
 		default:
 			break;
 		}

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-20 13:05 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov
@ 2018-03-21 16:41   ` Jiri Olsa
  2018-03-21 17:12     ` Alexey Budankov
  2018-03-22 16:17     ` Alexey Budankov
  0 siblings, 2 replies; 9+ messages in thread
From: Jiri Olsa @ 2018-03-21 16:41 UTC (permalink / raw)
  To: Alexey Budankov
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel

On Tue, Mar 20, 2018 at 04:05:17PM +0300, Alexey Budankov wrote:
> Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
> event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
> designating synchronization context switch out event:
> 
> perf report -D -i system-wide.perf: 
> 
> 0x1b9c50 [0x30]: event: 15
> .
> . ... raw event: size 48 bytes
> .  0000:  0f 00 00 00 00 20 30 00 01 1e 00 00 01 1e 00 00  ..... 0.........
> .  0010:  00 00 00 00 00 00 00 00 85 ae d4 e3 3e 0e 00 00  ............>...
> .  0020:  54 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  T...............
> 
> 5 15663273127557 0x1b9c50 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:  7681/7681 
> 
> 0x2646c0 [0x30]: event: 15
> .
> . ... raw event: size 48 bytes
> .  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
> .  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
> .  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............
> 
> 7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
> 
> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
> ---
>  tools/perf/util/event.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
> index f0a6cbd033cc..af5a85d56446 100644
> --- a/tools/perf/util/event.c
> +++ b/tools/perf/util/event.c
> @@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
>  size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
>  {
>  	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
> -	const char *in_out = out ? "OUT" : "IN ";
> +	const char *in_out = !out ? "IN " :
> +		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
> +				"OUT" : "OUT yield";

I'm getting:

       rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
         swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN   prev pid/tid:     9/9

could you plase format the 'OUT yield' line so the rest of the
fields are in line with 'IN' and 'OUT' lines like:

       rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
         swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN         prev pid/tid:     9/9

thanks,
jirka

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-21 16:41   ` Jiri Olsa
@ 2018-03-21 17:12     ` Alexey Budankov
  2018-03-22 16:17     ` Alexey Budankov
  1 sibling, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-21 17:12 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel

On 21.03.2018 19:41, Jiri Olsa wrote:
> On Tue, Mar 20, 2018 at 04:05:17PM +0300, Alexey Budankov wrote:
>> Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
>> event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
>> designating synchronization context switch out event:
>>
>> perf report -D -i system-wide.perf: 
>>
>> 0x1b9c50 [0x30]: event: 15
>> .
>> . ... raw event: size 48 bytes
>> .  0000:  0f 00 00 00 00 20 30 00 01 1e 00 00 01 1e 00 00  ..... 0.........
>> .  0010:  00 00 00 00 00 00 00 00 85 ae d4 e3 3e 0e 00 00  ............>...
>> .  0020:  54 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  T...............
>>
>> 5 15663273127557 0x1b9c50 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:  7681/7681 
>>
>> 0x2646c0 [0x30]: event: 15
>> .
>> . ... raw event: size 48 bytes
>> .  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
>> .  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
>> .  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............
>>
>> 7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>>
>> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
>> ---
>>  tools/perf/util/event.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
>> index f0a6cbd033cc..af5a85d56446 100644
>> --- a/tools/perf/util/event.c
>> +++ b/tools/perf/util/event.c
>> @@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
>>  size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
>>  {
>>  	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
>> -	const char *in_out = out ? "OUT" : "IN ";
>> +	const char *in_out = !out ? "IN " :
>> +		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
>> +				"OUT" : "OUT yield";
> 
> I'm getting:
> 
>        rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>          swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN   prev pid/tid:     9/9
> 
> could you plase format the 'OUT yield' line so the rest of the
> fields are in line with 'IN' and 'OUT' lines like:
> 
>        rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>          swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN         prev pid/tid:     9/9

Yes, let me take care of that.

Thanks,
Alexey

> 
> thanks,
> jirka
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-21 16:41   ` Jiri Olsa
  2018-03-21 17:12     ` Alexey Budankov
@ 2018-03-22 16:17     ` Alexey Budankov
  1 sibling, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-22 16:17 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Alexander Shishkin, Namhyung Kim, Andi Kleen, linux-kernel

On 21.03.2018 19:41, Jiri Olsa wrote:
> On Tue, Mar 20, 2018 at 04:05:17PM +0300, Alexey Budankov wrote:
>> Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
>> event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
>> designating synchronization context switch out event:
>>
>> perf report -D -i system-wide.perf: 
>>
>> 0x1b9c50 [0x30]: event: 15
>> .
>> . ... raw event: size 48 bytes
>> .  0000:  0f 00 00 00 00 20 30 00 01 1e 00 00 01 1e 00 00  ..... 0.........
>> .  0010:  00 00 00 00 00 00 00 00 85 ae d4 e3 3e 0e 00 00  ............>...
>> .  0020:  54 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  T...............
>>
>> 5 15663273127557 0x1b9c50 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:  7681/7681 
>>
>> 0x2646c0 [0x30]: event: 15
>> .
>> . ... raw event: size 48 bytes
>> .  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
>> .  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
>> .  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............
>>
>> 7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>>
>> Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
>> ---
>>  tools/perf/util/event.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
>> index f0a6cbd033cc..af5a85d56446 100644
>> --- a/tools/perf/util/event.c
>> +++ b/tools/perf/util/event.c
>> @@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
>>  size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
>>  {
>>  	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
>> -	const char *in_out = out ? "OUT" : "IN ";
>> +	const char *in_out = !out ? "IN " :
>> +		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
>> +				"OUT" : "OUT yield";
> 
> I'm getting:
> 
>        rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>          swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN   prev pid/tid:     9/9
> 
> could you plase format the 'OUT yield' line so the rest of the
> fields are in line with 'IN' and 'OUT' lines like:
> 
>        rcu_sched     9 [004] Sy     1303.392349: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0
>          swapper     0 [004]        1303.392350: PERF_RECORD_SWITCH_CPU_WIDE IN         prev pid/tid:     9/9

Please find update in v2.

Thanks,
Alexey

> 
> thanks,
> jirka
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-22 16:08 [PATCH v2 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
@ 2018-03-22 16:13 ` Alexey Budankov
  0 siblings, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-22 16:13 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, linux-kernel, Andi Kleen


Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
designating synchronization context switch out event:

perf report -D -i system-wide.perf | grep _SWITCH: 

1 113807080924003 0x26db26 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE OUT        next pid/tid: 20495/20495
1 113807080925644 0x26db4e [0x28]: PERF_RECORD_SWITCH_CPU_WIDE IN         prev pid/tid: 31479/31479
1 113807080937266 0x26db76 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:    16/16   
1 113807080938445 0x26db9e [0x28]: PERF_RECORD_SWITCH_CPU_WIDE IN         prev pid/tid: 20495/20495
1 113807080945455 0x26dbc6 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid: 20495/20495

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

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index f0a6cbd033cc..324f44f02e66 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
 size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
 {
 	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
-	const char *in_out = out ? "OUT" : "IN ";
+	const char *in_out = !out ? "IN       " :
+		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
+				"OUT      " : "OUT yield";
 
 	if (event->header.type == PERF_RECORD_SWITCH)
 		return fprintf(fp, " %s\n", in_out);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type
  2018-03-05 11:35 [PATCH v1 0/3] perf: expose thread context switch out event type to user space Alexey Budankov
@ 2018-03-05 11:38 ` Alexey Budankov
  0 siblings, 0 replies; 9+ messages in thread
From: Alexey Budankov @ 2018-03-05 11:38 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo
  Cc: Alexander Shishkin, Jiri Olsa, Namhyung Kim, Andi Kleen,
	linux-kernel, Dmitri Prokhorov


Print additional 'yield' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_YIELD bit set 
designating synchronization context switch out event:

perf report -D -i system-wide.perf: 

...

0x1b9c50 [0x30]: event: 15
.
. ... raw event: size 48 bytes
.  0000:  0f 00 00 00 00 20 30 00 01 1e 00 00 01 1e 00 00  ..... 0.........
.  0010:  00 00 00 00 00 00 00 00 85 ae d4 e3 3e 0e 00 00  ............>...
.  0020:  54 00 00 00 00 00 00 00 05 00 00 00 00 00 00 00  T...............

5 15663273127557 0x1b9c50 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT  next pid/tid:  7681/7681 

0x2646c0 [0x30]: event: 15
.
. ... raw event: size 48 bytes
.  0000:  0f 00 00 00 00 60 30 00 00 00 00 00 00 00 00 00  .....`0.........
.  0010:  00 1e 00 00 00 1e 00 00 29 1e d5 e3 3e 0e 00 00  ........)...>...
.  0020:  56 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00  V...............

7 15663273156137 0x2646c0 [0x30]: PERF_RECORD_SWITCH_CPU_WIDE OUT yield  next pid/tid:     0/0

...


Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
---
 tools/include/uapi/linux/perf_event.h | 5 +++++
 tools/perf/util/event.c               | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index 6f873503552d..0339c829cda5 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -654,6 +654,11 @@ struct perf_event_mmap_page {
  * perf_event_attr::precise_ip.
  */
 #define PERF_RECORD_MISC_EXACT_IP		(1 << 14)
+/*
+ * Indicates that thread explicitly yielded cpu due to
+ * a call of some synchronization API e.g. futex system call
+ */
+#define PERF_RECORD_MISC_SWITCH_OUT_YIELD	(1 << 14)
 /*
  * Reserve the last bit to indicate some extended misc field
  */
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index f0a6cbd033cc..af5a85d56446 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -1421,7 +1421,9 @@ size_t perf_event__fprintf_itrace_start(union perf_event *event, FILE *fp)
 size_t perf_event__fprintf_switch(union perf_event *event, FILE *fp)
 {
 	bool out = event->header.misc & PERF_RECORD_MISC_SWITCH_OUT;
-	const char *in_out = out ? "OUT" : "IN ";
+	const char *in_out = !out ? "IN " :
+		!(event->header.misc & PERF_RECORD_MISC_SWITCH_OUT_YIELD) ?
+				"OUT" : "OUT yield";
 
 	if (event->header.type == PERF_RECORD_SWITCH)
 		return fprintf(fp, " %s\n", in_out);

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-03-22 16:17 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-20 12:33 [PATCH v1 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
2018-03-20 13:04 ` [PATCH v1 1/3] perf/core: store context switch out type into Perf trace Alexey Budankov
2018-03-20 13:05 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov
2018-03-21 16:41   ` Jiri Olsa
2018-03-21 17:12     ` Alexey Budankov
2018-03-22 16:17     ` Alexey Budankov
2018-03-20 13:06 ` [PATCH v1 3/3] perf script: extend misc field deconding " Alexey Budankov
  -- strict thread matches above, loose matches on Subject: below --
2018-03-22 16:08 [PATCH v2 0/3] perf/core: expose thread context switch out event type to user space Alexey Budankov
2018-03-22 16:13 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov
2018-03-05 11:35 [PATCH v1 0/3] perf: expose thread context switch out event type to user space Alexey Budankov
2018-03-05 11:38 ` [PATCH v1 2/3] perf report: extend raw dump (-D) out with switch out event type Alexey Budankov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).