Skip to contentSkip to conversation

perf ftrace: Add support for --pid option

PATCH In review Namhyung Kim 3 participants 13 messages Feb 24, 2017 – Mar 7, 2017 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/4 perf ftrace: Add support for --pid option

The -p (--pid) option enables to trace existing process by its pid.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/Documentation/perf-ftrace.txt |  4 ++
 tools/perf/builtin-ftrace.c              | 91 ++++++++++++++++++++++----------
 2 files changed, 68 insertions(+), 27 deletions(-)
tools/perf/Documentation/perf-ftrace.txt +4 -0
index 2d96de6132a9..2d39397f3f30 100644
@@ -30,6 +30,10 @@ OPTIONS
 --verbose=::
         Verbosity level.
 
+-p::
+--pid=::
+	Trace on existing process id (comma separated list).
+
 
 SEE ALSO
 --------
tools/perf/builtin-ftrace.c +64 -27

187 lines not on this page · raw message

Signature · 1 line
2.11.1
author maintainer
#1 lore raw

PATCH 2/4 perf tools: Introduce cpu_map__snprint_mask()

The cpu_map__snprint_mask() is to generate string representation of cpumask bitmap. For cpu 0 to 11, it'll return "fff".

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/cpumap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/cpumap.h |  1 +
 2 files changed, 47 insertions(+)
tools/perf/util/cpumap.c +46 -0
index 8c7504939113..08540ab2a891 100644
@@ -673,3 +673,49 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 	pr_debug("cpumask list: %s\n", buf);
 	return ret;
 }
+
+static char hex_char(char val)
+{
+	if (0 <= val && val <= 9)
+		return val + '0';
+	if (10 <= val && val < 16)
+		return val - 10 + 'a';
+	return '?';
+}
+
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
+{
+	int i, cpu;
+	char *ptr = buf;
+	unsigned char *bitmap;
+	int last_cpu = cpu_map__cpu(map, map->nr - 1);
+
+	bitmap = zalloc((last_cpu + 7) / 8);
+	if (bitmap == NULL) {
+		buf[0] = '\0';
+		return 0;
+	}
+
+	for (i = 0; i < map->nr; i++) {
+		cpu = cpu_map__cpu(map, i);
+		bitmap[cpu / 8] |= 1 << (cpu % 8);
+	}
+
+	for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
+		unsigned char bits = bitmap[cpu / 8];
+
+		if (cpu % 8)
+			bits >>= 4;
+		else
+			bits &= 0xf;
+
+		*ptr++ = hex_char(bits);
+		if ((cpu % 32) == 0 && cpu > 0)
+			*ptr++ = ',';
+	}
+	*ptr = '\0';
+	free(bitmap);
+
+	buf[size - 1] = '\0';
+	return ptr - buf;
+}
tools/perf/util/cpumap.h +1 -0
index 1a0549af8f5c..4d231c6eac0c 100644
@@ -20,6 +20,7 @@ struct cpu_map *cpu_map__dummy_new(void);
 struct cpu_map *cpu_map__new_data(struct cpu_map_data *data);
 struct cpu_map *cpu_map__read(FILE *file);
 size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size);
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size);
 size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
 int cpu_map__get_socket_id(int cpu);
 int cpu_map__get_socket(struct cpu_map *map, int idx, void *data);
Signature · 1 line
2.11.1
#2 lore raw

Re: [PATCH 2/4] perf tools: Introduce cpu_map__snprint_mask()

Em Fri, Feb 24, 2017 at 10:12:49AM +0900, Namhyung Kim escreveu:

Quoted 16 lines

The cpu_map__snprint_mask() is to generate string representation of cpumask bitmap. For cpu 0 to 11, it'll return "fff".

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/cpumap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/cpumap.h |  1 +
 2 files changed, 47 insertions(+)
tools/perf/util/cpumap.c +0 -0
index 8c7504939113..08540ab2a891 100644

tools/perf/util/cpumap.c size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size) · line 677

Quoted 5 lines
tools/perf/util/cpumap.c +2 -0
@@ -673,3 +673,49 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 	pr_debug("cpumask list: %s\n", buf);
 	return ret;
 }
+
+static char hex_char(char val)

Why do you use 'char' above and...

Quoted 8 lines
tools/perf/util/cpumap.c +8 -0
+{
+	if (0 <= val && val <= 9)
+		return val + '0';
+	if (10 <= val && val < 16)
+		return val - 10 + 'a';
+	return '?';
+}
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)

<SNIP>

tools/perf/util/cpumap.c

Quoted 2 lines
tools/perf/util/cpumap.c +2 -0
+	for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
+		unsigned char bits = bitmap[cpu / 8];

'unsigned char' here?

Some compilers don't like it, for instance:

19 fedora:24-x-ARC-uClibc: FAIL

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:2: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)
^
cc1: all warnings being treated as errors

And:

10 debian:experimental-x-arm64: FAIL

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:8: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)

        ^~

Are you ok with the patch below?

tools/perf/util/cpumap.c +2 -2
index 6ab8699f0233..405f56ad5c24 100644
@@ -687,7 +687,7 @@ size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
 {
 	int i, cpu;
 	char *ptr = buf;
-	unsigned char *bitmap;
+	char *bitmap;
 	int last_cpu = cpu_map__cpu(map, map->nr - 1);
 
 	bitmap = zalloc((last_cpu + 7) / 8);
@@ -702,7 +702,7 @@ size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
 	}
 
 	for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
-		unsigned char bits = bitmap[cpu / 8];
+		char bits = bitmap[cpu / 8];
 
 		if (cpu % 8)
 			bits >>= 4;
Quoted 29 lines
tools/perf/util/cpumap.c +15 -0
+		if (cpu % 8)
+			bits >>= 4;
+		else
+			bits &= 0xf;
+
+		*ptr++ = hex_char(bits);
+		if ((cpu % 32) == 0 && cpu > 0)
+			*ptr++ = ',';
+	}
+	*ptr = '\0';
+	free(bitmap);
+
+	buf[size - 1] = '\0';
+	return ptr - buf;
+}
tools/perf/util/cpumap.h +1 -0
index 1a0549af8f5c..4d231c6eac0c 100644
@@ -20,6 +20,7 @@ struct cpu_map *cpu_map__dummy_new(void);
 struct cpu_map *cpu_map__new_data(struct cpu_map_data *data);
 struct cpu_map *cpu_map__read(FILE *file);
 size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size);
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size);
 size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
 int cpu_map__get_socket_id(int cpu);
 int cpu_map__get_socket(struct cpu_map *map, int idx, void *data);
Signature · 1 line
2.11.1
author maintainer
#3 lore raw

Re: [PATCH 2/4] perf tools: Introduce cpu_map__snprint_mask()

Hi Arnaldo,

Quoted 12 lines · Arnaldo Carvalho de Melo

Em Fri, Feb 24, 2017 at 10:12:49AM +0900, Namhyung Kim escreveu:

Quoted 11 lines

The cpu_map__snprint_mask() is to generate string representation of cpumask bitmap. For cpu 0 to 11, it'll return "fff".

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/cpumap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/cpumap.h |  1 +
 2 files changed, 47 insertions(+)
Quoted 12 lines

tools/perf/util/cpumap.c size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size) · line 677

Quoted 10 lines
tools/perf/util/cpumap.c +2 -0
index 8c7504939113..08540ab2a891 100644
@@ -673,3 +673,49 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 	pr_debug("cpumask list: %s\n", buf);
 	return ret;
 }
+
+static char hex_char(char val)

Why do you use 'char' above and...

My bad. The argument should be unsigned. The semantics is that it converts a bitmap value into a character (string).

Quoted 30 lines
Quoted 9 lines
tools/perf/util/cpumap.c +8 -0
+{
+	if (0 <= val && val <= 9)
+		return val + '0';
+	if (10 <= val && val < 16)
+		return val - 10 + 'a';
+	return '?';
+}
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)

<SNIP>

tools/perf/util/cpumap.c

Quoted 2 lines
tools/perf/util/cpumap.c +2 -0
+	for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
+		unsigned char bits = bitmap[cpu / 8];

'unsigned char' here?

Some compilers don't like it, for instance:

19 fedora:24-x-ARC-uClibc: FAIL

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:2: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)
^
cc1: all warnings being treated as errors

And:

10 debian:experimental-x-arm64: FAIL

Quoted 7 lines

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:8: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)

        ^~

Are you ok with the patch below?

I'd rather change hex_char() instead. How about this?

tools/perf/util/cpumap.c +3 -3
index 6ab8699f0233..061018b42393 100644
@@ -674,11 +674,11 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
        return ret;
 }
 
-static char hex_char(char val)
+static char hex_char(unsigned char val)
 {
-       if (0 <= val && val <= 9)
+       if (val < 10)
                return val + '0';
-       if (10 <= val && val < 16)
+       if (val < 16)
                return val - 10 + 'a';
        return '?';
 }
author maintainer
#4 lore raw

Re: [PATCH 2/4] perf tools: Introduce cpu_map__snprint_mask()

Hi Arnaldo,

Quoted 81 lines · Namhyung Kim

Hi Arnaldo,

Quoted 12 lines · Arnaldo Carvalho de Melo

Em Fri, Feb 24, 2017 at 10:12:49AM +0900, Namhyung Kim escreveu:

Quoted 11 lines

The cpu_map__snprint_mask() is to generate string representation of cpumask bitmap. For cpu 0 to 11, it'll return "fff".

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/util/cpumap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/cpumap.h |  1 +
 2 files changed, 47 insertions(+)
Quoted 12 lines

tools/perf/util/cpumap.c size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size) · line 677

Quoted 10 lines
tools/perf/util/cpumap.c +2 -0
index 8c7504939113..08540ab2a891 100644
@@ -673,3 +673,49 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
    pr_debug("cpumask list: %s\n", buf);
    return ret;
 }
+
+static char hex_char(char val)

Why do you use 'char' above and...

My bad. The argument should be unsigned. The semantics is that it converts a bitmap value into a character (string).

Quoted 30 lines
Quoted 9 lines
tools/perf/util/cpumap.c +8 -0
+{
+   if (0 <= val && val <= 9)
+           return val + '0';
+   if (10 <= val && val < 16)
+           return val - 10 + 'a';
+   return '?';
+}
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)

<SNIP>

tools/perf/util/cpumap.c

Quoted 2 lines
tools/perf/util/cpumap.c +2 -0
+   for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
+           unsigned char bits = bitmap[cpu / 8];

'unsigned char' here?

Some compilers don't like it, for instance:

19 fedora:24-x-ARC-uClibc: FAIL

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:2: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)
^
cc1: all warnings being treated as errors

And:

10 debian:experimental-x-arm64: FAIL

Quoted 7 lines

CC /tmp/build/perf/util/cpumap.o
util/cpumap.c: In function 'hex_char':
util/cpumap.c:679:8: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)

        ^~

Are you ok with the patch below?

I'd rather change hex_char() instead. How about this?

tools/perf/util/cpumap.c +0 -1
index 6ab8699f0233..061018b42393 100644
@@ -674,11 +674,11 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
        return ret;
 }
 
-static char hex_char(char val)

tools/perf/util/cpumap.c size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size) · line 684

Quoted 10 lines
tools/perf/util/cpumap.c +3 -2
+static char hex_char(unsigned char val)
 {
-       if (0 <= val && val <= 9)
+       if (val < 10)
                return val + '0';
-       if (10 <= val && val < 16)
+       if (val < 16)
                return val - 10 + 'a';
        return '?';
 }

Ping!

Thanks,
Namhyung

#5 lore raw

Re: [PATCH 2/4] perf tools: Introduce cpu_map__snprint_mask()

In reply to Namhyung Kim

Em Sat, Feb 25, 2017 at 01:27:34PM +0900, Namhyung Kim escreveu:

Quoted 8 lines · Arnaldo Carvalho de Melo
Quoted 5 lines

Em Fri, Feb 24, 2017 at 10:12:49AM +0900, Namhyung Kim escreveu:
util/cpumap.c:679:8: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (0 <= val && val <= 9)

        ^~

Are you ok with the patch below?

I'd rather change hex_char() instead. How about this?

Ok, applying by hand, somehow it didn't apply using git-am...

- Arnaldo

Quoted 16 lines

+++ b/tools/perf/util/cpumap.c

tools/perf/util/cpumap.c +3 -3
@@ -674,11 +674,11 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
        return ret;
 }
 
-static char hex_char(char val)
+static char hex_char(unsigned char val)
 {
-       if (0 <= val && val <= 9)
+       if (val < 10)
                return val + '0';
-       if (10 <= val && val < 16)
+       if (val < 16)
                return val - 10 + 'a';
        return '?';
 }
#6 lore raw

[tip:perf/core] perf cpumap: Introduce cpu_map__snprint_mask()

In reply to Namhyung Kim
perf cpumap: Introduce cpu_map__snprint_mask()
Commit-ID:  4400ac8a9a900318f8516dc0fb94075cb3fdb50d
Gitweb:     http://git.kernel.org/tip/4400ac8a9a900318f8516dc0fb94075cb3fdb50d
Author:     Namhyung Kim <[email protected]>
AuthorDate: Fri, 24 Feb 2017 10:12:49 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 3 Mar 2017 19:07:17 -0300

perf cpumap: Introduce cpu_map__snprint_mask()

The cpu_map__snprint_mask() generates a string representation of a cpumask bitmap. For cpu 0 to 11, it'll return "fff".

Committer notes:

Fix compiler warning on some toolchains:

    19 fedora:24-x-ARC-uClibc: FAIL

    CC       /tmp/build/perf/util/cpumap.o
  util/cpumap.c: In function 'hex_char':
  util/cpumap.c:679:2: error: comparison is always true due to limited range of data type [-Werror=type-limits]
    if (0 <= val && val <= 9)
    ^

cc1: all warnings being treated as errors

Applying patch from Namhyung that makes function receive an 'unsigned char', that is what the callers are passing to this function.

---
 tools/perf/util/cpumap.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 tools/perf/util/cpumap.h |  1 +
 2 files changed, 47 insertions(+)
tools/perf/util/cpumap.c +46 -0
index 39ad2ca..061018b 100644
@@ -673,3 +673,49 @@ size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size)
 	pr_debug("cpumask list: %s\n", buf);
 	return ret;
 }
+
+static char hex_char(unsigned char val)
+{
+	if (val < 10)
+		return val + '0';
+	if (val < 16)
+		return val - 10 + 'a';
+	return '?';
+}
+
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size)
+{
+	int i, cpu;
+	char *ptr = buf;
+	unsigned char *bitmap;
+	int last_cpu = cpu_map__cpu(map, map->nr - 1);
+
+	bitmap = zalloc((last_cpu + 7) / 8);
+	if (bitmap == NULL) {
+		buf[0] = '\0';
+		return 0;
+	}
+
+	for (i = 0; i < map->nr; i++) {
+		cpu = cpu_map__cpu(map, i);
+		bitmap[cpu / 8] |= 1 << (cpu % 8);
+	}
+
+	for (cpu = last_cpu / 4 * 4; cpu >= 0; cpu -= 4) {
+		unsigned char bits = bitmap[cpu / 8];
+
+		if (cpu % 8)
+			bits >>= 4;
+		else
+			bits &= 0xf;
+
+		*ptr++ = hex_char(bits);
+		if ((cpu % 32) == 0 && cpu > 0)
+			*ptr++ = ',';
+	}
+	*ptr = '\0';
+	free(bitmap);
+
+	buf[size - 1] = '\0';
+	return ptr - buf;
+}
tools/perf/util/cpumap.h +1 -0
index e844916..6b8bff8 100644
@@ -20,6 +20,7 @@ struct cpu_map *cpu_map__dummy_new(void);
 struct cpu_map *cpu_map__new_data(struct cpu_map_data *data);
 struct cpu_map *cpu_map__read(FILE *file);
 size_t cpu_map__snprint(struct cpu_map *map, char *buf, size_t size);
+size_t cpu_map__snprint_mask(struct cpu_map *map, char *buf, size_t size);
 size_t cpu_map__fprintf(struct cpu_map *map, FILE *fp);
 int cpu_map__get_socket_id(int cpu);
 int cpu_map__get_socket(struct cpu_map *map, int idx, void *data);
author maintainer
#7 lore raw

PATCH 3/4 perf ftrace: Add support for -a and -C option

In reply to Namhyung Kim

The -a/--all-cpus and -C/--cpu option is for controlling tracing cpus.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/Documentation/perf-ftrace.txt | 14 ++++++++
 tools/perf/builtin-ftrace.c              | 60 ++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
tools/perf/Documentation/perf-ftrace.txt +14 -0
index 2d39397f3f30..6e6a8b22c859 100644
@@ -34,6 +34,20 @@ OPTIONS
 --pid=::
 	Trace on existing process id (comma separated list).
 
+-a::
+--all-cpus::
+	Force system-wide collection.  Scripts run without a <command>
+	normally use -a by default, while scripts run with a <command>
+	normally don't - this option allows the latter to be run in
+	system-wide mode.
+
+-C::
+--cpu=::
+	Only trace for the list of CPUs provided.  Multiple CPUs can
+	be provided as a comma separated list with no space like: 0,1.
+	Ranges of CPUs are specified with -: 0-2.
+	Default is to trace on all online CPUs.
+
 
 SEE ALSO
 --------
tools/perf/builtin-ftrace.c +60 -0

96 lines not on this page · raw message

Signature · 1 line
2.11.1
#8 lore raw

[tip:perf/core] perf ftrace: Add support for -a and -C option

perf ftrace: Add support for -a and -C option
Commit-ID:  dc23103278c5ad53c177a25e209ef687e6d5d293
Gitweb:     http://git.kernel.org/tip/dc23103278c5ad53c177a25e209ef687e6d5d293
Author:     Namhyung Kim <[email protected]>
AuthorDate: Fri, 24 Feb 2017 10:12:50 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 3 Mar 2017 19:07:17 -0300

perf ftrace: Add support for -a and -C option

The -a/--all-cpus and -C/--cpu option is for controlling tracing cpus.

---
 tools/perf/Documentation/perf-ftrace.txt | 14 ++++++++
 tools/perf/builtin-ftrace.c              | 60 ++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
tools/perf/Documentation/perf-ftrace.txt +14 -0
index 2d39397..6e6a8b2 100644
@@ -34,6 +34,20 @@ OPTIONS
 --pid=::
 	Trace on existing process id (comma separated list).
 
+-a::
+--all-cpus::
+	Force system-wide collection.  Scripts run without a <command>
+	normally use -a by default, while scripts run with a <command>
+	normally don't - this option allows the latter to be run in
+	system-wide mode.
+
+-C::
+--cpu=::
+	Only trace for the list of CPUs provided.  Multiple CPUs can
+	be provided as a comma separated list with no space like: 0,1.
+	Ranges of CPUs are specified with -: 0-2.
+	Default is to trace on all online CPUs.
+
 
 SEE ALSO
 --------
tools/perf/builtin-ftrace.c +60 -0

96 lines not on this page · raw message

author maintainer
#9 lore raw

PATCH 4/4 perf ftrace: Use pager for displaying result

In reply to Namhyung Kim

It's convenient to use pager when seeing many lines of result.

Note that setup_pager() should be called after perf_evlist__ prepare_workload() since they can interfere each other regarding shared stdio streams.

Cc Steven Rostedt <[email protected]>
Cc Frederic Weisbecker <[email protected]>
---
 tools/perf/builtin-ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-ftrace.c +3 -0
index d5b566ed7178..6087295f8827 100644
@@ -195,6 +195,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 	signal(SIGINT, sig_handler);
 	signal(SIGUSR1, sig_handler);
 	signal(SIGCHLD, sig_handler);
+	signal(SIGPIPE, sig_handler);
 
 	if (reset_tracing_files(ftrace) < 0)
 		goto out;
@@ -247,6 +248,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 		goto out_close_fd;
 	}
 
+	setup_pager();
+
 	perf_evlist__start_workload(ftrace->evlist);
 
 	while (!done) {
Signature · 1 line
2.11.1
#10 lore raw

[tip:perf/core] perf ftrace: Use pager for displaying result

perf ftrace: Use pager for displaying result
Commit-ID:  583359646fde8526ea9456618cc24dc359b34094
Gitweb:     http://git.kernel.org/tip/583359646fde8526ea9456618cc24dc359b34094
Author:     Namhyung Kim <[email protected]>
AuthorDate: Fri, 24 Feb 2017 10:12:51 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 3 Mar 2017 19:07:17 -0300

perf ftrace: Use pager for displaying result

It's convenient to use the pager when seeing many lines of result.

Note that setup_pager() should be called after perf_evlist__prepare_workload() since they can interfere each other regarding shared stdio streams.

---
 tools/perf/builtin-ftrace.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-ftrace.c +3 -0
index d5b566e..6087295 100644
@@ -195,6 +195,7 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 	signal(SIGINT, sig_handler);
 	signal(SIGUSR1, sig_handler);
 	signal(SIGCHLD, sig_handler);
+	signal(SIGPIPE, sig_handler);
 
 	if (reset_tracing_files(ftrace) < 0)
 		goto out;
@@ -247,6 +248,8 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
 		goto out_close_fd;
 	}
 
+	setup_pager();
+
 	perf_evlist__start_workload(ftrace->evlist);
 
 	while (!done) {
#11 lore raw
In reply to Namhyung Kim

Em Fri, Feb 24, 2017 at 10:12:48AM +0900, Namhyung Kim escreveu:

Quoted 1 line

The -p (--pid) option enables to trace existing process by its pid.

Thanks, tested and applied the series, adding committer notes with examples to this one with --pid.

- Arnaldo

#12 lore raw
In reply to Namhyung Kim
perf ftrace: Add support for --pid option
Commit-ID:  a9af6be5bc25214f7870fef2b6d3490fe8b87bf7
Gitweb:     http://git.kernel.org/tip/a9af6be5bc25214f7870fef2b6d3490fe8b87bf7
Author:     Namhyung Kim <[email protected]>
AuthorDate: Fri, 24 Feb 2017 10:12:48 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 3 Mar 2017 19:07:16 -0300

perf ftrace: Add support for --pid option

The -p (--pid) option enables to trace existing process by its pid.

Committer notes:

Testing it:

Using the function_graph tracer on a process that is just waiting for user input and thus will make 'perf ftrace' sit there waiting for that, then press any key on that mutt session and see what happens:

  # perf ftrace -t function_graph -p `pidof mutt` | head -40
  2)   1.038 us    |  switch_mm_irqs_off();
  ------------------------------------------
  2)    <idle>-0    =>   mutt-3595
  ------------------------------------------
  2)               |              finish_task_switch() {
  2)               |                smp_irq_work_interrupt() {
  2)               |                  irq_enter() {
  2)   0.180 us    |                    rcu_irq_enter();
  2)   1.248 us    |                  }
  2)               |                  __wake_up() {
  2)   0.126 us    |                    _raw_spin_lock_irqsave();
  2)               |                    __wake_up_common() {
  2)               |                      pollwake() {
  2)               |                        default_wake_function() {
  2)               |                          try_to_wake_up() {
  2)   0.662 us    |                            _raw_spin_lock_irqsave();
  2)               |                            select_task_rq_fair() {
  2)   1.719 us    |                              effective_load.isra.41();
  2)   1.343 us    |                              effective_load.isra.41();
  2)               |                              select_idle_sibling() {
  2)   0.331 us    |                                idle_cpu();
  2)   1.458 us    |                              }
  2)   8.350 us    |                            }
  2)   0.200 us    |                            _raw_spin_lock();
  2)               |                            ttwu_do_activate() {
  2)               |                              activate_task() {
  2)   0.136 us    |                                update_rq_clock.part.77();
  2)               |                                enqueue_task_fair() {
  2)               |                                  enqueue_entity() {
  2)   0.146 us    |                                    update_curr();
  2)   0.330 us    |                                    account_entity_enqueue();
  2)   0.280 us    |                                    update_cfs_shares();
  2)   0.321 us    |                                    place_entity();
  2)   0.206 us    |                                    __enqueue_entity();
  2)   6.926 us    |                                  }
  2)               |                                  enqueue_entity() {
  2)   0.105 us    |                                    update_curr();
  2)   0.175 us    |                                    account_entity_enqueue();
  2)   0.531 us    |                                    update_cfs_shares();

#

---
 tools/perf/Documentation/perf-ftrace.txt |  4 ++
 tools/perf/builtin-ftrace.c              | 91 ++++++++++++++++++++++----------
 2 files changed, 68 insertions(+), 27 deletions(-)
tools/perf/Documentation/perf-ftrace.txt +4 -0
index 2d96de6..2d39397 100644
@@ -30,6 +30,10 @@ OPTIONS
 --verbose=::
         Verbosity level.
 
+-p::
+--pid=::
+	Trace on existing process id (comma separated list).
+
 
 SEE ALSO
 --------
tools/perf/builtin-ftrace.c +64 -27

187 lines not on this page · raw message