Skip to contentSkip to conversation

perf/core improvements and fixes

GIT PULL New Arnaldo Carvalho de Melo 2 participants 8 messages Aug 31, 2015 – Sep 1, 2015

Subsystems (3)
lore
Share & tools
lore

Arnaldo Carvalho de Melo

author maintainer
#0 lore raw

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit bac2e4a96d1c0bcce5e9654dcc902f75576b9b03:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-08-31 10:25:46 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to bcc84ec65ad1bd9f777a1fade6f8e5e0c5808fa5:

perf record: Add ability to name registers to record (2015-08-31 18:01:33 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Add ability to specify to select which registers to record, to reduce the size of perf.data files, and also allow printing the registers in 'perf script': (Stephane Eranian)

    # perf record --intr-regs=AX,SP usleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.016 MB perf.data (8 samples) ]
    # perf script -F ip,sym,iregs | tail -5
     ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
     ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
     ffffffff81761ac0 _raw_spin_lock   AX:0xffff8801bfcf8020    SP:0xffff8802629c3ce8
     ffffffff81202bf8 __vma_adjust_trans_huge   AX:0x7ffc75200000    SP:0xffff8802629c3b30
     ffffffff8122b089 dput   AX:0x101    SP:0xffff8802629c3c78
    #

Infrastructure:

- Open event on evsel cpus and threads (Kan Liang)

- New bpf API to get name from a BPF object (Wang Nan)

Build fixes:

- Fix build on powerpc broken by pt/bts (Adrian Hunter)

----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix build on powerpc broken by pt/bts

Kan Liang (1):
perf evlist: Open event on evsel cpus and threads

Stephane Eranian (3):
perf script: Enable printing of interrupted machine state perf/x86: Add list of register names
perf record: Add ability to name registers to record

Wang Nan (1):
bpf tools: New API to get name from a BPF object

 tools/lib/bpf/libbpf.c                             | 25 +++++++-
 tools/lib/bpf/libbpf.h                             |  4 +-
 tools/perf/Documentation/perf-record.txt           |  6 +-
 tools/perf/Documentation/perf-script.txt           |  2 +-
 tools/perf/arch/x86/util/Build                     |  1 +
 tools/perf/arch/x86/util/perf_regs.c               | 30 +++++++++
 tools/perf/builtin-record.c                        |  9 ++-
 tools/perf/builtin-script.c                        | 31 +++++++++-
 tools/perf/perf.h                                  |  2 +-
 tools/perf/tests/llvm.c                            |  2 +-
 tools/perf/util/Build                              |  2 +
 tools/perf/util/evlist.c                           |  4 ++
 tools/perf/util/evsel.c                            |  2 +-
 .../util/intel-pt-decoder/intel-pt-insn-decoder.c  |  3 +
 tools/perf/util/parse-regs-options.c               | 71 ++++++++++++++++++++++
 tools/perf/util/parse-regs-options.h               |  5 ++
 tools/perf/util/perf_regs.h                        |  7 +++
 17 files changed, 193 insertions(+), 13 deletions(-)
 create mode 100644 tools/perf/arch/x86/util/perf_regs.c
 create mode 100644 tools/perf/util/parse-regs-options.c
 create mode 100644 tools/perf/util/parse-regs-options.h
author maintainer
#1 lore raw

PATCH 1/6 perf tools: Fix build on powerpc broken by pt/bts

From: Adrian Hunter <[email protected]>

It is theoretically possible to process perf.data files created on x86 and that contain Intel PT or Intel BTS data, on any other architecture, which is why it is possible for there to be build errors on powerpc caused by pt/bts.

The errors were:

util/intel-pt-decoder/intel-pt-insn-decoder.c: In function ‘intel_pt_insn_decoder’:
util/intel-pt-decoder/intel-pt-insn-decoder.c:138:3: error: switch missing default case [-Werror=switch-default]
switch (insn->immediate.nbytes) {
^
cc1: all warnings being treated as errors

linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_synth_branch_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:871: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function intel_pt_sample':
sources/linux-acme.git/tools/perf/util/intel-pt.c:915: undefined reference to tsc_to_perf_time' sources/linux-acme.git/tools/perf/util/intel-pt.c:962: undefined reference to tsc_to_perf_time' linux-acme.git/tools/perf/perf-obj/libperf.a(libperf-in.o): In function `intel_pt_process_event':
sources/linux-acme.git/tools/perf/util/intel-pt.c:1454: undefined reference to `perf_time_to_tsc'

---
 tools/perf/util/Build                                    | 1 +
 tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c | 3 +++
 2 files changed, 4 insertions(+)
tools/perf/util/Build +1 -0
index e912856cc4e5..e79e4522368a 100644
@@ -75,6 +75,7 @@ libperf-y += record.o
 libperf-y += srcline.o
 libperf-y += data.o
 libperf-$(CONFIG_X86) += tsc.o
+libperf-$(CONFIG_AUXTRACE) += tsc.o
 libperf-y += cloexec.o
 libperf-y += thread-stack.o
 libperf-$(CONFIG_AUXTRACE) += auxtrace.o
tools/perf/util/intel-pt-decoder/intel-pt-insn-decoder.c +3 -0
index 9e4eb8fcd559..d23138c06665 100644
@@ -146,6 +146,9 @@ static void intel_pt_insn_decoder(struct insn *insn,
 		case 4:
 			intel_pt_insn->rel = bswap_32(insn->immediate.value);
 			break;
+		default:
+			intel_pt_insn->rel = 0;
+			break;
 		}
 #else
 		intel_pt_insn->rel = insn->immediate.value;
Signature · 1 line
2.1.0
author maintainer
#2 lore raw

PATCH 2/6 bpf tools: New API to get name from a BPF object

In reply to Arnaldo Carvalho de Melo

From: Wang Nan <[email protected]>

Before this patch there's no way to connect a loaded bpf object to its source file. However, during applying perf's '--filter' to BPF object, without this connection makes things harder, because perf loads all programs together, but '--filter' setting is for each object.

The API of bpf_object__open_buffer() is changed to allow passing a name. Fortunately, at this time there's only one user of it (perf test LLVM), so we change it together.

Cc Alexei Starovoitov <[email protected]>
Cc Brendan Gregg <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David Ahern <[email protected]>
Cc He Kuang <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Kaixu Xia <[email protected]>
Cc Masami Hiramatsu <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Zefan Li <[email protected]>
---
 tools/lib/bpf/libbpf.c  | 25 ++++++++++++++++++++++---
 tools/lib/bpf/libbpf.h  |  4 +++-
 tools/perf/tests/llvm.c |  2 +-
 3 files changed, 26 insertions(+), 5 deletions(-)
tools/lib/bpf/libbpf.c +22 -3
index 4fa4bc4505f5..4252fc22f78f 100644
@@ -880,15 +880,26 @@ struct bpf_object *bpf_object__open(const char *path)
 }
 
 struct bpf_object *bpf_object__open_buffer(void *obj_buf,
-					   size_t obj_buf_sz)
+					   size_t obj_buf_sz,
+					   const char *name)
 {
+	char tmp_name[64];
+
 	/* param validation */
 	if (!obj_buf || obj_buf_sz <= 0)
 		return NULL;
 
-	pr_debug("loading object from buffer\n");
+	if (!name) {
+		snprintf(tmp_name, sizeof(tmp_name), "%lx-%lx",
+			 (unsigned long)obj_buf,
+			 (unsigned long)obj_buf_sz);
+		tmp_name[sizeof(tmp_name) - 1] = '\0';
+		name = tmp_name;
+	}
+	pr_debug("loading object '%s' from buffer\n",
+		 name);
 
-	return __bpf_object__open("[buffer]", obj_buf, obj_buf_sz);
+	return __bpf_object__open(name, obj_buf, obj_buf_sz);
 }
 
 int bpf_object__unload(struct bpf_object *obj)
@@ -975,6 +986,14 @@ bpf_object__next(struct bpf_object *prev)
 	return next;
 }
 
+const char *
+bpf_object__get_name(struct bpf_object *obj)
+{
+	if (!obj)
+		return NULL;
+	return obj->path;
+}
+
 struct bpf_program *
 bpf_program__next(struct bpf_program *prev, struct bpf_object *obj)
 {
tools/lib/bpf/libbpf.h +3 -1
index ea8adc206b62..f16170c95ffd 100644
@@ -28,12 +28,14 @@ struct bpf_object;
 
 struct bpf_object *bpf_object__open(const char *path);
 struct bpf_object *bpf_object__open_buffer(void *obj_buf,
-					   size_t obj_buf_sz);
+					   size_t obj_buf_sz,
+					   const char *name);
 void bpf_object__close(struct bpf_object *object);
 
 /* Load/unload object into/from kernel */
 int bpf_object__load(struct bpf_object *obj);
 int bpf_object__unload(struct bpf_object *obj);
+const char *bpf_object__get_name(struct bpf_object *obj);
 
 struct bpf_object *bpf_object__next(struct bpf_object *prev);
 #define bpf_object__for_each_safe(pos, tmp)			\
tools/perf/tests/llvm.c +1 -1
index a337356fd979..52d55971f66f 100644
@@ -26,7 +26,7 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
 {
 	struct bpf_object *obj;
 
-	obj = bpf_object__open_buffer(obj_buf, obj_buf_sz);
+	obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, NULL);
 	if (!obj)
 		return -1;
 	bpf_object__close(obj);
Signature · 1 line
2.1.0
author maintainer
#3 lore raw

PATCH 3/6 perf evlist: Open event on evsel cpus and threads

In reply to Arnaldo Carvalho de Melo

From: Kan Liang <[email protected]>

An evsel may have different cpus and threads than the evlist it is in.

Use it's own cpus and threads, when opening the evsel in 'perf record'.

---
 tools/perf/builtin-record.c | 2 +-
 tools/perf/util/evlist.c    | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
tools/perf/builtin-record.c +1 -1
index a660022f2c92..1d14f382f614 100644
@@ -279,7 +279,7 @@ static int record__open(struct record *rec)
 
 	evlist__for_each(evlist, pos) {
 try_again:
-		if (perf_evsel__open(pos, evlist->cpus, evlist->threads) < 0) {
+		if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
 			if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
 				if (verbose)
 					ui__warning("%s\n", msg);
tools/perf/util/evlist.c +4 -0
index 8d00039d6a20..d51a5200c8af 100644
@@ -1181,6 +1181,10 @@ int perf_evlist__apply_filters(struct perf_evlist *evlist, struct perf_evsel **e
 		if (evsel->filter == NULL)
 			continue;
 
+		/*
+		 * filters only work for tracepoint event, which doesn't have cpu limit.
+		 * So evlist and evsel should always be same.
+		 */
 		err = perf_evsel__apply_filter(evsel, ncpus, nthreads, evsel->filter);
 		if (err) {
 			*err_evsel = evsel;
Signature · 1 line
2.1.0
author maintainer
#4 lore raw

PATCH 4/6 perf script: Enable printing of interrupted machine state

In reply to Arnaldo Carvalho de Melo

From: Stephane Eranian <[email protected]>

This patch adds the output of the interrupted machine state (iregs) to perf script. It presents them as NAME:VALUE so this is easy to parse during post processing.

To capture the interrupted machine state:

   $ perf record -I ....

to display iregs, use the -F option:

   $ perf script -F ip,iregs
   40afc2   AX:0x6c5770    BX:0x1e    CX:0x5f4d80a    DX:0x101010101010101    SI:0x1
---
 tools/perf/Documentation/perf-script.txt |  2 +-
 tools/perf/builtin-script.c              | 31 ++++++++++++++++++++++++++++++-
 2 files changed, 31 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-script.txt +1 -1
index 614b2c7b0293..dc3ec783b7bd 100644
@@ -116,7 +116,7 @@ OPTIONS
 --fields::
         Comma separated list of fields to print. Options are:
         comm, tid, pid, time, cpu, event, trace, ip, sym, dso, addr, symoff,
-	srcline, period, flags.
+	srcline, period, iregs, flags.
         Field list can be prepended with the type, trace, sw or hw,
         to indicate to which event type the field list applies.
         e.g., -f sw:comm,tid,time,ip,sym  and -f trace:time,cpu,trace
tools/perf/builtin-script.c +30 -1
index 4430340292c0..eb51325e8ad9 100644
@@ -6,6 +6,7 @@
 #include "util/exec_cmd.h"
 #include "util/header.h"
 #include "util/parse-options.h"
+#include "util/perf_regs.h"
 #include "util/session.h"
 #include "util/tool.h"
 #include "util/symbol.h"
@@ -46,6 +47,7 @@ enum perf_output_field {
 	PERF_OUTPUT_SYMOFFSET       = 1U << 11,
 	PERF_OUTPUT_SRCLINE         = 1U << 12,
 	PERF_OUTPUT_PERIOD          = 1U << 13,
+	PERF_OUTPUT_IREGS	    = 1U << 14,
 };
 
 struct output_option {
@@ -66,6 +68,7 @@ struct output_option {
 	{.str = "symoff", .field = PERF_OUTPUT_SYMOFFSET},
 	{.str = "srcline", .field = PERF_OUTPUT_SRCLINE},
 	{.str = "period", .field = PERF_OUTPUT_PERIOD},
+	{.str = "iregs", .field = PERF_OUTPUT_IREGS},
 };
 
 /* default set to maintain compatibility with current format */
@@ -255,6 +258,11 @@ static int perf_evsel__check_attr(struct perf_evsel *evsel,
 					PERF_OUTPUT_PERIOD))
 		return -EINVAL;
 
+	if (PRINT_FIELD(IREGS) &&
+		perf_evsel__check_stype(evsel, PERF_SAMPLE_REGS_INTR, "IREGS",
+					PERF_OUTPUT_IREGS))
+		return -EINVAL;
+
 	return 0;
 }
 
@@ -352,6 +360,24 @@ out:
 	return 0;
 }
 
+static void print_sample_iregs(union perf_event *event __maybe_unused,
+			  struct perf_sample *sample,
+			  struct thread *thread __maybe_unused,
+			  struct perf_event_attr *attr)
+{
+	struct regs_dump *regs = &sample->intr_regs;
+	uint64_t mask = attr->sample_regs_intr;
+	unsigned i = 0, r;
+
+	if (!regs)
+		return;
+
+	for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
+		u64 val = regs->regs[i++];
+		printf("%5s:0x%"PRIx64" ", perf_reg_name(r), val);
+	}
+}
+
 static void print_sample_start(struct perf_sample *sample,
 			       struct thread *thread,
 			       struct perf_evsel *evsel)
@@ -525,6 +551,9 @@ static void process_event(union perf_event *event, struct perf_sample *sample,
 				     PERF_MAX_STACK_DEPTH);
 	}
 
+	if (PRINT_FIELD(IREGS))
+		print_sample_iregs(event, sample, thread, attr);
+
 	printf("\n");
 }
 
@@ -1643,7 +1672,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
 		     "comma separated output fields prepend with 'type:'. "
 		     "Valid types: hw,sw,trace,raw. "
 		     "Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,"
-		     "addr,symoff,period,flags", parse_output_fields),
+		     "addr,symoff,period,iregs,flags", parse_output_fields),
 	OPT_BOOLEAN('a', "all-cpus", &system_wide,
 		    "system-wide collection from all CPUs"),
 	OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
Signature · 1 line
2.1.0
author maintainer
#5 lore raw

PATCH 5/6 perf/x86: Add list of register names

In reply to Arnaldo Carvalho de Melo

From: Stephane Eranian <[email protected]>

This patch adds a way to locate a register identifier (PERF_X86_REG_*) based on its name, e.g., AX.

This will be used by a subsequent patch to improved flexibility of perf record.

---
 tools/perf/arch/x86/util/Build       |  1 +
 tools/perf/arch/x86/util/perf_regs.c | 30 ++++++++++++++++++++++++++++++
 tools/perf/util/perf_regs.h          |  7 +++++++
 3 files changed, 38 insertions(+)
 create mode 100644 tools/perf/arch/x86/util/perf_regs.c
tools/perf/arch/x86/util/Build +1 -0
index 2c55e1b336c5..ff63649fa9ac 100644
@@ -2,6 +2,7 @@ libperf-y += header.o
 libperf-y += tsc.o
 libperf-y += pmu.o
 libperf-y += kvm-stat.o
+libperf-y += perf_regs.o
 
 libperf-$(CONFIG_DWARF) += dwarf-regs.o
 
tools/perf/arch/x86/util/perf_regs.c new file +30 -0
new file mode 100644
index 000000000000..087c84ef5234
@@ -0,0 +1,30 @@
+#include "../../perf.h"
+#include "../../util/perf_regs.h"
+
+#define REG(n, b) { .name = #n, .mask = 1ULL << (b) }
+#define REG_END { .name = NULL }
+const struct sample_reg sample_reg_masks[] = {
+	REG(AX, PERF_REG_X86_AX),
+	REG(BX, PERF_REG_X86_BX),
+	REG(CX, PERF_REG_X86_CX),
+	REG(DX, PERF_REG_X86_DX),
+	REG(SI, PERF_REG_X86_SI),
+	REG(DI, PERF_REG_X86_DI),
+	REG(BP, PERF_REG_X86_BP),
+	REG(SP, PERF_REG_X86_SP),
+	REG(IP, PERF_REG_X86_IP),
+	REG(FLAGS, PERF_REG_X86_FLAGS),
+	REG(CS, PERF_REG_X86_CS),
+	REG(SS, PERF_REG_X86_SS),
+#ifdef HAVE_ARCH_X86_64_SUPPORT
+	REG(R8, PERF_REG_X86_R8),
+	REG(R9, PERF_REG_X86_R9),
+	REG(R10, PERF_REG_X86_R10),
+	REG(R11, PERF_REG_X86_R11),
+	REG(R12, PERF_REG_X86_R12),
+	REG(R13, PERF_REG_X86_R13),
+	REG(R14, PERF_REG_X86_R14),
+	REG(R15, PERF_REG_X86_R15),
+#endif
+	REG_END
+};
tools/perf/util/perf_regs.h +7 -0
index 980dbf76bc98..92c1fff2153e 100644
@@ -5,6 +5,13 @@
 
 struct regs_dump;
 
+struct sample_reg {
+	const char *name;
+	uint64_t mask;
+};
+
+extern const struct sample_reg sample_reg_masks[];
+
 #ifdef HAVE_PERF_REGS_SUPPORT
 #include <perf_regs.h>
 
Signature · 1 line
2.1.0
author maintainer
#6 lore raw

PATCH 6/6 perf record: Add ability to name registers to record

In reply to Arnaldo Carvalho de Melo

From: Stephane Eranian <[email protected]>

This patch modifies the -I/--int-regs option to enablepassing the name of the registers to sample on interrupt. Registers can be specified by their symbolic names. For instance on x86, --intr-regs=ax,si.

The motivation is to reduce the size of the perf.data file and the overhead of sampling by only collecting the registers useful to a specific analysis. For instance, for value profiling, sampling only the registers used to passed arguements to functions.

With no parameter, the --intr-regs still records all possible registers based on the architecture.

To name registers, it is necessary to use the long form of the option, i.e., --intr-regs:

  $ perf record --intr-regs=si,di,r8,r9 .....

To record any possible registers:

  $ perf record -I .....
  $ perf report --intr-regs ...

To display the register, one can use perf report -D

To list the available registers:

  $ perf record --intr-regs=\?
  available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10 R11 R12 R13 R14 R15
---
 tools/perf/Documentation/perf-record.txt |  6 ++-
 tools/perf/builtin-record.c              |  7 +++-
 tools/perf/perf.h                        |  2 +-
 tools/perf/util/Build                    |  1 +
 tools/perf/util/evsel.c                  |  2 +-
 tools/perf/util/parse-regs-options.c     | 71 ++++++++++++++++++++++++++++++++
 tools/perf/util/parse-regs-options.h     |  5 +++
 7 files changed, 89 insertions(+), 5 deletions(-)
 create mode 100644 tools/perf/util/parse-regs-options.c
 create mode 100644 tools/perf/util/parse-regs-options.h
tools/perf/Documentation/perf-record.txt +5 -1
index 347a27322ed8..2e9ce77b5e14 100644
@@ -276,7 +276,11 @@ filter out the startup phase of the program, which is often very different.
 --intr-regs::
 Capture machine state (registers) at interrupt, i.e., on counter overflows for
 each sample. List of captured registers depends on the architecture. This option
-is off by default.
+is off by default. It is possible to select the registers to sample using their
+symbolic names, e.g. on x86, ax, si. To list the available registers use
+--intr-regs=\?. To name registers, pass a comma separated list such as
+--intr-regs=ax,bx. The list of register is architecture dependent.
+
 
 --running-time::
 Record running and enabled time for read events (:S)
tools/perf/builtin-record.c +5 -2
index 1d14f382f614..142eeb341b29 100644
@@ -27,8 +27,10 @@
 #include "util/cpumap.h"
 #include "util/thread_map.h"
 #include "util/data.h"
+#include "util/perf_regs.h"
 #include "util/auxtrace.h"
 #include "util/parse-branch-options.h"
+#include "util/parse-regs-options.h"
 
 #include <unistd.h>
 #include <sched.h>
@@ -1080,8 +1082,9 @@ struct option __record_options[] = {
 		    "sample transaction flags (special events only)"),
 	OPT_BOOLEAN(0, "per-thread", &record.opts.target.per_thread,
 		    "use per-thread mmaps"),
-	OPT_BOOLEAN('I', "intr-regs", &record.opts.sample_intr_regs,
-		    "Sample machine registers on interrupt"),
+	OPT_CALLBACK_OPTARG('I', "intr-regs", &record.opts.sample_intr_regs, NULL, "any register",
+		    "sample selected machine registers on interrupt,"
+		    " use -I ? to list register names", parse_regs),
 	OPT_BOOLEAN(0, "running-time", &record.opts.running_time,
 		    "Record running/enabled time of read (:S) events"),
 	OPT_CALLBACK('k', "clockid", &record.opts,
tools/perf/perf.h +1 -1
index cccb4cf575d3..90129accffbe 100644
@@ -54,7 +54,6 @@ struct record_opts {
 	bool	     sample_time_set;
 	bool	     callgraph_set;
 	bool	     period;
-	bool	     sample_intr_regs;
 	bool	     running_time;
 	bool	     full_auxtrace;
 	bool	     auxtrace_snapshot_mode;
@@ -64,6 +63,7 @@ struct record_opts {
 	unsigned int auxtrace_mmap_pages;
 	unsigned int user_freq;
 	u64          branch_stack;
+	u64	     sample_intr_regs;
 	u64	     default_interval;
 	u64	     user_interval;
 	size_t	     auxtrace_snapshot_size;
tools/perf/util/Build +1 -0
index e79e4522368a..349bc96ca1fe 100644
@@ -83,6 +83,7 @@ libperf-$(CONFIG_AUXTRACE) += intel-pt-decoder/
 libperf-$(CONFIG_AUXTRACE) += intel-pt.o
 libperf-$(CONFIG_AUXTRACE) += intel-bts.o
 libperf-y += parse-branch-options.o
+libperf-y += parse-regs-options.o
 
 libperf-$(CONFIG_LIBELF) += symbol-elf.o
 libperf-$(CONFIG_LIBELF) += probe-file.o
tools/perf/util/evsel.c +1 -1
index bac25f41a751..c53f79123b37 100644
@@ -787,7 +787,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 		perf_evsel__config_callgraph(evsel, opts, &callchain_param);
 
 	if (opts->sample_intr_regs) {
-		attr->sample_regs_intr = PERF_REGS_MASK;
+		attr->sample_regs_intr = opts->sample_intr_regs;
 		perf_evsel__set_sample_bit(evsel, REGS_INTR);
 	}
 
tools/perf/util/parse-regs-options.c new file +71 -0

71 lines not on this page · raw message

tools/perf/util/parse-regs-options.h new file +5 -0
new file mode 100644
index 000000000000..7d762b188007
@@ -0,0 +1,5 @@
+#ifndef _PERF_PARSE_REGS_OPTIONS_H
+#define _PERF_PARSE_REGS_OPTIONS_H 1
+struct option;
+int parse_regs(const struct option *opt, const char *str, int unset);
+#endif /* _PERF_PARSE_REGS_OPTIONS_H */
Signature · 1 line
2.1.0
#7 lore raw
In reply to Arnaldo Carvalho de Melo
Quoted 78 lines · Arnaldo Carvalho de Melo

Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit bac2e4a96d1c0bcce5e9654dcc902f75576b9b03:

Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-08-31 10:25:46 +0200)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo

for you to fetch changes up to bcc84ec65ad1bd9f777a1fade6f8e5e0c5808fa5:

perf record: Add ability to name registers to record (2015-08-31 18:01:33 -0300)

----------------------------------------------------------------
perf/core improvements and fixes:

User visible:

- Add ability to specify to select which registers to record, to reduce the size of perf.data files, and also allow printing the registers in 'perf script': (Stephane Eranian)

    # perf record --intr-regs=AX,SP usleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.016 MB perf.data (8 samples) ]
    # perf script -F ip,sym,iregs | tail -5
     ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
     ffffffff8105f42a native_write_msr_safe   AX:0xf    SP:0xffff8802629c3c00
     ffffffff81761ac0 _raw_spin_lock   AX:0xffff8801bfcf8020    SP:0xffff8802629c3ce8
     ffffffff81202bf8 __vma_adjust_trans_huge   AX:0x7ffc75200000    SP:0xffff8802629c3b30
     ffffffff8122b089 dput   AX:0x101    SP:0xffff8802629c3c78
    #

Infrastructure:

- Open event on evsel cpus and threads (Kan Liang)

- New bpf API to get name from a BPF object (Wang Nan)

Build fixes:

- Fix build on powerpc broken by pt/bts (Adrian Hunter)

----------------------------------------------------------------
Adrian Hunter (1):
perf tools: Fix build on powerpc broken by pt/bts

Kan Liang (1):
perf evlist: Open event on evsel cpus and threads

Stephane Eranian (3):
perf script: Enable printing of interrupted machine state perf/x86: Add list of register names
perf record: Add ability to name registers to record

Wang Nan (1):
bpf tools: New API to get name from a BPF object

 tools/lib/bpf/libbpf.c                             | 25 +++++++-
 tools/lib/bpf/libbpf.h                             |  4 +-
 tools/perf/Documentation/perf-record.txt           |  6 +-
 tools/perf/Documentation/perf-script.txt           |  2 +-
 tools/perf/arch/x86/util/Build                     |  1 +
 tools/perf/arch/x86/util/perf_regs.c               | 30 +++++++++
 tools/perf/builtin-record.c                        |  9 ++-
 tools/perf/builtin-script.c                        | 31 +++++++++-
 tools/perf/perf.h                                  |  2 +-
 tools/perf/tests/llvm.c                            |  2 +-
 tools/perf/util/Build                              |  2 +
 tools/perf/util/evlist.c                           |  4 ++
 tools/perf/util/evsel.c                            |  2 +-
Quoted 8 lines
 .../util/intel-pt-decoder/intel-pt-insn-decoder.c  |  3 +
 tools/perf/util/parse-regs-options.c               | 71 ++++++++++++++++++++++
 tools/perf/util/parse-regs-options.h               |  5 ++
 tools/perf/util/perf_regs.h                        |  7 +++
 17 files changed, 193 insertions(+), 13 deletions(-)
 create mode 100644 tools/perf/arch/x86/util/perf_regs.c
 create mode 100644 tools/perf/util/parse-regs-options.c
 create mode 100644 tools/perf/util/parse-regs-options.h

Pulled into tip:perf/urgent, thanks a lot Arnaldo!

Ingo