linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL 00/10] perf/core improvements and fixes
@ 2015-07-30 16:16 Arnaldo Carvalho de Melo
  2015-07-30 16:16 ` [PATCH 01/10] perf python: Remove dependency on 'machine' methods Arnaldo Carvalho de Melo
                   ` (10 more replies)
  0 siblings, 11 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:16 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Andi Kleen, Borislav Petkov, David Ahern, Frederic Weisbecker,
	Jaroslav Skarvada, Jeremy Eder, Jiri Olsa, Kan Liang,
	Luiz Fernando Capitulino, Namhyung Kim, Pawel Moll,
	Peter Zijlstra, Stephane Eranian

Hi Ingo,

	Please consider pulling,

- Arnaldo

The following changes since commit 4b0c53e9e1a2a785746b2d379a32cb70b4dbb2fd:

  Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-07-27 17:56:18 +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 aa53c09e90a19c215549bd1ca970fddcb7c0c001:


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

* [PATCH 01/10] perf python: Remove dependency on 'machine' methods
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
@ 2015-07-30 16:16 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 02/10] perf python: Add macro to simplify maintainance of the constants array Arnaldo Carvalho de Melo
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:16 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The python binding still doesn't provide symbol resolving facilities,
but the recent addition of the trace_event__register_resolver() function
made it add as a dependency the machine__resolve_kernel_addr() method,
that in turn drags all the symbol resolving code.

The problem:

  [root@zoo ~]# perf test -v python
  17: Try 'import perf' in python, checking link problems      :
  --- start ---
  test child forked, pid 6853
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ImportError: /tmp/build/perf/python/perf.so: undefined symbol: machine__resolve_kernel_addr
  test child finished with -1
  ---- end ----
  Try 'import perf' in python, checking link problems: FAILED!
  [root@zoo ~]#

Fix it by requiring this function to receive the resolver as a
parameter, just like pevent_register_function_resolver(), i.e. do
not explicitely refer to an object file not included in
tools/perf/util/python-ext-sources.

  [root@zoo ~]# perf test python
  17: Try 'import perf' in python, checking link problems      : Ok
  [root@zoo ~]#

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Fixes: c3168b0db93a ("perf symbols: Provide libtraceevent callback to resolve kernel symbols")
Link: http://lkml.kernel.org/n/tip-vxlhh95v2em9zdbgj3jm7xi5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c    | 2 +-
 tools/perf/util/trace-event.c | 7 +++----
 tools/perf/util/trace-event.h | 3 ++-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 282841b10f24..06cfa93c0305 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1489,7 +1489,7 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
 	if (trace->host == NULL)
 		return -ENOMEM;
 
-	if (trace_event__register_resolver(trace->host) < 0)
+	if (trace_event__register_resolver(trace->host, machine__resolve_kernel_addr) < 0)
 		return -errno;
 
 	err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
diff --git a/tools/perf/util/trace-event.c b/tools/perf/util/trace-event.c
index 667bd109d16f..b90e646c7a91 100644
--- a/tools/perf/util/trace-event.c
+++ b/tools/perf/util/trace-event.c
@@ -50,14 +50,13 @@ static int trace_event__init2(void)
 	return 0;
 }
 
-int trace_event__register_resolver(struct machine *machine)
+int trace_event__register_resolver(struct machine *machine,
+				   pevent_func_resolver_t *func)
 {
 	if (!tevent_initialized && trace_event__init2())
 		return -1;
 
-	return pevent_set_function_resolver(tevent.pevent,
-					    machine__resolve_kernel_addr,
-					    machine);
+	return pevent_set_function_resolver(tevent.pevent, func, machine);
 }
 
 void trace_event__cleanup(struct trace_event *t)
diff --git a/tools/perf/util/trace-event.h b/tools/perf/util/trace-event.h
index 568128c3284a..da6cc4cc2a4f 100644
--- a/tools/perf/util/trace-event.h
+++ b/tools/perf/util/trace-event.h
@@ -18,7 +18,8 @@ struct trace_event {
 
 int trace_event__init(struct trace_event *t);
 void trace_event__cleanup(struct trace_event *t);
-int trace_event__register_resolver(struct machine *machine);
+int trace_event__register_resolver(struct machine *machine,
+				   pevent_func_resolver_t *func);
 struct event_format*
 trace_event__tp_format(const char *sys, const char *name);
 
-- 
2.1.0


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

* [PATCH 02/10] perf python: Add macro to simplify maintainance of the constants array
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2015-07-30 16:16 ` [PATCH 01/10] perf python: Remove dependency on 'machine' methods Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 03/10] perf python: Add missing PERF_RECORD_{MMAP2,AUX,etc} Arnaldo Carvalho de Melo
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, David Ahern, Jiri Olsa,
	Namhyung Kim

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-ffuchgsbr5mqu91xl9oggfss@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/python.c | 134 ++++++++++++++++++++++++-----------------------
 1 file changed, 68 insertions(+), 66 deletions(-)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index 626422eda727..a851b791151b 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -941,76 +941,78 @@ static int pyrf_evlist__setup_types(void)
 	return PyType_Ready(&pyrf_evlist__type);
 }
 
+#define PERF_CONST(name) { #name, PERF_##name }
+
 static struct {
 	const char *name;
 	int	    value;
 } perf__constants[] = {
-	{ "TYPE_HARDWARE",   PERF_TYPE_HARDWARE },
-	{ "TYPE_SOFTWARE",   PERF_TYPE_SOFTWARE },
-	{ "TYPE_TRACEPOINT", PERF_TYPE_TRACEPOINT },
-	{ "TYPE_HW_CACHE",   PERF_TYPE_HW_CACHE },
-	{ "TYPE_RAW",	     PERF_TYPE_RAW },
-	{ "TYPE_BREAKPOINT", PERF_TYPE_BREAKPOINT },
-
-	{ "COUNT_HW_CPU_CYCLES",	  PERF_COUNT_HW_CPU_CYCLES },
-	{ "COUNT_HW_INSTRUCTIONS",	  PERF_COUNT_HW_INSTRUCTIONS },
-	{ "COUNT_HW_CACHE_REFERENCES",	  PERF_COUNT_HW_CACHE_REFERENCES },
-	{ "COUNT_HW_CACHE_MISSES",	  PERF_COUNT_HW_CACHE_MISSES },
-	{ "COUNT_HW_BRANCH_INSTRUCTIONS", PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
-	{ "COUNT_HW_BRANCH_MISSES",	  PERF_COUNT_HW_BRANCH_MISSES },
-	{ "COUNT_HW_BUS_CYCLES",	  PERF_COUNT_HW_BUS_CYCLES },
-	{ "COUNT_HW_CACHE_L1D",		  PERF_COUNT_HW_CACHE_L1D },
-	{ "COUNT_HW_CACHE_L1I",		  PERF_COUNT_HW_CACHE_L1I },
-	{ "COUNT_HW_CACHE_LL",	  	  PERF_COUNT_HW_CACHE_LL },
-	{ "COUNT_HW_CACHE_DTLB",	  PERF_COUNT_HW_CACHE_DTLB },
-	{ "COUNT_HW_CACHE_ITLB",	  PERF_COUNT_HW_CACHE_ITLB },
-	{ "COUNT_HW_CACHE_BPU",		  PERF_COUNT_HW_CACHE_BPU },
-	{ "COUNT_HW_CACHE_OP_READ",	  PERF_COUNT_HW_CACHE_OP_READ },
-	{ "COUNT_HW_CACHE_OP_WRITE",	  PERF_COUNT_HW_CACHE_OP_WRITE },
-	{ "COUNT_HW_CACHE_OP_PREFETCH",	  PERF_COUNT_HW_CACHE_OP_PREFETCH },
-	{ "COUNT_HW_CACHE_RESULT_ACCESS", PERF_COUNT_HW_CACHE_RESULT_ACCESS },
-	{ "COUNT_HW_CACHE_RESULT_MISS",   PERF_COUNT_HW_CACHE_RESULT_MISS },
-
-	{ "COUNT_HW_STALLED_CYCLES_FRONTEND",	  PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },
-	{ "COUNT_HW_STALLED_CYCLES_BACKEND",	  PERF_COUNT_HW_STALLED_CYCLES_BACKEND },
-
-	{ "COUNT_SW_CPU_CLOCK",	       PERF_COUNT_SW_CPU_CLOCK },
-	{ "COUNT_SW_TASK_CLOCK",       PERF_COUNT_SW_TASK_CLOCK },
-	{ "COUNT_SW_PAGE_FAULTS",      PERF_COUNT_SW_PAGE_FAULTS },
-	{ "COUNT_SW_CONTEXT_SWITCHES", PERF_COUNT_SW_CONTEXT_SWITCHES },
-	{ "COUNT_SW_CPU_MIGRATIONS",   PERF_COUNT_SW_CPU_MIGRATIONS },
-	{ "COUNT_SW_PAGE_FAULTS_MIN",  PERF_COUNT_SW_PAGE_FAULTS_MIN },
-	{ "COUNT_SW_PAGE_FAULTS_MAJ",  PERF_COUNT_SW_PAGE_FAULTS_MAJ },
-	{ "COUNT_SW_ALIGNMENT_FAULTS", PERF_COUNT_SW_ALIGNMENT_FAULTS },
-	{ "COUNT_SW_EMULATION_FAULTS", PERF_COUNT_SW_EMULATION_FAULTS },
-	{ "COUNT_SW_DUMMY",            PERF_COUNT_SW_DUMMY },
-
-	{ "SAMPLE_IP",	      PERF_SAMPLE_IP },
-	{ "SAMPLE_TID",	      PERF_SAMPLE_TID },
-	{ "SAMPLE_TIME",      PERF_SAMPLE_TIME },
-	{ "SAMPLE_ADDR",      PERF_SAMPLE_ADDR },
-	{ "SAMPLE_READ",      PERF_SAMPLE_READ },
-	{ "SAMPLE_CALLCHAIN", PERF_SAMPLE_CALLCHAIN },
-	{ "SAMPLE_ID",	      PERF_SAMPLE_ID },
-	{ "SAMPLE_CPU",	      PERF_SAMPLE_CPU },
-	{ "SAMPLE_PERIOD",    PERF_SAMPLE_PERIOD },
-	{ "SAMPLE_STREAM_ID", PERF_SAMPLE_STREAM_ID },
-	{ "SAMPLE_RAW",	      PERF_SAMPLE_RAW },
-
-	{ "FORMAT_TOTAL_TIME_ENABLED", PERF_FORMAT_TOTAL_TIME_ENABLED },
-	{ "FORMAT_TOTAL_TIME_RUNNING", PERF_FORMAT_TOTAL_TIME_RUNNING },
-	{ "FORMAT_ID",		       PERF_FORMAT_ID },
-	{ "FORMAT_GROUP",	       PERF_FORMAT_GROUP },
-
-	{ "RECORD_MMAP",       PERF_RECORD_MMAP },
-	{ "RECORD_LOST",       PERF_RECORD_LOST },
-	{ "RECORD_COMM",       PERF_RECORD_COMM },
-	{ "RECORD_EXIT",       PERF_RECORD_EXIT },
-	{ "RECORD_THROTTLE",   PERF_RECORD_THROTTLE },
-	{ "RECORD_UNTHROTTLE", PERF_RECORD_UNTHROTTLE },
-	{ "RECORD_FORK",       PERF_RECORD_FORK },
-	{ "RECORD_READ",       PERF_RECORD_READ },
-	{ "RECORD_SAMPLE",     PERF_RECORD_SAMPLE },
+	PERF_CONST(TYPE_HARDWARE),
+	PERF_CONST(TYPE_SOFTWARE),
+	PERF_CONST(TYPE_TRACEPOINT),
+	PERF_CONST(TYPE_HW_CACHE),
+	PERF_CONST(TYPE_RAW),
+	PERF_CONST(TYPE_BREAKPOINT),
+
+	PERF_CONST(COUNT_HW_CPU_CYCLES),
+	PERF_CONST(COUNT_HW_INSTRUCTIONS),
+	PERF_CONST(COUNT_HW_CACHE_REFERENCES),
+	PERF_CONST(COUNT_HW_CACHE_MISSES),
+	PERF_CONST(COUNT_HW_BRANCH_INSTRUCTIONS),
+	PERF_CONST(COUNT_HW_BRANCH_MISSES),
+	PERF_CONST(COUNT_HW_BUS_CYCLES),
+	PERF_CONST(COUNT_HW_CACHE_L1D),
+	PERF_CONST(COUNT_HW_CACHE_L1I),
+	PERF_CONST(COUNT_HW_CACHE_LL),
+	PERF_CONST(COUNT_HW_CACHE_DTLB),
+	PERF_CONST(COUNT_HW_CACHE_ITLB),
+	PERF_CONST(COUNT_HW_CACHE_BPU),
+	PERF_CONST(COUNT_HW_CACHE_OP_READ),
+	PERF_CONST(COUNT_HW_CACHE_OP_WRITE),
+	PERF_CONST(COUNT_HW_CACHE_OP_PREFETCH),
+	PERF_CONST(COUNT_HW_CACHE_RESULT_ACCESS),
+	PERF_CONST(COUNT_HW_CACHE_RESULT_MISS),
+
+	PERF_CONST(COUNT_HW_STALLED_CYCLES_FRONTEND),
+	PERF_CONST(COUNT_HW_STALLED_CYCLES_BACKEND),
+
+	PERF_CONST(COUNT_SW_CPU_CLOCK),
+	PERF_CONST(COUNT_SW_TASK_CLOCK),
+	PERF_CONST(COUNT_SW_PAGE_FAULTS),
+	PERF_CONST(COUNT_SW_CONTEXT_SWITCHES),
+	PERF_CONST(COUNT_SW_CPU_MIGRATIONS),
+	PERF_CONST(COUNT_SW_PAGE_FAULTS_MIN),
+	PERF_CONST(COUNT_SW_PAGE_FAULTS_MAJ),
+	PERF_CONST(COUNT_SW_ALIGNMENT_FAULTS),
+	PERF_CONST(COUNT_SW_EMULATION_FAULTS),
+	PERF_CONST(COUNT_SW_DUMMY),
+
+	PERF_CONST(SAMPLE_IP),
+	PERF_CONST(SAMPLE_TID),
+	PERF_CONST(SAMPLE_TIME),
+	PERF_CONST(SAMPLE_ADDR),
+	PERF_CONST(SAMPLE_READ),
+	PERF_CONST(SAMPLE_CALLCHAIN),
+	PERF_CONST(SAMPLE_ID),
+	PERF_CONST(SAMPLE_CPU),
+	PERF_CONST(SAMPLE_PERIOD),
+	PERF_CONST(SAMPLE_STREAM_ID),
+	PERF_CONST(SAMPLE_RAW),
+
+	PERF_CONST(FORMAT_TOTAL_TIME_ENABLED),
+	PERF_CONST(FORMAT_TOTAL_TIME_RUNNING),
+	PERF_CONST(FORMAT_ID),
+	PERF_CONST(FORMAT_GROUP),
+
+	PERF_CONST(RECORD_MMAP),
+	PERF_CONST(RECORD_LOST),
+	PERF_CONST(RECORD_COMM),
+	PERF_CONST(RECORD_EXIT),
+	PERF_CONST(RECORD_THROTTLE),
+	PERF_CONST(RECORD_UNTHROTTLE),
+	PERF_CONST(RECORD_FORK),
+	PERF_CONST(RECORD_READ),
+	PERF_CONST(RECORD_SAMPLE),
 	{ .name = NULL, },
 };
 
-- 
2.1.0


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

* [PATCH 03/10] perf python: Add missing PERF_RECORD_{MMAP2,AUX,etc}
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
  2015-07-30 16:16 ` [PATCH 01/10] perf python: Remove dependency on 'machine' methods Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 02/10] perf python: Add macro to simplify maintainance of the constants array Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 04/10] perf python: Make twatch.py use soft dummy event, freq=0 Arnaldo Carvalho de Melo
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

Those were added to the kernel and tooling but we forgot to
expose them via the python binding, fix it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-sg1m6t2c58gchidfce4hmitg@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/python.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c
index a851b791151b..6324fe6b161e 100644
--- a/tools/perf/util/python.c
+++ b/tools/perf/util/python.c
@@ -1013,6 +1013,12 @@ static struct {
 	PERF_CONST(RECORD_FORK),
 	PERF_CONST(RECORD_READ),
 	PERF_CONST(RECORD_SAMPLE),
+	PERF_CONST(RECORD_MMAP2),
+	PERF_CONST(RECORD_AUX),
+	PERF_CONST(RECORD_ITRACE_START),
+	PERF_CONST(RECORD_LOST_SAMPLES),
+	PERF_CONST(RECORD_SWITCH),
+	PERF_CONST(RECORD_SWITCH_CPU_WIDE),
 	{ .name = NULL, },
 };
 
-- 
2.1.0


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

* [PATCH 04/10] perf python: Make twatch.py use soft dummy event, freq=0
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (2 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 03/10] perf python: Add missing PERF_RECORD_{MMAP2,AUX,etc} Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 05/10] perf symbols: Fix mismatched declarations for elf_getphdrnum Arnaldo Carvalho de Melo
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker,
	Jaroslav Skarvada, Jeremy Eder, Jiri Olsa, Namhyung Kim,
	Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

To not sample, what we want are just the PERF_RECORD_ lifetime events
for threads, using the default, PERF_TYPE_HARDWARE +
PERF_COUNT_HW_CYCLES and freq=1 (the default), makes perf reenable
irq_vectors:local_timer_entry, disabling nohz, not good for some use
cases where all we want is to get notifications when threads comes and
goes...

Fix it by using PERF_TYPE_SOFTWARE (no counter rotation) and
PERF_COUNT_SW_DUMMY (created by Adrian so that we could have access to
those PERF_RECORD_ goodies).

Reported-by: Luiz Fernando Capitulino <lcapitulino@redhat.com>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jaroslav Skarvada <jskarvad@redhat.com>
Cc: Jeremy Eder <jeder@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-kfsijirfrs6xfhkcdxeoen06@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/python/twatch.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/tools/perf/python/twatch.py b/tools/perf/python/twatch.py
index 2225162ee1fc..b9d508336ae6 100755
--- a/tools/perf/python/twatch.py
+++ b/tools/perf/python/twatch.py
@@ -18,10 +18,20 @@ import perf
 def main():
 	cpus = perf.cpu_map()
 	threads = perf.thread_map()
-	evsel = perf.evsel(task = 1, comm = 1, mmap = 0,
+	evsel = perf.evsel(type	  = perf.TYPE_SOFTWARE,
+			   config = perf.COUNT_SW_DUMMY,
+			   task = 1, comm = 1, mmap = 0, freq = 0,
 			   wakeup_events = 1, watermark = 1,
 			   sample_id_all = 1,
 			   sample_type = perf.SAMPLE_PERIOD | perf.SAMPLE_TID | perf.SAMPLE_CPU)
+
+	"""What we want are just the PERF_RECORD_ lifetime events for threads,
+	 using the default, PERF_TYPE_HARDWARE + PERF_COUNT_HW_CYCLES & freq=1
+	 (the default), makes perf reenable irq_vectors:local_timer_entry, when
+	 disabling nohz, not good for some use cases where all we want is to get
+	 threads comes and goes... So use (perf.TYPE_SOFTWARE, perf_COUNT_SW_DUMMY,
+	 freq=0) instead."""
+
 	evsel.open(cpus = cpus, threads = threads);
 	evlist = perf.evlist(cpus, threads)
 	evlist.add(evsel)
-- 
2.1.0


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

* [PATCH 05/10] perf symbols: Fix mismatched declarations for elf_getphdrnum
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (3 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 04/10] perf python: Make twatch.py use soft dummy event, freq=0 Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 06/10] perf session env: Rename exit method Arnaldo Carvalho de Melo
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

When HAVE_ELF_GETPHDRNUM_SUPPORT is false we trip on this problem:

    CC       /tmp/build/perf/util/symbol-elf.o
  util/symbol-elf.c:41:12: error: static declaration of ‘elf_getphdrnum’ follows non-static declaration
   static int elf_getphdrnum(Elf *elf, size_t *dst)
            ^
  In file included from util/symbol.h:19:0,
                   from util/symbol-elf.c:8:
  /usr/include/libelf.h:206:12: note: previous declaration of ‘elf_getphdrnum’ was here
   extern int elf_getphdrnum (Elf *__elf, size_t *__dst);
            ^
    MKDIR    /tmp/build/perf/bench/
  /home/git/linux/tools/build/Makefile.build:68: recipe for target '/tmp/build/perf/util/symbol-elf.o' failed
  make[3]: *** [/tmp/build/perf/util/symbol-elf.o] Error 1

Fix it.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-qcmekyfedmov4sxr0wahcikr@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/symbol-elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 65f7e389ae09..b0ad810f04dd 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -38,7 +38,7 @@ static inline char *bfd_demangle(void __maybe_unused *v,
 #endif
 
 #ifndef HAVE_ELF_GETPHDRNUM_SUPPORT
-static int elf_getphdrnum(Elf *elf, size_t *dst)
+int elf_getphdrnum(Elf *elf, size_t *dst)
 {
 	GElf_Ehdr gehdr;
 	GElf_Ehdr *ehdr;
-- 
2.1.0


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

* [PATCH 06/10] perf session env: Rename exit method
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (4 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 05/10] perf symbols: Fix mismatched declarations for elf_getphdrnum Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 07/10] perf tools: Add support for event post configuration Arnaldo Carvalho de Melo
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Arnaldo Carvalho de Melo, Adrian Hunter,
	Borislav Petkov, David Ahern, Frederic Weisbecker, Jiri Olsa,
	Kan Liang, Namhyung Kim, Stephane Eranian

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The semantic associated in tools/perf/ with foo__delete(instance) is to
release all resources referenced by 'instance' members and then release
the memory for 'instance' itself.

The perf_session_env__delete() function isn't doing this, it just does
the first part, but the space used by 'instance' itself isn't freed, as
it is embedded in a larger structure, that will be freed at other stage.

For these cases we se foo__exit(), i.e. the usage is:

 void foo__delete(foo)
 {
         if (foo) {
                 foo__exit(foo);
                 free(foo);
         }
 }

But when we have something like:

 struct bar {
         struct foo foo;
         . . .
 }

Then we can't really call foo__delete(&bar.foo), we must have this
instead:

 void bar__exit(bar)
 {
         foo__exit(&bar.foo);
         /* free other bar-> resources */
 }

 void bar__delete(bar)
 {
         if (bar) {
		bar__exit(bar);
                free(bar);
         }
 }

So just rename perf_session_env__delete() to perf_session_env__exit().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-djbgpcfo5udqptx3q0flwtmk@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/session.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 2d9574710543..f51eb54aeeb3 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -170,7 +170,7 @@ static void perf_session__delete_threads(struct perf_session *session)
 	machine__delete_threads(&session->machines.host);
 }
 
-static void perf_session_env__delete(struct perf_session_env *env)
+static void perf_session_env__exit(struct perf_session_env *env)
 {
 	zfree(&env->hostname);
 	zfree(&env->os_release);
@@ -193,7 +193,7 @@ void perf_session__delete(struct perf_session *session)
 	auxtrace_index__free(&session->auxtrace_index);
 	perf_session__destroy_kernel_maps(session);
 	perf_session__delete_threads(session);
-	perf_session_env__delete(&session->header.env);
+	perf_session_env__exit(&session->header.env);
 	machines__exit(&session->machines);
 	if (session->file)
 		perf_data_file__close(session->file);
-- 
2.1.0


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

* [PATCH 07/10] perf tools: Add support for event post configuration
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (5 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 06/10] perf session env: Rename exit method Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 08/10] perf tools: Force period term to overload global settings Arnaldo Carvalho de Melo
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, Andi Kleen, Kan Liang, Namhyung Kim,
	Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Add support to overload any global settings for event and force user
specified term value. It will be useful for new time and backtrace
terms.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1438162936-59698-2-git-send-email-kan.liang@intel.com
Signed-off-by: Kan Liang <kan.liang@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evsel.c        | 31 +++++++++++++++++++
 tools/perf/util/evsel.h        | 19 ++++++++++++
 tools/perf/util/parse-events.c | 67 +++++++++++++++++++++++++++++++++++-------
 3 files changed, 106 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 71f6905c7cb9..048d61dde3f6 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -207,6 +207,7 @@ void perf_evsel__init(struct perf_evsel *evsel,
 	evsel->unit	   = "";
 	evsel->scale	   = 1.0;
 	INIT_LIST_HEAD(&evsel->node);
+	INIT_LIST_HEAD(&evsel->config_terms);
 	perf_evsel__object.init(evsel);
 	evsel->sample_size = __perf_evsel__sample_size(attr->sample_type);
 	perf_evsel__calc_id_pos(evsel);
@@ -586,6 +587,19 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel,
 	}
 }
 
+static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
+			       struct list_head *config_terms)
+{
+	struct perf_evsel_config_term *term;
+
+	list_for_each_entry(term, config_terms, list) {
+		switch (term->type) {
+		default:
+			break;
+		}
+	}
+}
+
 /*
  * The enable_on_exec/disabled value strategy:
  *
@@ -777,6 +791,12 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
 		attr->use_clockid = 1;
 		attr->clockid = opts->clockid;
 	}
+
+	/*
+	 * Apply event specific term settings,
+	 * it overloads any global configuration.
+	 */
+	apply_config_terms(attr, &evsel->config_terms);
 }
 
 static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
@@ -900,6 +920,16 @@ static void perf_evsel__free_id(struct perf_evsel *evsel)
 	zfree(&evsel->id);
 }
 
+static void perf_evsel__free_config_terms(struct perf_evsel *evsel)
+{
+	struct perf_evsel_config_term *term, *h;
+
+	list_for_each_entry_safe(term, h, &evsel->config_terms, list) {
+		list_del(&term->list);
+		free(term);
+	}
+}
+
 void perf_evsel__close_fd(struct perf_evsel *evsel, int ncpus, int nthreads)
 {
 	int cpu, thread;
@@ -919,6 +949,7 @@ void perf_evsel__exit(struct perf_evsel *evsel)
 	assert(list_empty(&evsel->node));
 	perf_evsel__free_fd(evsel);
 	perf_evsel__free_id(evsel);
+	perf_evsel__free_config_terms(evsel);
 	close_cgroup(evsel->cgrp);
 	cpu_map__put(evsel->cpus);
 	thread_map__put(evsel->threads);
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 1fc263a80d91..033981974fd2 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -31,6 +31,24 @@ struct perf_sample_id {
 
 struct cgroup_sel;
 
+/*
+ * The 'struct perf_evsel_config_term' is used to pass event
+ * specific configuration data to perf_evsel__config routine.
+ * It is allocated within event parsing and attached to
+ * perf_evsel::config_terms list head.
+*/
+enum {
+	PERF_EVSEL__CONFIG_TERM_MAX,
+};
+
+struct perf_evsel_config_term {
+	struct list_head	list;
+	int	type;
+	union {
+		u64	period;
+	} val;
+};
+
 /** struct perf_evsel - event selector
  *
  * @name - Can be set to retain the original event name passed by the user,
@@ -87,6 +105,7 @@ struct perf_evsel {
 	struct perf_evsel	*leader;
 	char			*group_name;
 	bool			cmdline_group_boundary;
+	struct list_head	config_terms;
 };
 
 union u64_swap {
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 4f807fc1b14a..3271d134e8c1 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -276,7 +276,8 @@ const char *event_type(int type)
 static struct perf_evsel *
 __add_event(struct list_head *list, int *idx,
 	    struct perf_event_attr *attr,
-	    char *name, struct cpu_map *cpus)
+	    char *name, struct cpu_map *cpus,
+	    struct list_head *config_terms)
 {
 	struct perf_evsel *evsel;
 
@@ -291,14 +292,19 @@ __add_event(struct list_head *list, int *idx,
 
 	if (name)
 		evsel->name = strdup(name);
+
+	if (config_terms)
+		list_splice(config_terms, &evsel->config_terms);
+
 	list_add_tail(&evsel->node, list);
 	return evsel;
 }
 
 static int add_event(struct list_head *list, int *idx,
-		     struct perf_event_attr *attr, char *name)
+		     struct perf_event_attr *attr, char *name,
+		     struct list_head *config_terms)
 {
-	return __add_event(list, idx, attr, name, NULL) ? 0 : -ENOMEM;
+	return __add_event(list, idx, attr, name, NULL, config_terms) ? 0 : -ENOMEM;
 }
 
 static int parse_aliases(char *str, const char *names[][PERF_EVSEL__MAX_ALIASES], int size)
@@ -377,7 +383,7 @@ int parse_events_add_cache(struct list_head *list, int *idx,
 	memset(&attr, 0, sizeof(attr));
 	attr.config = cache_type | (cache_op << 8) | (cache_result << 16);
 	attr.type = PERF_TYPE_HW_CACHE;
-	return add_event(list, idx, &attr, name);
+	return add_event(list, idx, &attr, name, NULL);
 }
 
 static int add_tracepoint(struct list_head *list, int *idx,
@@ -539,7 +545,7 @@ int parse_events_add_breakpoint(struct list_head *list, int *idx,
 	attr.type = PERF_TYPE_BREAKPOINT;
 	attr.sample_period = 1;
 
-	return add_event(list, idx, &attr, NULL);
+	return add_event(list, idx, &attr, NULL, NULL);
 }
 
 static int check_type_val(struct parse_events_term *term,
@@ -622,22 +628,56 @@ static int config_attr(struct perf_event_attr *attr,
 	return 0;
 }
 
+static int get_config_terms(struct list_head *head_config,
+			    struct list_head *head_terms __maybe_unused)
+{
+#define ADD_CONFIG_TERM(__type, __name, __val)			\
+do {								\
+	struct perf_evsel_config_term *__t;			\
+								\
+	__t = zalloc(sizeof(*__t));				\
+	if (!__t)						\
+		return -ENOMEM;					\
+								\
+	INIT_LIST_HEAD(&__t->list);				\
+	__t->type       = PERF_EVSEL__CONFIG_TERM_ ## __type;	\
+	__t->val.__name = __val;				\
+	list_add_tail(&__t->list, head_terms);			\
+} while (0)
+
+	struct parse_events_term *term;
+
+	list_for_each_entry(term, head_config, list) {
+		switch (term->type_term) {
+		default:
+			break;
+		}
+	}
+#undef ADD_EVSEL_CONFIG
+	return 0;
+}
+
 int parse_events_add_numeric(struct parse_events_evlist *data,
 			     struct list_head *list,
 			     u32 type, u64 config,
 			     struct list_head *head_config)
 {
 	struct perf_event_attr attr;
+	LIST_HEAD(config_terms);
 
 	memset(&attr, 0, sizeof(attr));
 	attr.type = type;
 	attr.config = config;
 
-	if (head_config &&
-	    config_attr(&attr, head_config, data->error))
-		return -EINVAL;
+	if (head_config) {
+		if (config_attr(&attr, head_config, data->error))
+			return -EINVAL;
+
+		if (get_config_terms(head_config, &config_terms))
+			return -ENOMEM;
+	}
 
-	return add_event(list, &data->idx, &attr, NULL);
+	return add_event(list, &data->idx, &attr, NULL, &config_terms);
 }
 
 static int parse_events__is_name_term(struct parse_events_term *term)
@@ -664,6 +704,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
 	struct perf_pmu_info info;
 	struct perf_pmu *pmu;
 	struct perf_evsel *evsel;
+	LIST_HEAD(config_terms);
 
 	pmu = perf_pmu__find(name);
 	if (!pmu)
@@ -678,7 +719,7 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
 
 	if (!head_config) {
 		attr.type = pmu->type;
-		evsel = __add_event(list, &data->idx, &attr, NULL, pmu->cpus);
+		evsel = __add_event(list, &data->idx, &attr, NULL, pmu->cpus, NULL);
 		return evsel ? 0 : -ENOMEM;
 	}
 
@@ -692,11 +733,15 @@ int parse_events_add_pmu(struct parse_events_evlist *data,
 	if (config_attr(&attr, head_config, data->error))
 		return -EINVAL;
 
+	if (get_config_terms(head_config, &config_terms))
+		return -ENOMEM;
+
 	if (perf_pmu__config(pmu, &attr, head_config, data->error))
 		return -EINVAL;
 
 	evsel = __add_event(list, &data->idx, &attr,
-			    pmu_event_name(head_config), pmu->cpus);
+			    pmu_event_name(head_config), pmu->cpus,
+			    &config_terms);
 	if (evsel) {
 		evsel->unit = info.unit;
 		evsel->scale = info.scale;
-- 
2.1.0


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

* [PATCH 08/10] perf tools: Force period term to overload global settings
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (6 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 07/10] perf tools: Add support for event post configuration Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 09/10] perf tools: Introduce callgraph_set for callgraph option Arnaldo Carvalho de Melo
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, Andi Kleen, Kan Liang, Namhyung Kim,
	Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@kernel.org>

Currently the command line option settings beats the per event period
settings:

With no global settings, we get per-event configuration:

  $ perf record -e 'cpu/instructions,period=20000/' sleep 1
  $ perf evlist -v
  ... { sample_period, sample_freq }: 20000 ...

With 'c' option period setup, we get 'c' option value:
  $ perf record -e 'cpu/instructions,period=20000/' -c 1000 sleep 1
  $ perf evlist -v
  ... { sample_period, sample_freq }: 1000 ...

This patch makes the per-event settings overload the global 'c' option
setup:

  $ perf record -e 'cpu/instructions,period=20000/' -c 1000 sleep 1
  $ perf evlist -v
  ... { sample_period, sample_freq }: 20000 ...

I think the making the per-event settings to overload any other config
makes more sense than current state. However it breaks the current
'period' term handling, which might cause some noise.. so let's see ;-).

Also fixing parse event tests with the new behaviour.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1438162936-59698-3-git-send-email-kan.liang@intel.com
Signed-off-by: Kan Liang <kan.liang@intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/Documentation/perf-record.txt |  2 +-
 tools/perf/tests/parse-events.c          | 12 ++++++++++--
 tools/perf/util/evsel.c                  |  2 ++
 tools/perf/util/evsel.h                  |  1 +
 tools/perf/util/parse-events.c           |  3 ++-
 5 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 63ee0408761d..ac41350ca485 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -46,7 +46,7 @@ OPTIONS
           /sys/bus/event_sources/devices/<pmu>/format/*
 
 	  There are also some params which are not defined in .../<pmu>/format/*.
-	  These params can be used to set event defaults.
+	  These params can be used to overload default config values per event.
 	  Here is a list of the params.
 	  - 'period': Set event sampling period
 
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index d76963f7ad3d..f65bb89e109e 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -82,8 +82,12 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
 	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
 	TEST_ASSERT_VAL("wrong config",
 			PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
+	/*
+	 * The period value gets configured within perf_evlist__config,
+	 * while this test executes only parse events method.
+	 */
 	TEST_ASSERT_VAL("wrong period",
-			100000 == evsel->attr.sample_period);
+			0 == evsel->attr.sample_period);
 	TEST_ASSERT_VAL("wrong config1",
 			0 == evsel->attr.config1);
 	TEST_ASSERT_VAL("wrong config2",
@@ -406,7 +410,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist)
 	TEST_ASSERT_VAL("wrong config",    10 == evsel->attr.config);
 	TEST_ASSERT_VAL("wrong config1",    1 == evsel->attr.config1);
 	TEST_ASSERT_VAL("wrong config2",    3 == evsel->attr.config2);
-	TEST_ASSERT_VAL("wrong period",  1000 == evsel->attr.sample_period);
+	/*
+	 * The period value gets configured within perf_evlist__config,
+	 * while this test executes only parse events method.
+	 */
+	TEST_ASSERT_VAL("wrong period",     0 == evsel->attr.sample_period);
 
 	return 0;
 }
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 048d61dde3f6..7d3acba5a512 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -594,6 +594,8 @@ static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
 
 	list_for_each_entry(term, config_terms, list) {
 		switch (term->type) {
+		case PERF_EVSEL__CONFIG_TERM_PERIOD:
+			attr->sample_period = term->val.period;
 		default:
 			break;
 		}
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 033981974fd2..a7d2175358b8 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -38,6 +38,7 @@ struct cgroup_sel;
  * perf_evsel::config_terms list head.
 */
 enum {
+	PERF_EVSEL__CONFIG_TERM_PERIOD,
 	PERF_EVSEL__CONFIG_TERM_MAX,
 };
 
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 3271d134e8c1..09bee93fd0ec 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -596,7 +596,6 @@ do {									   \
 		break;
 	case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
 		CHECK_TYPE_VAL(NUM);
-		attr->sample_period = term->val.num;
 		break;
 	case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
 		/*
@@ -649,6 +648,8 @@ do {								\
 
 	list_for_each_entry(term, head_config, list) {
 		switch (term->type_term) {
+		case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
+			ADD_CONFIG_TERM(PERIOD, period, term->val.num);
 		default:
 			break;
 		}
-- 
2.1.0


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

* [PATCH 09/10] perf tools: Introduce callgraph_set for callgraph option
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (7 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 08/10] perf tools: Force period term to overload global settings Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-30 16:17 ` [PATCH 10/10] perf tests: Adding build test for having ending double slash Arnaldo Carvalho de Melo
  2015-07-31  8:04 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Kan Liang, Andi Kleen, Jiri Olsa, Namhyung Kim,
	Arnaldo Carvalho de Melo

From: Kan Liang <kan.liang@intel.com>

Introduce callgraph_set to indicate whether the callgraph option was set
by user.

Signed-off-by: Kan Liang <kan.liang@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1438162936-59698-4-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-record.c | 9 +++++++--
 tools/perf/perf.h           | 1 +
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 445a64d19625..f51131b11ad7 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -762,12 +762,14 @@ static void callchain_debug(void)
 			 callchain_param.dump_size);
 }
 
-int record_parse_callchain_opt(const struct option *opt __maybe_unused,
+int record_parse_callchain_opt(const struct option *opt,
 			       const char *arg,
 			       int unset)
 {
 	int ret;
+	struct record_opts *record = (struct record_opts *)opt->value;
 
+	record->callgraph_set = true;
 	callchain_param.enabled = !unset;
 
 	/* --no-call-graph */
@@ -784,10 +786,13 @@ int record_parse_callchain_opt(const struct option *opt __maybe_unused,
 	return ret;
 }
 
-int record_callchain_opt(const struct option *opt __maybe_unused,
+int record_callchain_opt(const struct option *opt,
 			 const char *arg __maybe_unused,
 			 int unset __maybe_unused)
 {
+	struct record_opts *record = (struct record_opts *)opt->value;
+
+	record->callgraph_set = true;
 	callchain_param.enabled = true;
 
 	if (callchain_param.record_mode == CALLCHAIN_NONE)
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index cf459f89fc9b..cccb4cf575d3 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -52,6 +52,7 @@ struct record_opts {
 	bool	     sample_weight;
 	bool	     sample_time;
 	bool	     sample_time_set;
+	bool	     callgraph_set;
 	bool	     period;
 	bool	     sample_intr_regs;
 	bool	     running_time;
-- 
2.1.0


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

* [PATCH 10/10] perf tests: Adding build test for having ending double slash
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (8 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 09/10] perf tools: Introduce callgraph_set for callgraph option Arnaldo Carvalho de Melo
@ 2015-07-30 16:17 ` Arnaldo Carvalho de Melo
  2015-07-31  8:04 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar
  10 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-30 16:17 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Jiri Olsa, Jiri Olsa, Adrian Hunter, Namhyung Kim,
	Peter Zijlstra, Arnaldo Carvalho de Melo

From: Jiri Olsa <jolsa@redhat.com>

Pawel Moll reported build issue for having extra slash (/) at the end of
the prefix variable.

  $ make prefix=/usr/local/

    CC       tests/attr.o
  tests/attr.c: In function ‘test__attr’:
  tests/attr.c:168:50: error: expected ‘)’ before ‘;’ token
    snprintf(path_perf, PATH_MAX, "%s/perf", BINDIR);
                                                ^
  tests/attr.c:176:1: error: expected ‘;’ before ‘}’ token
   }
   ^
  tests/attr.c:176:1: error: control reaches end of non-void function [-Werror=return-type]
   }
   ^
  cc1: all warnings being treated as errors

Adding automated test case for this.

Reported-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/20150727182417.GD20509@krava.brq.redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/tests/make | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/make b/tools/perf/tests/make
index 729112f4cfaa..ba31c4bd441d 100644
--- a/tools/perf/tests/make
+++ b/tools/perf/tests/make
@@ -58,7 +58,8 @@ make_install_man    := install-man
 make_install_html   := install-html
 make_install_info   := install-info
 make_install_pdf    := install-pdf
-make_install_prefix := install prefix=/tmp/krava
+make_install_prefix       := install prefix=/tmp/krava
+make_install_prefix_slash := install prefix=/tmp/krava/
 make_static         := LDFLAGS=-static
 
 # all the NO_* variable combined
@@ -101,6 +102,7 @@ run += make_util_pmu_bison_o
 run += make_install
 run += make_install_bin
 run += make_install_prefix
+run += make_install_prefix_slash
 # FIXME 'install-*' commented out till they're fixed
 # run += make_install_doc
 # run += make_install_man
@@ -175,11 +177,14 @@ test_make_install_O     := $(call test_dest_files,$(installed_files_all))
 test_make_install_bin   := $(call test_dest_files,$(installed_files_bin))
 test_make_install_bin_O := $(call test_dest_files,$(installed_files_bin))
 
-# We prefix all installed files for make_install_prefix
+# We prefix all installed files for make_install_prefix(_slash)
 # with '/tmp/krava' to match installed/prefix-ed files.
 installed_files_all_prefix := $(addprefix /tmp/krava/,$(installed_files_all))
-test_make_install_prefix   := $(call test_dest_files,$(installed_files_all_prefix))
-test_make_install_prefix_O := $(call test_dest_files,$(installed_files_all_prefix))
+test_make_install_prefix   :=  $(call test_dest_files,$(installed_files_all_prefix))
+test_make_install_prefix_O :=  $(call test_dest_files,$(installed_files_all_prefix))
+
+test_make_install_prefix_slash   := $(test_make_install_prefix)
+test_make_install_prefix_slash_O := $(test_make_install_prefix_O)
 
 # FIXME nothing gets installed
 test_make_install_man    := test -f $$TMP_DEST/share/man/man1/perf.1
-- 
2.1.0


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

* Re: [GIT PULL 00/10] perf/core improvements and fixes
  2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
                   ` (9 preceding siblings ...)
  2015-07-30 16:17 ` [PATCH 10/10] perf tests: Adding build test for having ending double slash Arnaldo Carvalho de Melo
@ 2015-07-31  8:04 ` Ingo Molnar
  2015-07-31 13:30   ` Arnaldo Carvalho de Melo
  10 siblings, 1 reply; 13+ messages in thread
From: Ingo Molnar @ 2015-07-31  8:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: linux-kernel, Adrian Hunter, Andi Kleen, Borislav Petkov,
	David Ahern, Frederic Weisbecker, Jaroslav Skarvada, Jeremy Eder,
	Jiri Olsa, Kan Liang, Luiz Fernando Capitulino, Namhyung Kim,
	Pawel Moll, Peter Zijlstra, Stephane Eranian


* Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> Hi Ingo,
> 
> 	Please consider pulling,
> 
> - Arnaldo
> 
> The following changes since commit 4b0c53e9e1a2a785746b2d379a32cb70b4dbb2fd:
> 
>   Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core (2015-07-27 17:56:18 +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 aa53c09e90a19c215549bd1ca970fddcb7c0c001:

Hm, your pull request mail was cut short as it ends here abruptly. I figured it 
out nevertheless, from the commit log:

====================>

User visible changes:

  - Force period term to overload global settings, i.e. previously this
    command line:

     $ perf record -e 'cpu/instructions,period=20000/',cycles -c 1000 sleep 1

    would result in both events having a period equal to 1000, with the fix we
    get something saner:

     $ perf evlist -v | grep period
     cpu/instructions,period=20000/: ... { sample_period, sample_freq }: 20000, ...
     cycles: ... { sample_period, sample_freq }: 1000 ...
     $

   (Jiri Olsa)

Infrastructure changes:

  - Use the dummy software event with freq=0 in the twatch.py python
    binding example, to avoid disabling nohz. (Arnaldo Carvalho de Melo)

  - Add some missing constants to the python binding. (Arnaldo Carvalho de Melo)

  - Fix mismatched declarations for elf_getphdrnum, that happens
    only in the corner case where this function is not found on
    the system.  (Arnaldo Carvalho de Melo)

  - Add build test for having ending double slash. (Jiri Olsa)

  - Introduce callgraph_set for callgraph option. (Kan Liang)

 tools/perf/Documentation/perf-record.txt |   2 +-
 tools/perf/builtin-record.c              |   9 +-
 tools/perf/builtin-trace.c               |   2 +-
 tools/perf/perf.h                        |   1 +
 tools/perf/python/twatch.py              |  12 ++-
 tools/perf/tests/make                    |  13 ++-
 tools/perf/tests/parse-events.c          |  12 ++-
 tools/perf/util/evsel.c                  |  33 ++++++++
 tools/perf/util/evsel.h                  |  20 +++++
 tools/perf/util/parse-events.c           |  70 +++++++++++++---
 tools/perf/util/python.c                 | 140 ++++++++++++++++---------------
 tools/perf/util/session.c                |   4 +-
 tools/perf/util/symbol-elf.c             |   2 +-
 tools/perf/util/trace-event.c            |   7 +-
 tools/perf/util/trace-event.h            |   3 +-
 15 files changed, 233 insertions(+), 97 deletions(-)

<================

Pulled, thanks a lot Arnaldo!

	Ingo

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

* Re: [GIT PULL 00/10] perf/core improvements and fixes
  2015-07-31  8:04 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar
@ 2015-07-31 13:30   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2015-07-31 13:30 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: linux-kernel, Adrian Hunter, Andi Kleen, Borislav Petkov,
	David Ahern, Frederic Weisbecker, Jaroslav Skarvada, Jeremy Eder,
	Jiri Olsa, Kan Liang, Luiz Fernando Capitulino, Namhyung Kim,
	Pawel Moll, Peter Zijlstra, Stephane Eranian

Em Fri, Jul 31, 2015 at 10:04:35AM +0200, Ingo Molnar escreveu:
> * Arnaldo Carvalho de Melo <acme@kernel.org> wrote:
> > 	Please consider pulling,

> > for you to fetch changes up to aa53c09e90a19c215549bd1ca970fddcb7c0c001:
> 
> Hm, your pull request mail was cut short as it ends here abruptly. I figured it 
> out nevertheless, from the commit log:

Right, I forgot the 'git request-pull' part after pushing the signed tag
:-\

Thanks!

- Arnaldo
 
> ====================>
> 
> User visible changes:
> 
>   - Force period term to overload global settings, i.e. previously this
>     command line:
> 
>      $ perf record -e 'cpu/instructions,period=20000/',cycles -c 1000 sleep 1
> 
>     would result in both events having a period equal to 1000, with the fix we
>     get something saner:
> 
>      $ perf evlist -v | grep period
>      cpu/instructions,period=20000/: ... { sample_period, sample_freq }: 20000, ...
>      cycles: ... { sample_period, sample_freq }: 1000 ...
>      $
> 
>    (Jiri Olsa)
> 
> Infrastructure changes:
> 
>   - Use the dummy software event with freq=0 in the twatch.py python
>     binding example, to avoid disabling nohz. (Arnaldo Carvalho de Melo)
> 
>   - Add some missing constants to the python binding. (Arnaldo Carvalho de Melo)
> 
>   - Fix mismatched declarations for elf_getphdrnum, that happens
>     only in the corner case where this function is not found on
>     the system.  (Arnaldo Carvalho de Melo)
> 
>   - Add build test for having ending double slash. (Jiri Olsa)
> 
>   - Introduce callgraph_set for callgraph option. (Kan Liang)
> 
>  tools/perf/Documentation/perf-record.txt |   2 +-
>  tools/perf/builtin-record.c              |   9 +-
>  tools/perf/builtin-trace.c               |   2 +-
>  tools/perf/perf.h                        |   1 +
>  tools/perf/python/twatch.py              |  12 ++-
>  tools/perf/tests/make                    |  13 ++-
>  tools/perf/tests/parse-events.c          |  12 ++-
>  tools/perf/util/evsel.c                  |  33 ++++++++
>  tools/perf/util/evsel.h                  |  20 +++++
>  tools/perf/util/parse-events.c           |  70 +++++++++++++---
>  tools/perf/util/python.c                 | 140 ++++++++++++++++---------------
>  tools/perf/util/session.c                |   4 +-
>  tools/perf/util/symbol-elf.c             |   2 +-
>  tools/perf/util/trace-event.c            |   7 +-
>  tools/perf/util/trace-event.h            |   3 +-
>  15 files changed, 233 insertions(+), 97 deletions(-)
> 
> <================
> 
> Pulled, thanks a lot Arnaldo!
> 
> 	Ingo
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2015-07-31 13:30 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-30 16:16 [GIT PULL 00/10] perf/core improvements and fixes Arnaldo Carvalho de Melo
2015-07-30 16:16 ` [PATCH 01/10] perf python: Remove dependency on 'machine' methods Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 02/10] perf python: Add macro to simplify maintainance of the constants array Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 03/10] perf python: Add missing PERF_RECORD_{MMAP2,AUX,etc} Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 04/10] perf python: Make twatch.py use soft dummy event, freq=0 Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 05/10] perf symbols: Fix mismatched declarations for elf_getphdrnum Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 06/10] perf session env: Rename exit method Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 07/10] perf tools: Add support for event post configuration Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 08/10] perf tools: Force period term to overload global settings Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 09/10] perf tools: Introduce callgraph_set for callgraph option Arnaldo Carvalho de Melo
2015-07-30 16:17 ` [PATCH 10/10] perf tests: Adding build test for having ending double slash Arnaldo Carvalho de Melo
2015-07-31  8:04 ` [GIT PULL 00/10] perf/core improvements and fixes Ingo Molnar
2015-07-31 13:30   ` Arnaldo Carvalho de Melo

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).