[PATCHv4 0/8] perf, tool: Allow to use hw events in PMU syntax
hi, here's the change to make following syntax available: perf stat -e cpu/event=instructions/u ls perf stat -e cpu/cycles/u ls this is identical to: perf stat -e instructions:u ls perf stat -e cycles:u ls v4 changes: - kernel change is now structured differently allowing to pick up cpu differences - added support for intel/p6/amd PMUs - intel and amd tested, did not get p6 server, but should be ok.. feel free to omit Attached patches: 1/8 perf x86: Making hardware events translations available in sysfs 2/8 perf x86: Filter out undefined events from sysfs events attribute 3/8 perf x86: Adding hardware events translations for intel cpus 4/8 perf x86: Adding hardware events translations for amd cpus 5/8 perf x86: Adding hardware events translations for p6 cpus 6/8 perf tools: Fix pmu object alias initialization 7/8 perf tools: Add support to specify hw event as pmu event term 8/8 perf test: Add automated tests for pmu sysfs translated events jirka Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event.c | 121 + arch/x86/kernel/cpu/perf_event.h | 2 ++ arch/x86/kernel/cpu/perf_event_amd.c | 9 +++ arch/x86/kernel/cpu/perf_event_intel.c | 9 +++ arch/x86/kernel/cpu/perf_event_p6.c| 2 ++ include/linux/perf_event.h | 3 +++ tools/perf/util/parse-events-test.c| 68 ++ tools/perf/util/parse-events.c | 18 ++ tools/perf/util/parse-events.h | 2 ++ tools/perf/util/parse-events.y | 18 ++ tools/perf/util/pmu.c | 7 +++--- 11 files changed, 256 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/8] perf x86: Adding hardware events translations for amd cpus
Adding support for amd processors to display 'events' sysfs directory (/sys/devices/cpu/events/) with hw event translations. # ls /sys/devices/cpu/events/ branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions ref-cycles stalled-cycles-backend stalled-cycles-frontend Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event.c | 3 +-- arch/x86/kernel/cpu/perf_event_amd.c | 9 + arch/x86/kernel/cpu/perf_event_intel.c | 11 +-- include/linux/perf_event.h | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 1fbf319..476dab0 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1384,9 +1384,8 @@ static struct attribute_group x86_pmu_events_group = { .attrs = events_attr, }; -ssize_t x86_event_sysfs_show(char *page, u64 config) +ssize_t x86_event_sysfs_show(char *page, u64 config, u64 event) { - u64 event = (config ARCH_PERFMON_EVENTSEL_EVENT); u64 umask = (config ARCH_PERFMON_EVENTSEL_UMASK) 8; u64 cmask = (config ARCH_PERFMON_EVENTSEL_CMASK) 24; bool edge = (config ARCH_PERFMON_EVENTSEL_EDGE); diff --git a/arch/x86/kernel/cpu/perf_event_amd.c b/arch/x86/kernel/cpu/perf_event_amd.c index 4528ae7..c93bc4e 100644 --- a/arch/x86/kernel/cpu/perf_event_amd.c +++ b/arch/x86/kernel/cpu/perf_event_amd.c @@ -568,6 +568,14 @@ amd_get_event_constraints_f15h(struct cpu_hw_events *cpuc, struct perf_event *ev } } +static ssize_t amd_event_sysfs_show(char *page, u64 config) +{ + u64 event = (config ARCH_PERFMON_EVENTSEL_EVENT) | + (config AMD64_EVENTSEL_EVENT) 24; + + return x86_event_sysfs_show(page, config, event); +} + static __initconst const struct x86_pmu amd_pmu = { .name = AMD, .handle_irq = x86_pmu_handle_irq, @@ -591,6 +599,7 @@ static __initconst const struct x86_pmu amd_pmu = { .put_event_constraints = amd_put_event_constraints, .format_attrs = amd_format_attr, + .events_sysfs_show = amd_event_sysfs_show, .cpu_prepare= amd_pmu_cpu_prepare, .cpu_starting = amd_pmu_cpu_starting, diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index f711ca2..fe50274 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c @@ -1603,6 +1603,13 @@ static struct attribute *intel_arch_formats_attr[] = { NULL, }; +ssize_t intel_event_sysfs_show(char *page, u64 config) +{ + u64 event = (config ARCH_PERFMON_EVENTSEL_EVENT); + + return x86_event_sysfs_show(page, config, event); +} + static __initconst const struct x86_pmu core_pmu = { .name = core, .handle_irq = x86_pmu_handle_irq, @@ -1628,7 +1635,7 @@ static __initconst const struct x86_pmu core_pmu = { .event_constraints = intel_core_event_constraints, .guest_get_msrs = core_guest_get_msrs, .format_attrs = intel_arch_formats_attr, - .events_sysfs_show = x86_event_sysfs_show, + .events_sysfs_show = intel_event_sysfs_show, }; struct intel_shared_regs *allocate_shared_regs(int cpu) @@ -1767,7 +1774,7 @@ static __initconst const struct x86_pmu intel_pmu = { .pebs_aliases = intel_pebs_aliases_core2, .format_attrs = intel_arch3_formats_attr, - .events_sysfs_show = x86_event_sysfs_show, + .events_sysfs_show = intel_event_sysfs_show, .cpu_prepare= intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index ee9c9d0..827c374 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1418,7 +1418,7 @@ _name##_show(struct device *dev, \ \ static struct device_attribute format_attr_##_name = __ATTR_RO(_name) -ssize_t x86_event_sysfs_show(char *page, u64 config); +ssize_t x86_event_sysfs_show(char *page, u64 config, u64 event); #endif /* __KERNEL__ */ #endif /* _LINUX_PERF_EVENT_H */ -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http
[PATCH 6/8] perf tools: Fix pmu object alias initialization
The pmu_lookup should return pmus that do not expose the 'events' group attribute in sysfs. Also it should fail when any other error during 'events' lookup is hit (pmu_aliases fails). Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- tools/perf/util/pmu.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 8a2229d..18e8480 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -164,7 +164,7 @@ static int pmu_aliases(char *name, struct list_head *head) %s/bus/event_source/devices/%s/events, sysfs, name); if (stat(path, st) 0) - return -1; + return 0;/* no error if 'events' does not exist */ if (pmu_aliases_parse(path, head)) return -1; @@ -296,6 +296,9 @@ static struct perf_pmu *pmu_lookup(char *name) if (pmu_format(name, format)) return NULL; + if (pmu_aliases(name, aliases)) + return NULL; + if (pmu_type(name, type)) return NULL; @@ -305,8 +308,6 @@ static struct perf_pmu *pmu_lookup(char *name) pmu-cpus = pmu_cpumask(name); - pmu_aliases(name, aliases); - INIT_LIST_HEAD(pmu-format); INIT_LIST_HEAD(pmu-aliases); list_splice(format, pmu-format); -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 7/8] perf tools: Add support to specify hw event as pmu event term
Adding a way to specify hw event as pmu event term like: 'cpu/event=cpu-cycles/u' 'cpu/event=instructions,.../u' 'cpu/cycles,.../u' The 'event=cpu-cycles' term is replaced/translated by the hw events term translation, which is exposed by sysfs 'events' group attribute. Adding parser bits, the rest is already handled by the pmu alias code. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- tools/perf/util/parse-events.c | 18 ++ tools/perf/util/parse-events.h | 2 ++ tools/perf/util/parse-events.y | 18 ++ 3 files changed, 38 insertions(+) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index aed38e4..5ce6f8c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1139,6 +1139,24 @@ int parse_events__term_str(struct parse_events__term **term, config, str, 0); } +int parse_events__term_sym_hw(struct parse_events__term **term, + char *config, unsigned idx) +{ + struct event_symbol *sym; + + BUG_ON(idx = PERF_COUNT_HW_MAX); + sym = event_symbols_hw[idx]; + + if (config) + return new_term(term, PARSE_EVENTS__TERM_TYPE_STR, + PARSE_EVENTS__TERM_TYPE_USER, config, + (char *) sym-symbol, 0); + else + return new_term(term, PARSE_EVENTS__TERM_TYPE_STR, + PARSE_EVENTS__TERM_TYPE_USER, + (char *) event, (char *) sym-symbol, 0); +} + int parse_events__term_clone(struct parse_events__term **new, struct parse_events__term *term) { diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index c356e44..6b1e841 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -76,6 +76,8 @@ int parse_events__term_num(struct parse_events__term **_term, int type_term, char *config, u64 num); int parse_events__term_str(struct parse_events__term **_term, int type_term, char *config, char *str); +int parse_events__term_sym_hw(struct parse_events__term **term, + char *config, unsigned idx); int parse_events__term_clone(struct parse_events__term **new, struct parse_events__term *term); void parse_events__free_terms(struct list_head *terms); diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index cd88209..0f9914a 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -352,6 +352,15 @@ PE_NAME '=' PE_VALUE $$ = term; } | +PE_NAME '=' PE_VALUE_SYM_HW +{ + struct parse_events__term *term; + int config = $3 255; + + ABORT_ON(parse_events__term_sym_hw(term, $1, config)); + $$ = term; +} +| PE_NAME { struct parse_events__term *term; @@ -361,6 +370,15 @@ PE_NAME $$ = term; } | +PE_VALUE_SYM_HW +{ + struct parse_events__term *term; + int config = $1 255; + + ABORT_ON(parse_events__term_sym_hw(term, NULL, config)); + $$ = term; +} +| PE_TERM '=' PE_NAME { struct parse_events__term *term; -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 8/8] perf test: Add automated tests for pmu sysfs translated events
Adding automated tests for all events found under PMU/events directory. Tested events are in 'cpu/event=xxx/u' format, where 'xxx' is substituted by every event found. The 'event=xxx' term is translated to the cpu specific term. We only check that the event is created (not the real config numbers) and that modifier is properly set. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- tools/perf/util/parse-events-test.c | 68 + 1 file changed, 68 insertions(+) diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index d7244e5..c9354b6 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c @@ -443,6 +443,23 @@ static int test__checkevent_pmu_name(struct perf_evlist *evlist) return 0; } +static int test__checkevent_pmu_events(struct perf_evlist *evlist) +{ + struct perf_evsel *evsel; + + evsel = list_entry(evlist-entries.next, struct perf_evsel, node); + TEST_ASSERT_VAL(wrong number of entries, 1 == evlist-nr_entries); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_RAW == evsel-attr.type); + TEST_ASSERT_VAL(wrong exclude_user, + !evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, + evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip); + + return 0; +} + static int test__checkterms_simple(struct list_head *terms) { struct parse_events__term *term; @@ -1020,6 +1037,51 @@ static int test_pmu(void) return !ret; } +static int test_pmu_events(void) +{ + struct stat st; + char path[PATH_MAX]; + struct dirent *ent; + DIR *dir; + int ret; + + snprintf(path, PATH_MAX, %s/bus/event_source/devices/cpu/events/, +sysfs_find_mountpoint()); + + ret = stat(path, st); + if (ret) { + pr_debug(ommiting PMU cpu events tests\n); + return 0; + } + + dir = opendir(path); + if (!dir) { + pr_debug(can't open pmu event dir); + return -1; + } + + while (!ret (ent = readdir(dir))) { +#define MAX_NAME 100 + struct test__event_st e; + char name[MAX_NAME]; + + if (!strcmp(ent-d_name, .) || + !strcmp(ent-d_name, ..)) + continue; + + snprintf(name, MAX_NAME, cpu/event=%s/u, ent-d_name); + + e.name = name; + e.check = test__checkevent_pmu_events; + + ret = test_event(e); +#undef MAX_NAME + } + + closedir(dir); + return ret; +} + int parse_events__test(void) { int ret1, ret2 = 0; @@ -1036,6 +1098,12 @@ do { \ if (test_pmu()) TEST_EVENTS(test__events_pmu); + if (test_pmu()) { + int ret = test_pmu_events(); + if (ret) + return ret; + } + ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms)); if (!ret2) ret2 = ret1; -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/8] perf x86: Adding hardware events translations for p6 cpus
Adding support for p6 processors to display 'events' sysfs directory (/sys/devices/cpu/events/) with hw event translations. # ls /sys/devices/cpu/events/ branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions ref-cycles stalled-cycles-backend stalled-cycles-frontend Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event_p6.c | 2 ++ include/linux/perf_event.h | 1 + 2 files changed, 3 insertions(+) diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c index e4dd0f7..900b76b 100644 --- a/arch/x86/kernel/cpu/perf_event_p6.c +++ b/arch/x86/kernel/cpu/perf_event_p6.c @@ -134,6 +134,8 @@ static __initconst const struct x86_pmu p6_pmu = { .event_constraints = p6_event_constraints, .format_attrs = intel_p6_formats_attr, + .events_sysfs_show = intel_event_sysfs_show, + }; __init int p6_pmu_init(void) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 827c374..6e48be0 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1419,6 +1419,7 @@ _name##_show(struct device *dev, \ static struct device_attribute format_attr_##_name = __ATTR_RO(_name) ssize_t x86_event_sysfs_show(char *page, u64 config, u64 event); +ssize_t intel_event_sysfs_show(char *page, u64 config); #endif /* __KERNEL__ */ #endif /* _LINUX_PERF_EVENT_H */ -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/8] perf x86: Adding hardware events translations for intel cpus
Adding support for intel processors to display 'events' sysfs directory (/sys/devices/cpu/events/) with hw event translations. # ls /sys/devices/cpu/events/ branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions ref-cycles stalled-cycles-backend stalled-cycles-frontend Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event.c | 40 ++ arch/x86/kernel/cpu/perf_event_intel.c | 2 ++ include/linux/perf_event.h | 2 ++ 3 files changed, 44 insertions(+) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 9b6f83c..1fbf319 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1384,6 +1384,46 @@ static struct attribute_group x86_pmu_events_group = { .attrs = events_attr, }; +ssize_t x86_event_sysfs_show(char *page, u64 config) +{ + u64 event = (config ARCH_PERFMON_EVENTSEL_EVENT); + u64 umask = (config ARCH_PERFMON_EVENTSEL_UMASK) 8; + u64 cmask = (config ARCH_PERFMON_EVENTSEL_CMASK) 24; + bool edge = (config ARCH_PERFMON_EVENTSEL_EDGE); + bool pc= (config ARCH_PERFMON_EVENTSEL_PIN_CONTROL); + bool any = (config ARCH_PERFMON_EVENTSEL_ANY); + bool inv = (config ARCH_PERFMON_EVENTSEL_INV); + ssize_t ret; + + /* + * We have whole page size to spend and just little data + * to write, so we can safely use sprintf. + */ + ret = sprintf(page, event=0x%02llx, event); + + if (umask) + ret += sprintf(page + ret, ,umask=0x%02llx, umask); + + if (edge) + ret += sprintf(page + ret, ,edge); + + if (pc) + ret += sprintf(page + ret, ,pc); + + if (any) + ret += sprintf(page + ret, ,any); + + if (inv) + ret += sprintf(page + ret, ,inv); + + if (cmask) + ret += sprintf(page + ret, ,cmask=0x%02llx, cmask); + + ret += sprintf(page + ret, \n); + + return ret; +} + static int __init init_hw_perf_events(void) { struct x86_pmu_quirk *quirk; diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index 7f2739e..f711ca2 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c @@ -1628,6 +1628,7 @@ static __initconst const struct x86_pmu core_pmu = { .event_constraints = intel_core_event_constraints, .guest_get_msrs = core_guest_get_msrs, .format_attrs = intel_arch_formats_attr, + .events_sysfs_show = x86_event_sysfs_show, }; struct intel_shared_regs *allocate_shared_regs(int cpu) @@ -1766,6 +1767,7 @@ static __initconst const struct x86_pmu intel_pmu = { .pebs_aliases = intel_pebs_aliases_core2, .format_attrs = intel_arch3_formats_attr, + .events_sysfs_show = x86_event_sysfs_show, .cpu_prepare= intel_pmu_cpu_prepare, .cpu_starting = intel_pmu_cpu_starting, diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 28f9cee..ee9c9d0 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1418,5 +1418,7 @@ _name##_show(struct device *dev, \ \ static struct device_attribute format_attr_##_name = __ATTR_RO(_name) +ssize_t x86_event_sysfs_show(char *page, u64 config); + #endif /* __KERNEL__ */ #endif /* _LINUX_PERF_EVENT_H */ -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/8] perf x86: Making hardware events translations available in sysfs
Adding support to display hardware events translations available through the sysfs. Adding 'events' group attribute under the sysfs x86 PMU record with attribute/file for each hardware event. This patch adds only backbone for PMUs to display config under 'events' directory. The specific PMU support itself will come in next patches, however this is how the sysfs group will look like: # ls /sys/devices/cpu/events/ branch-instructions branch-misses bus-cycles cache-misses cache-references cpu-cycles instructions ref-cycles stalled-cycles-backend stalled-cycles-frontend The file - hw event ID mappings is: file hw event ID --- cpu-cyclesPERF_COUNT_HW_CPU_CYCLES instructions PERF_COUNT_HW_INSTRUCTIONS cache-references PERF_COUNT_HW_CACHE_REFERENCES cache-misses PERF_COUNT_HW_CACHE_MISSES branch-instructions PERF_COUNT_HW_BRANCH_INSTRUCTIONS branch-misses PERF_COUNT_HW_BRANCH_MISSES bus-cyclesPERF_COUNT_HW_BUS_CYCLES stalled-cycles-frontend PERF_COUNT_HW_STALLED_CYCLES_FRONTEND stalled-cycles-backendPERF_COUNT_HW_STALLED_CYCLES_BACKEND ref-cyclesPERF_COUNT_HW_REF_CPU_CYCLES Each file in 'events' directory contains term translation for the symbolic hw event for the currently running cpu model. # cat /sys/devices/cpu/events/stalled-cycles-backend event=0xb1,umask=0x01,inv,cmask=0x01 Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event.c | 60 arch/x86/kernel/cpu/perf_event.h | 2 ++ 2 files changed, 62 insertions(+) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 915b876..bff2eaa 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1308,6 +1308,62 @@ static struct attribute_group x86_pmu_format_group = { .attrs = NULL, }; +struct perf_pmu_events_attr { + struct device_attribute attr; + u64 id; +}; + +ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, + char *page) +{ + struct perf_pmu_events_attr *pmu_attr = \ + container_of(attr, struct perf_pmu_events_attr, attr); + + u64 config = x86_pmu.event_map(pmu_attr-id); + return x86_pmu.events_sysfs_show(page, config); +} + +#define EVENT_VAR(_id) event_attr_##_id +#define EVENT_PTR(_id) event_attr_##_id.attr.attr + +#define EVENT_ATTR(_name, _id) \ +static struct perf_pmu_events_attr EVENT_VAR(_id) = { \ + .attr = __ATTR(_name, 0444, events_sysfs_show, NULL), \ + .id = PERF_COUNT_HW_##_id, \ +}; + +EVENT_ATTR(cpu-cycles, CPU_CYCLES ); +EVENT_ATTR(instructions, INSTRUCTIONS); +EVENT_ATTR(cache-references, CACHE_REFERENCES); +EVENT_ATTR(cache-misses, CACHE_MISSES); +EVENT_ATTR(branch-instructions,BRANCH_INSTRUCTIONS ); +EVENT_ATTR(branch-misses, BRANCH_MISSES ); +EVENT_ATTR(bus-cycles, BUS_CYCLES ); +EVENT_ATTR(stalled-cycles-frontend,STALLED_CYCLES_FRONTEND ); +EVENT_ATTR(stalled-cycles-backend, STALLED_CYCLES_BACKEND ); +EVENT_ATTR(ref-cycles, REF_CPU_CYCLES ); + +static struct attribute *empty_attrs; + +struct attribute *events_attr[] = { + EVENT_PTR(CPU_CYCLES), + EVENT_PTR(INSTRUCTIONS), + EVENT_PTR(CACHE_REFERENCES), + EVENT_PTR(CACHE_MISSES), + EVENT_PTR(BRANCH_INSTRUCTIONS), + EVENT_PTR(BRANCH_MISSES), + EVENT_PTR(BUS_CYCLES), + EVENT_PTR(STALLED_CYCLES_FRONTEND), + EVENT_PTR(STALLED_CYCLES_BACKEND), + EVENT_PTR(REF_CPU_CYCLES), + NULL, +}; + +static struct attribute_group x86_pmu_events_group = { + .name = events, + .attrs = events_attr, +}; + static int __init init_hw_perf_events(void) { struct x86_pmu_quirk *quirk; @@ -1354,6 +1410,9 @@ static int __init init_hw_perf_events(void) x86_pmu.attr_rdpmc = 1; /* enable userspace RDPMC usage by default */ x86_pmu_format_group.attrs = x86_pmu.format_attrs; + if (!x86_pmu.events_sysfs_show) + x86_pmu_events_group.attrs = empty_attrs; + pr_info(... version:%d\n, x86_pmu.version); pr_info(... bit width: %d\n, x86_pmu.cntval_bits
[PATCH 2/8] perf x86: Filter out undefined events from sysfs events attribute
The sysfs events group attribute currently shows all hw events, including also undefined ones. This patch filters out all undefined events out of the sysfs events group attribute, so they don't even show up. Suggested-by: Peter Zijlstra a.p.zijls...@chello.nl Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Stephane Eranian eran...@google.com --- arch/x86/kernel/cpu/perf_event.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index bff2eaa..9b6f83c 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c @@ -1313,6 +1313,26 @@ struct perf_pmu_events_attr { u64 id; }; +/* + * Remove all undefined events (x86_pmu.event_map(id) == 0) + * out of events_attr attributes. + */ +static void __init filter_events(struct attribute **attrs) +{ + int i, j; + + for (i = 0; attrs[i]; i++) { + if (x86_pmu.event_map(i)) + continue; + + for (j = i; attrs[j]; j++) + attrs[j] = attrs[j + 1]; + + /* Check the shifted attr. */ + i--; + } +} + ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page) { @@ -1412,6 +1432,8 @@ static int __init init_hw_perf_events(void) if (!x86_pmu.events_sysfs_show) x86_pmu_events_group.attrs = empty_attrs; + else + filter_events(x86_pmu_events_group.attrs); pr_info(... version:%d\n, x86_pmu.version); pr_info(... bit width: %d\n, x86_pmu.cntval_bits); -- 1.7.11.4 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv4 0/8] perf, tool: Allow to use hw events in PMU syntax
On Wed, Oct 10, 2012 at 03:34:53PM +0200, Stephane Eranian wrote: On Wed, Oct 10, 2012 at 2:53 PM, Jiri Olsa jo...@redhat.com wrote: hi, here's the change to make following syntax available: perf stat -e cpu/event=instructions/u ls perf stat -e cpu/cycles/u ls Unless, I am mistaken but I did not see in your patch where you adjust the list of generic Hw events (and encodings) you expose via sysfs based on CPU model number. Some generic HW PMU may not have actual physical mappings. Look at IvyBridge, for instance. hm, path 2 remove any attribute that is not defined via x86_pmu.event_map, if that's what you mean.. jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/8] perf x86: Adding hardware events translations for amd cpus
On Wed, Oct 10, 2012 at 04:11:42PM +0200, Peter Zijlstra wrote: On Wed, 2012-10-10 at 14:53 +0200, Jiri Olsa wrote: +static ssize_t amd_event_sysfs_show(char *page, u64 config) +{ + u64 event = (config ARCH_PERFMON_EVENTSEL_EVENT) | + (config AMD64_EVENTSEL_EVENT) 24; + + return x86_event_sysfs_show(page, config, event); +} You'll need to filter out 0xF32 bits before passing them on in @config, Intel has a different meaning for them. Right, that would be those 'intx and intx_cp' bits we discussed, right? My thinking was to customize this once those bits are introduced and part of the format stuff. Until that time the x86_event_sysfs_show function shows proper data for both amd and intel. Or is it already on its way in? jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 00/11] perf tool: Add PERF_SAMPLE_READ sample read support
On Fri, Oct 26, 2012 at 11:14:45AM +0200, Peter Zijlstra wrote: On Fri, 2012-10-26 at 10:29 +0900, Namhyung Kim wrote: Hi Jiri, On Sat, 20 Oct 2012 16:33:08 +0200, Jiri Olsa wrote: hi, adding support to read sample values through the PERF_SAMPLE_READ sample type. It's now possible to specify 'S' modifier for an event and get its sample value by PERF_SAMPLE_READ. I have a question. What's an actual impact of specifying 'S' modifiere to a non-group event or even only a (non-leader) member of a group? For instance, 'cycles:S' or '{branches,branch-misses:S}'. I would hope a syntax error from the parser ;-) yeaa.. no ;) $ ./perf record -e '{cycles:S,cache-misses}' ls ... [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.011 MB perf.data (~476 samples) ] $ ./perf report non matching sample_type I haven't actually looked at the implementation, but I understood it to be a group modifier, not an event modifier. we might want to be able to use PERF_SAMPLE_READ for single event same as for groups the difference between single event and group 'S' modifier: $ ./perf record -e 'cycles:S' ls - records 'cycles' samples and read period value via PERF_SAMPLE_READ $ ./perf record -e '{cycles,cache-misses}:S' - samples just on 'cycles' samples and read both period values (cycles and cache-misses) via PERF_SAMPLE_READ group format $ ./perf record -e '{cycles,cache-misses}:S,instructions' ls $ ./perf record -e '{cycles:S,cache-misses},instructions' ls $ ./perf record -e 'cycles:S,instructions' ls - non matching sample_type hm, thats the unique sample_type issue again ;) Once we set PERF_SAMPLE_READ for event or group, we need to set it for all other events in session, otherwise the report fails sooo, it looks like: - global record '-S' option instead, setting PERF_SAMPLE_READ sample type globaly for all events - and ':S' group modifier to enable sampling only on leader with group format reading for the rest of the group - ':S' group modifier alone would imply -S How about that? thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] perf tools: Always show CHK message when doing try-cc
On Fri, Oct 26, 2012 at 05:55:51PM +0900, Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com It might be useful to see what's happening behind us rather than just waiting few seconds during the config checking. Do we want to see all that within just simple 'make' also in case nothing gets rebuilt? It seems noisy.. [jolsa@krava perf]$ make CHK -fstack-protector-all CHK -Wstack-protector CHK -Wvolatile-register-var CHK bionic CHK libelf CHK libdw CHK libunwind CHK -DLIBELF_MMAP CHK libaudit CHK libnewt CHK gtk2 Makefile:608: GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev CHK perl CHK python CHK python version CHK libbfd CHK -DHAVE_STRLCPY CHK -DHAVE_ON_EXIT CHK -DBACKTRACE_SUPPORT SUBDIR ../lib/traceevent/ LINK perf hum, also not sure why's there ^^^ the final LINK for no change rebuild.. jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 24/33] perf, tools: Move parse_events error printing to parse_events_options
On Fri, Oct 26, 2012 at 01:30:06PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com The callers of parse_events usually have their own error handling. Move the fprintf for a bad event to parse_events_options, which is the only one who should need it. Signed-off-by: Andi Kleen a...@linux.intel.com --- tools/perf/util/parse-events.c | 10 +++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 75c7b0f..409da3e 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -827,8 +827,6 @@ int parse_events(struct perf_evlist *evlist, const char *str, * Both call perf_evlist__delete in case of error, so we dont * need to bother. */ - fprintf(stderr, invalid or unsupported event: '%s'\n, str); - fprintf(stderr, Run 'perf list' for a list of valid events\n); return ret; } @@ -836,7 +834,13 @@ int parse_events_option(const struct option *opt, const char *str, int unset __maybe_unused) { struct perf_evlist *evlist = *(struct perf_evlist **)opt-value; - return parse_events(evlist, str, unset); + int ret = parse_events(evlist, str, unset); + + if (ret) { + fprintf(stderr, invalid or unsupported event: '%s'\n, str); + fprintf(stderr, Run 'perf list' for a list of valid events\n); + } + return ret; } int parse_filter(const struct option *opt, const char *str, -- 1.7.7.6 Acked-by: Jiri Olsa jo...@redhat.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 25/33] perf, tools: Support events with - in the name
On Fri, Oct 26, 2012 at 01:30:07PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com - looks nicer than _, so allow - in the event names. Used for various of the arch perfmon and Haswell events. Signed-off-by: Andi Kleen a...@linux.intel.com --- tools/perf/util/parse-events.l |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index c87efc1..ef602f0 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -80,7 +80,7 @@ event [^,{}/]+ num_dec [0-9]+ num_hex 0x[a-fA-F0-9]+ num_raw_hex [a-fA-F0-9]+ -name [a-zA-Z_*?][a-zA-Z0-9_*?]* +name [a-zA-Z_*?][a-zA-Z0-9\-_*?]* this breaks cache events parsing since they are '-' separated and having '-' in 'name' patern will endup with PE_NAME being matched instead of PE_NAME_CACHE_* terms I guess you want '-' being used within 'cpu/..t=v../' terms right? That could be done via start conditions '%x' jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 27/33] tools, perf: Add a precise event qualifier
On Fri, Oct 26, 2012 at 01:30:09PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com Add a precise qualifier, like cpu/event=0x3c,precise=1/ hm, I think this works already via 'p' modifier like: cpu/event=0x3c/p jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 31/33] perf, tools: Support generic events as pmu event names v2
On Fri, Oct 26, 2012 at 01:30:13PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com Extend the parser/lexer to allow generic event names like instructions as a sysfs supplied PMU event name. This resolves the problem that cpu/instructions/ gives a parse error, even when the kernel supplies a instructions event This is useful to add sysfs specified qualifiers to these events, for example cpu/instructions,intx=1/ and needed for the TSX events Simply extend the grammar to handle this case. The lexer needs minor changes to save the original string. ops, I think you need to check recent changes: 3f3a206 perf test: Add automated tests for pmu sysfs translated events 1d33d6d perf tools: Add support to specify hw event as PMU event term 3fded96 perf tools: Fix PMU object alias initialization 20550a4 perf/x86: Add hardware events translations for Intel P6 cpus 0bf79d4 perf/x86: Add hardware events translations for AMD cpus 43c032f perf/x86: Add hardware events translations for Intel cpus 8300daa perf/x86: Filter out undefined events from sysfs events attribute a474739 perf/x86: Make hardware event translations available in sysfs jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 32/33] perf, tools: Default to cpu// for events v2
On Fri, Oct 26, 2012 at 01:30:14PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com When an event fails to parse and it's not in a new style format, try to parse it again as a cpu event. This allows to use sysfs exported events directly without //, so I can use perf record -e tx-aborts ... hum, seems usefull and hacky ;) would not work for modifier stuff like: tx-aborts:u (not sure if 'u' makes sense for 'tx-aborts'..) but nevermind, seems like usefull shortcut instead of perf record -e cpu/tx-aborts/ v2: Handle multiple events Signed-off-by: Andi Kleen a...@linux.intel.com --- tools/perf/util/parse-events.c | 37 + 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f800765..ee6a73c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -768,6 +768,23 @@ int parse_events_name(struct list_head *list, char *name) return 0; } +static void str_append(char **s, int *len, const char *a) +{ + int olen = *s ? strlen(*s) : 0; + int nlen = olen + strlen(a) + 1; + if (*len nlen) { + *len = *len * 2; + if (*len nlen) + *len = nlen; + *s = realloc(*s, *len); + if (!*s) trailing whitespace + exit(ENOMEM); + if (olen == 0) + **s = 0; + } + strcat(*s, a); +} + static int parse_events__scanner(const char *str, void *data, int start_token) { YY_BUFFER_STATE buffer; @@ -788,6 +805,26 @@ static int parse_events__scanner(const char *str, void *data, int start_token) parse_events__flush_buffer(buffer, scanner); parse_events__delete_buffer(buffer, scanner); parse_events_lex_destroy(scanner); + + if (ret !strchr(str, '/')) { + char *o = strdup(str); + char *s = NULL; + char *t = o; + char *p; + int len = 0; + + if (!o) + return ret; + while ((p = strsep(t, ,)) != NULL) { + if (s) + str_append(s, len, ,); + str_append(s, len, cpu/); + str_append(s, len, p); + str_append(s, len, /); + } + free(o); + ret = parse_events__scanner(s, data, start_token); any chance above could be in separated function? + } return ret; } -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 33/33] perf, tools: List kernel supplied event aliases in perf list v2
On Fri, Oct 26, 2012 at 01:30:15PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com List the kernel supplied pmu event aliases in perf list It's better when the users can actually see them. with the HW events being part of PMU 'events' dir we get single HW events listed twice branch-instructions OR cpu/branch-instructions/[Kernel PMU event] branch-misses OR cpu/branch-misses/[Kernel PMU event] bus-cycles OR cpu/bus-cycles/ [Kernel PMU event] cache-misses OR cpu/cache-misses/ [Kernel PMU event] cache-references OR cpu/cache-references/ [Kernel PMU event] cpu-cycles OR cpu/cpu-cycles/ [Kernel PMU event] instructions OR cpu/instructions/ [Kernel PMU event] ref-cycles OR cpu/ref-cycles/ [Kernel PMU event] stalled-cycles-backend OR cpu/stalled-cycles-backend/ [Kernel PMU event] stalled-cycles-frontend OR cpu/stalled-cycles-frontend/ [Kernel PMU event] uncore_cbox_0/clockticks/ [Kernel PMU event] uncore_cbox_1/clockticks/ [Kernel PMU event] uncore_cbox_2/clockticks/ [Kernel PMU event] uncore_cbox_3/clockticks/ [Kernel PMU event] jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [BUG] perf parser: does not support arbitrary new sysfs events
On Fri, Oct 26, 2012 at 10:23:09PM +0200, Stephane Eranian wrote: Hi, The latest round of perf parser changes broke my PEBS-LL patch series (at the last minute). For PEBS-LL, I need to add to generic events but I want to keep them PMU specific. As such, they need to live in the sysfs events subdir: /sys/devices/cpu/events/mem-loads, sys/devices/cpu/events/mem-stores. Given your latest rounds of sysfs event changes, I had to modify my kernel patches to fit those two new events within your perf_pmu_events_attr tables. But now, when I try to do: $ perf record -e cpu/mem-loads/ I can try this only on on uncore events and hw events aliases and that seems to work I get unsupported event. Looks at the syscall trace, it seems perf does not even look into the sysfs subdir to find a possible match. I don't understand that. What's the point of sysfs event list if it is not used or cannot be extended? Note that when I explicitly pass the content of the sysfs file to perf record, it works: $ perf record -e cpu/event=0xcd,umask=0x1,ldlat=3/ .. So this is clearly a problem with the lookup in sysfs. Also if you have the mappings exposed now in sysfs, why keep the hardcoded generic events as well? Or why have those events hardcoded in the parser as well. having perf work on old kernels I don't understand all this parser code. I get the feeling it is getting a bit out of hands already. But now, I am stuck. So could you fix my parser problem ASAP? yep, but need more details.. related patches would help jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/5] perf tool: Move BUILD_ID_SIZE into build-id object
Moving BUILD_ID_SIZE define into build-id object, plus include related changes. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-buildid-cache.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/build-id.h | 6 +- tools/perf/util/event.h| 3 +-- tools/perf/util/symbol.h | 3 +-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index edb26ea..fae8b25 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -14,6 +14,7 @@ #include util/parse-options.h #include util/strlist.h #include util/build-id.h +#include util/symbol.h static int build_id_cache__add_file(const char *filename, const char *debugdir) { diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index f0a9103..7a34dd1 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -15,6 +15,7 @@ #include debug.h #include annotate.h #include pthread.h +#include linux/bitops.h const char *disassembler_style; const char *objdump_path; diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index f6d9ff9..a811f5c 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -1,9 +1,13 @@ #ifndef PERF_BUILD_ID_H_ #define PERF_BUILD_ID_H_ 1 -#include session.h +#define BUILD_ID_SIZE 20 + +#include tool.h +#include types.h extern struct perf_tool build_id__mark_dso_hit_ops; +struct dso; int build_id__sprintf(const u8 *build_id, int len, char *bf); char *dso__build_id_filename(struct dso *self, char *bf, size_t size); diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index da97aff..0d573ff 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -6,6 +6,7 @@ #include ../perf.h #include map.h +#include build-id.h /* * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * @@ -96,8 +97,6 @@ struct perf_sample { struct stack_dump user_stack; }; -#define BUILD_ID_SIZE 20 - struct build_id_event { struct perf_event_header header; pid_tpid; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index d70f676..6eb7d3b 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -11,6 +11,7 @@ #include stdio.h #include byteswap.h #include libgen.h +#include build-id.h #ifdef LIBELF_SUPPORT #include libelf.h @@ -57,8 +58,6 @@ char *strxfrchar(char *s, char from, char to); #define DMGL_ANSI(1 1) /* Include const, volatile, etc */ #endif -#define BUILD_ID_SIZE 20 - /** struct symbol - symtab entry * * @ignore - resolvable but tools ignore it (e.g. idle routines) -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 5/5] perf tool: Move dso_* related functions into dso object
Moving dso_* related functions into dso object. Keeping symbol loading related functions still in the symbol object as it seems more convenient. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 2 + tools/perf/util/dso.c| 594 ++ tools/perf/util/dso.h| 148 tools/perf/util/symbol.c | 599 +-- tools/perf/util/symbol.h | 134 +-- 5 files changed, 751 insertions(+), 726 deletions(-) create mode 100644 tools/perf/util/dso.c create mode 100644 tools/perf/util/dso.h diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 629fc6a..ec63d53 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -327,6 +327,7 @@ LIB_H += util/svghelper.h LIB_H += util/tool.h LIB_H += util/run-command.h LIB_H += util/sigchain.h +LIB_H += util/dso.h LIB_H += util/symbol.h LIB_H += util/color.h LIB_H += util/values.h @@ -385,6 +386,7 @@ LIB_OBJS += $(OUTPUT)util/top.o LIB_OBJS += $(OUTPUT)util/usage.o LIB_OBJS += $(OUTPUT)util/wrapper.o LIB_OBJS += $(OUTPUT)util/sigchain.o +LIB_OBJS += $(OUTPUT)util/dso.o LIB_OBJS += $(OUTPUT)util/symbol.o LIB_OBJS += $(OUTPUT)util/symbol-elf.o LIB_OBJS += $(OUTPUT)util/dso-test-data.o diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c new file mode 100644 index 000..bec91fd --- /dev/null +++ b/tools/perf/util/dso.c @@ -0,0 +1,594 @@ +#include symbol.h +#include dso.h +#include util.h +#include debug.h + +char dso__symtab_origin(const struct dso *dso) +{ + static const char origin[] = { + [DSO_BINARY_TYPE__KALLSYMS] = 'k', + [DSO_BINARY_TYPE__VMLINUX] = 'v', + [DSO_BINARY_TYPE__JAVA_JIT] = 'j', + [DSO_BINARY_TYPE__DEBUGLINK]= 'l', + [DSO_BINARY_TYPE__BUILD_ID_CACHE] = 'B', + [DSO_BINARY_TYPE__FEDORA_DEBUGINFO] = 'f', + [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO] = 'u', + [DSO_BINARY_TYPE__BUILDID_DEBUGINFO]= 'b', + [DSO_BINARY_TYPE__SYSTEM_PATH_DSO] = 'd', + [DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE] = 'K', + [DSO_BINARY_TYPE__GUEST_KALLSYMS] = 'g', + [DSO_BINARY_TYPE__GUEST_KMODULE]= 'G', + [DSO_BINARY_TYPE__GUEST_VMLINUX]= 'V', + }; + + if (dso == NULL || dso-symtab_type == DSO_BINARY_TYPE__NOT_FOUND) + return '!'; + return origin[dso-symtab_type]; +} + +int dso__binary_type_file(struct dso *dso, enum dso_binary_type type, + char *root_dir, char *file, size_t size) +{ + char build_id_hex[BUILD_ID_SIZE * 2 + 1]; + int ret = 0; + + switch (type) { + case DSO_BINARY_TYPE__DEBUGLINK: { + char *debuglink; + + strncpy(file, dso-long_name, size); + debuglink = file + dso-long_name_len; + while (debuglink != file *debuglink != '/') + debuglink--; + if (*debuglink == '/') + debuglink++; + filename__read_debuglink(dso-long_name, debuglink, +size - (debuglink - file)); + } + break; + case DSO_BINARY_TYPE__BUILD_ID_CACHE: + /* skip the locally configured cache if a symfs is given */ + if (symbol_conf.symfs[0] || + (dso__build_id_filename(dso, file, size) == NULL)) + ret = -1; + break; + + case DSO_BINARY_TYPE__FEDORA_DEBUGINFO: + snprintf(file, size, %s/usr/lib/debug%s.debug, +symbol_conf.symfs, dso-long_name); + break; + + case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO: + snprintf(file, size, %s/usr/lib/debug%s, +symbol_conf.symfs, dso-long_name); + break; + + case DSO_BINARY_TYPE__BUILDID_DEBUGINFO: + if (!dso-has_build_id) { + ret = -1; + break; + } + + build_id__sprintf(dso-build_id, + sizeof(dso-build_id), + build_id_hex); + snprintf(file, size, +%s/usr/lib/debug/.build-id/%.2s/%s.debug, +symbol_conf.symfs, build_id_hex, build_id_hex + 2); + break; + + case DSO_BINARY_TYPE__SYSTEM_PATH_DSO: + snprintf(file, size, %s%s, +symbol_conf.symfs, dso
[PATCH 3/5] perf tool: Move hex2u64 into util object
Moving hex2u64 function into util object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/util/symbol.c | 33 - tools/perf/util/symbol.h | 1 - tools/perf/util/util.c | 33 + tools/perf/util/util.h | 1 + 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index e36e8c2..08b8257 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -2050,39 +2050,6 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid) return machine__create_kernel_maps(machine); } -static int hex(char ch) -{ - if ((ch = '0') (ch = '9')) - return ch - '0'; - if ((ch = 'a') (ch = 'f')) - return ch - 'a' + 10; - if ((ch = 'A') (ch = 'F')) - return ch - 'A' + 10; - return -1; -} - -/* - * While we find nice hex chars, build a long_val. - * Return number of chars processed. - */ -int hex2u64(const char *ptr, u64 *long_val) -{ - const char *p = ptr; - *long_val = 0; - - while (*p) { - const int hex_val = hex(*p); - - if (hex_val 0) - break; - - *long_val = (*long_val 4) | hex_val; - p++; - } - - return p - ptr; -} - char *strxfrchar(char *s, char from, char to) { char *p = s; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 6eb7d3b..bc34dc1 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -40,7 +40,6 @@ static inline char *bfd_demangle(void __maybe_unused *v, #endif #endif -int hex2u64(const char *ptr, u64 *val); char *strxfrchar(char *s, char from, char to); /* diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 637b5cc..5906e84 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -166,6 +166,39 @@ size_t hex_width(u64 v) return n; } +static int hex(char ch) +{ + if ((ch = '0') (ch = '9')) + return ch - '0'; + if ((ch = 'a') (ch = 'f')) + return ch - 'a' + 10; + if ((ch = 'A') (ch = 'F')) + return ch - 'A' + 10; + return -1; +} + +/* + * While we find nice hex chars, build a long_val. + * Return number of chars processed. + */ +int hex2u64(const char *ptr, u64 *long_val) +{ + const char *p = ptr; + *long_val = 0; + + while (*p) { + const int hex_val = hex(*p); + + if (hex_val 0) + break; + + *long_val = (*long_val 4) | hex_val; + p++; + } + + return p - ptr; +} + /* Obtain a backtrace and print it to stdout. */ #ifdef BACKTRACE_SUPPORT void dump_stack(void) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 0d85209..d6c22c5 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -262,6 +262,7 @@ bool is_power_of_2(unsigned long n) } size_t hex_width(u64 v); +int hex2u64(const char *ptr, u64 *val); char *rtrim(char *s); -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/5] perf tool: Move build_id__sprintf into build-id object
Moving build_id__sprintf function into build-id object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-buildid-cache.c | 2 +- tools/perf/util/build-id.c | 15 +++ tools/perf/util/build-id.h | 1 + tools/perf/util/header.c | 1 + tools/perf/util/map.c | 1 + tools/perf/util/symbol.c | 15 --- tools/perf/util/symbol.h | 1 - 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c index d37e077..edb26ea 100644 --- a/tools/perf/builtin-buildid-cache.c +++ b/tools/perf/builtin-buildid-cache.c @@ -13,7 +13,7 @@ #include util/header.h #include util/parse-options.h #include util/strlist.h -#include util/symbol.h +#include util/build-id.h static int build_id_cache__add_file(const char *filename, const char *debugdir) { diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 94ca117..5295625 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -70,6 +70,21 @@ struct perf_tool build_id__mark_dso_hit_ops = { .build_id= perf_event__process_build_id, }; +int build_id__sprintf(const u8 *build_id, int len, char *bf) +{ + char *bid = bf; + const u8 *raw = build_id; + int i; + + for (i = 0; i len; ++i) { + sprintf(bid, %02x, *raw); + ++raw; + bid += 2; + } + + return raw - build_id; +} + char *dso__build_id_filename(struct dso *self, char *bf, size_t size) { char build_id_hex[BUILD_ID_SIZE * 2 + 1]; diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h index 45c500b..f6d9ff9 100644 --- a/tools/perf/util/build-id.h +++ b/tools/perf/util/build-id.h @@ -5,6 +5,7 @@ extern struct perf_tool build_id__mark_dso_hit_ops; +int build_id__sprintf(const u8 *build_id, int len, char *bf); char *dso__build_id_filename(struct dso *self, char *bf, size_t size); int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event, diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 7daad23..514ed1b 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -23,6 +23,7 @@ #include pmu.h #include vdso.h #include strbuf.h +#include build-id.h static bool no_buildid_cache = false; diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 6109fa4..9b40c44 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -10,6 +10,7 @@ #include thread.h #include strlist.h #include vdso.h +#include build-id.h const char *map_type__name[MAP__NR_TYPES] = { [MAP__FUNCTION] = Functions, diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index e2e8c69..e36e8c2 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -504,21 +504,6 @@ void dso__sort_by_name(struct dso *dso, enum map_type type) dso-symbols[type]); } -int build_id__sprintf(const u8 *build_id, int len, char *bf) -{ - char *bid = bf; - const u8 *raw = build_id; - int i; - - for (i = 0; i len; ++i) { - sprintf(bid, %02x, *raw); - ++raw; - bid += 2; - } - - return raw - build_id; -} - size_t dso__fprintf_buildid(struct dso *dso, FILE *fp) { char sbuild_id[BUILD_ID_SIZE * 2 + 1]; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 8b6ef7f..d70f676 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -338,7 +338,6 @@ struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type, int filename__read_build_id(const char *filename, void *bf, size_t size); int sysfs__read_build_id(const char *filename, void *bf, size_t size); bool __dsos__read_build_ids(struct list_head *head, bool with_hits); -int build_id__sprintf(const u8 *build_id, int len, char *bf); int kallsyms__parse(const char *filename, void *arg, int (*process_symbol)(void *arg, const char *name, char type, u64 start)); -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/5] perf dso: Separate dso symbols to separate object
hi, separating dso related stuff into dso object plus some other symbol object cleanup. It's just a code moving, no actual change was done. Attached patches: 1/5 perf tool: Move build_id__sprintf into build-id object 2/5 perf tool: Move BUILD_ID_SIZE into build-id object 3/5 perf tool: Move hex2u64 into util object 4/5 perf tool: Move strxfrchar into string object 5/5 perf tool: Move dso_* related functions into dso object Also available in: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git perf/dso1 thanks, jirka Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile| 2 + tools/perf/builtin-buildid-cache.c | 1 + tools/perf/util/annotate.c | 1 + tools/perf/util/build-id.c | 15 ++ tools/perf/util/build-id.h | 7 +- tools/perf/util/dso.c | 594 tools/perf/util/dso.h | 148 +++ tools/perf/util/event.h| 3 +- tools/perf/util/header.c | 1 + tools/perf/util/map.c | 1 + tools/perf/util/string.c | 18 ++ tools/perf/util/symbol.c | 657 +-- tools/perf/util/symbol.h | 141 +-- tools/perf/util/util.c | 33 tools/perf/util/util.h | 2 + 15 files changed, 831 insertions(+), 793 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/5] perf tool: Move strxfrchar into string object
Moving strxfrchar function into string object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/util/string.c | 18 ++ tools/perf/util/symbol.c | 10 -- tools/perf/util/symbol.h | 2 -- tools/perf/util/util.h | 1 + 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 3217059..346707d 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c @@ -314,6 +314,24 @@ int strtailcmp(const char *s1, const char *s2) } /** + * strxfrchar - Locate and replace character in @s + * @s:The string to be searched/changed. + * @from: Source character to be replaced. + * @to: Destination character. + * + * Return pointer to the changed string. + */ +char *strxfrchar(char *s, char from, char to) +{ + char *p = s; + + while ((p = strchr(p, from)) != NULL) + *p++ = to; + + return s; +} + +/** * rtrim - Removes trailing whitespace from @s. * @s: The string to be stripped. * diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 08b8257..d3b1ecc 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -2050,16 +2050,6 @@ int machines__create_kernel_maps(struct rb_root *machines, pid_t pid) return machine__create_kernel_maps(machine); } -char *strxfrchar(char *s, char from, char to) -{ - char *p = s; - - while ((p = strchr(p, from)) != NULL) - *p++ = to; - - return s; -} - int machines__create_guest_kernel_maps(struct rb_root *machines) { int ret = 0; diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index bc34dc1..45d3df8 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h @@ -40,8 +40,6 @@ static inline char *bfd_demangle(void __maybe_unused *v, #endif #endif -char *strxfrchar(char *s, char from, char to); - /* * libelf 0.8.x and earlier do not support ELF_C_READ_MMAP; * for newer versions we can use mmap to reduce memory usage: diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index d6c22c5..c233091 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -240,6 +240,7 @@ void argv_free(char **argv); bool strglobmatch(const char *str, const char *pat); bool strlazymatch(const char *str, const char *pat); int strtailcmp(const char *s1, const char *s2); +char *strxfrchar(char *s, char from, char to); unsigned long convert_unit(unsigned long value, char *unit); int readn(int fd, void *buf, size_t size); -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [BUG] perf parser: does not support arbitrary new sysfs events
On Sun, Oct 28, 2012 at 01:13:59AM +0200, Stephane Eranian wrote: On Sat, Oct 27, 2012 at 10:34 PM, Jiri Olsa jo...@redhat.com wrote: On Fri, Oct 26, 2012 at 10:23:09PM +0200, Stephane Eranian wrote: Hi, The latest round of perf parser changes broke my PEBS-LL patch series (at the last minute). For PEBS-LL, I need to add to generic events but I want to keep them PMU specific. As such, they need to live in the sysfs events subdir: /sys/devices/cpu/events/mem-loads, sys/devices/cpu/events/mem-stores. Given your latest rounds of sysfs event changes, I had to modify my kernel patches to fit those two new events within your perf_pmu_events_attr tables. But now, when I try to do: $ perf record -e cpu/mem-loads/ I can try this only on on uncore events and hw events aliases and that seems to work I know it works there. I don't understand why it does not work with cpu/. Just add an encoding that has no hardcoded equivalent. I bet you will reproduce the problem. In my patch set, I have extended your perf_pmu_events_attr struct to also accept an already preformed event_str. I can send you that extension if you want. that would be great jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 5/5] perf tool: Move dso_* related functions into dso object
On Sun, Oct 28, 2012 at 11:37:02AM -0200, Arnaldo Carvalho de Melo wrote: Em Sat, Oct 27, 2012 at 11:18:32PM +0200, Jiri Olsa escreveu: Moving dso_* related functions into dso object. Keeping symbol loading related functions still in the symbol object as it seems more convenient. Please resubmit after you fix this: The other 4 patches I already applied to my local tree. - Arnaldo CC /home/acme/git/build/perf/util/dso-test-data.o In file included from util/dso.c:2: util/dso.h:87: error: ‘BUILD_ID_SIZE’ undeclared here (not in a function) CC /home/acme/git/build/perf/util/color.o cc1: warnings being treated as errors util/dso.c: In function ‘dso__binary_type_file’: util/dso.c:45: error: implicit declaration of function ‘filename__read_debuglink’ util/dso.c:45: error: nested extern declaration of ‘filename__read_debuglink’ util/dso.c:51: error: ‘symbol_conf’ undeclared (first use in this function) util/dso.c:51: error: (Each undeclared identifier is reported only once util/dso.c:51: error: for each function it appears in.) util/dso.c: In function ‘dso__delete’: util/dso.c:435: error: implicit declaration of function ‘symbols__delete’ util/dso.c:435: error: nested extern declaration of ‘symbols__delete’ util/dso.c: In function ‘dso__read_running_kernel_build_id’: util/dso.c:462: error: implicit declaration of function ‘sysfs__read_build_id’ util/dso.c:462: error: nested extern declaration of ‘sysfs__read_build_id’ util/dso.c: In function ‘__dsos__read_build_ids’: util/dso.c:500: error: implicit declaration of function ‘filename__read_build_id’ util/dso.c:500: error: nested extern declaration of ‘filename__read_build_id’ util/dso.c: In function ‘dso__fprintf’: util/dso.c:589: error: dereferencing pointer to incomplete type util/dso.c:589: error: type defaults to ‘int’ in declaration of ‘__mptr’ util/dso.c:589: error: initialization from incompatible pointer type util/dso.c:589: error: invalid use of undefined type ‘struct symbol’ util/dso.c:590: error: implicit declaration of function ‘symbol__fprintf’ util/dso.c:590: error: nested extern declaration of ‘symbol__fprintf’ make: *** [/home/acme/git/build/perf/util/dso.o] Error 1 ugh.. I have it rebased to your perf/core and it builds cleanly Any chance there's something not pushed yet? thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 27/33] tools, perf: Add a precise event qualifier
On Sun, Oct 28, 2012 at 08:13:13PM +0100, Andi Kleen wrote: On Sat, Oct 27, 2012 at 09:35:44PM +0200, Jiri Olsa wrote: On Fri, Oct 26, 2012 at 01:30:09PM -0700, Andi Kleen wrote: From: Andi Kleen a...@linux.intel.com Add a precise qualifier, like cpu/event=0x3c,precise=1/ hm, I think this works already via 'p' modifier like: cpu/event=0x3c/p Not for kernel specified events, which is why this was needed. I haven't checked deeply, but I thought the modifier is always applied, what do you mean by 'kernel specified events' ? jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 0/5] perf dso: Separate dso symbols to separate object
On Mon, Oct 29, 2012 at 08:07:48PM +0900, Namhyung Kim wrote: Hi Jiri, On Sat, 27 Oct 2012 23:18:27 +0200, Jiri Olsa wrote: hi, separating dso related stuff into dso object plus some other symbol object cleanup. It's just a code moving, no actual change was done. Attached patches: 1/5 perf tool: Move build_id__sprintf into build-id object 2/5 perf tool: Move BUILD_ID_SIZE into build-id object 3/5 perf tool: Move hex2u64 into util object 4/5 perf tool: Move strxfrchar into string object 5/5 perf tool: Move dso_* related functions into dso object Looks good to me. Arnaldo, if you want, you can add my Reviewed- or Tested-by tags for this series. humm, so you could compile it wth no problem..? what system are you? ;) thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/12] perf tests: Move test__vmlinux_matches_kallsyms into separate object
Separating test__vmlinux_matches_kallsyms test from the builtin-test into vmlinux-kallsyms object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 223 +- tools/perf/tests/tests.h| 6 + tools/perf/tests/vmlinux-kallsyms.c | 230 4 files changed, 239 insertions(+), 221 deletions(-) create mode 100644 tools/perf/tests/tests.h create mode 100644 tools/perf/tests/vmlinux-kallsyms.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index cca5bb8..7c7ba4d 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -431,6 +431,7 @@ LIB_OBJS += $(OUTPUT)arch/common.o LIB_OBJS += $(OUTPUT)tests/parse-events.o LIB_OBJS += $(OUTPUT)tests/dso-data.o LIB_OBJS += $(OUTPUT)tests/attr.o +LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o BUILTIN_OBJS += $(OUTPUT)builtin-bench.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 5d4354e..5bc9063 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -21,231 +21,12 @@ #include sys/mman.h -static int vmlinux_matches_kallsyms_filter(struct map *map __maybe_unused, - struct symbol *sym) -{ - bool *visited = symbol__priv(sym); - *visited = true; - return 0; -} - -static int test__vmlinux_matches_kallsyms(void) -{ - int err = -1; - struct rb_node *nd; - struct symbol *sym; - struct map *kallsyms_map, *vmlinux_map; - struct machine kallsyms, vmlinux; - enum map_type type = MAP__FUNCTION; - struct ref_reloc_sym ref_reloc_sym = { .name = _stext, }; - - /* -* Step 1: -* -* Init the machines that will hold kernel, modules obtained from -* both vmlinux + .ko files and from /proc/kallsyms split by modules. -*/ - machine__init(kallsyms, , HOST_KERNEL_ID); - machine__init(vmlinux, , HOST_KERNEL_ID); - - /* -* Step 2: -* -* Create the kernel maps for kallsyms and the DSO where we will then -* load /proc/kallsyms. Also create the modules maps from /proc/modules -* and find the .ko files that match them in /lib/modules/`uname -r`/. -*/ - if (machine__create_kernel_maps(kallsyms) 0) { - pr_debug(machine__create_kernel_maps ); - return -1; - } - - /* -* Step 3: -* -* Load and split /proc/kallsyms into multiple maps, one per module. -*/ - if (machine__load_kallsyms(kallsyms, /proc/kallsyms, type, NULL) = 0) { - pr_debug(dso__load_kallsyms ); - goto out; - } - - /* -* Step 4: -* -* kallsyms will be internally on demand sorted by name so that we can -* find the reference relocation * symbol, i.e. the symbol we will use -* to see if the running kernel was relocated by checking if it has the -* same value in the vmlinux file we load. -*/ - kallsyms_map = machine__kernel_map(kallsyms, type); - - sym = map__find_symbol_by_name(kallsyms_map, ref_reloc_sym.name, NULL); - if (sym == NULL) { - pr_debug(dso__find_symbol_by_name ); - goto out; - } - - ref_reloc_sym.addr = sym-start; - - /* -* Step 5: -* -* Now repeat step 2, this time for the vmlinux file we'll auto-locate. -*/ - if (machine__create_kernel_maps(vmlinux) 0) { - pr_debug(machine__create_kernel_maps ); - goto out; - } - - vmlinux_map = machine__kernel_map(vmlinux, type); - map__kmap(vmlinux_map)-ref_reloc_sym = ref_reloc_sym; - - /* -* Step 6: -* -* Locate a vmlinux file in the vmlinux path that has a buildid that -* matches the one of the running kernel. -* -* While doing that look if we find the ref reloc symbol, if we find it -* we'll have its ref_reloc_symbol.unrelocated_addr and then -* maps__reloc_vmlinux will notice and set proper -[un]map_ip routines -* to fixup the symbols. -*/ - if (machine__load_vmlinux_path(vmlinux, type, - vmlinux_matches_kallsyms_filter) = 0) { - pr_debug(machine__load_vmlinux_path ); - goto out; - } - - err = 0; - /* -* Step 7: -* -* Now look at the symbols in the vmlinux DSO and check if we find all of them -* in the kallsyms dso. For the ones
[PATCH 06/12] perf tests: Move test__rdpmc into separate object
Separating test__rdpmc test from the builtin-test into rdpmc object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 168 -- tools/perf/tests/rdpmc.c| 175 tools/perf/tests/tests.h| 1 + 4 files changed, 177 insertions(+), 168 deletions(-) create mode 100644 tools/perf/tests/rdpmc.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index a2d6153..2e5197a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -436,6 +436,7 @@ LIB_OBJS += $(OUTPUT)tests/open-syscall.o LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o LIB_OBJS += $(OUTPUT)tests/mmap-basic.o LIB_OBJS += $(OUTPUT)tests/perf-record.o +LIB_OBJS += $(OUTPUT)tests/rdpmc.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 7cb3928..1e9a0ea 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -30,174 +30,6 @@ #include sched.h - -#if defined(__x86_64__) || defined(__i386__) - -#define barrier() asm volatile( ::: memory) - -static u64 rdpmc(unsigned int counter) -{ - unsigned int low, high; - - asm volatile(rdpmc : =a (low), =d (high) : c (counter)); - - return low | ((u64)high) 32; -} - -static u64 rdtsc(void) -{ - unsigned int low, high; - - asm volatile(rdtsc : =a (low), =d (high)); - - return low | ((u64)high) 32; -} - -static u64 mmap_read_self(void *addr) -{ - struct perf_event_mmap_page *pc = addr; - u32 seq, idx, time_mult = 0, time_shift = 0; - u64 count, cyc = 0, time_offset = 0, enabled, running, delta; - - do { - seq = pc-lock; - barrier(); - - enabled = pc-time_enabled; - running = pc-time_running; - - if (enabled != running) { - cyc = rdtsc(); - time_mult = pc-time_mult; - time_shift = pc-time_shift; - time_offset = pc-time_offset; - } - - idx = pc-index; - count = pc-offset; - if (idx) - count += rdpmc(idx - 1); - - barrier(); - } while (pc-lock != seq); - - if (enabled != running) { - u64 quot, rem; - - quot = (cyc time_shift); - rem = cyc ((1 time_shift) - 1); - delta = time_offset + quot * time_mult + - ((rem * time_mult) time_shift); - - enabled += delta; - if (idx) - running += delta; - - quot = count / running; - rem = count % running; - count = quot * enabled + (rem * enabled) / running; - } - - return count; -} - -/* - * If the RDPMC instruction faults then signal this back to the test parent task: - */ -static void segfault_handler(int sig __maybe_unused, -siginfo_t *info __maybe_unused, -void *uc __maybe_unused) -{ - exit(-1); -} - -static int __test__rdpmc(void) -{ - volatile int tmp = 0; - u64 i, loops = 1000; - int n; - int fd; - void *addr; - struct perf_event_attr attr = { - .type = PERF_TYPE_HARDWARE, - .config = PERF_COUNT_HW_INSTRUCTIONS, - .exclude_kernel = 1, - }; - u64 delta_sum = 0; -struct sigaction sa; - - sigfillset(sa.sa_mask); - sa.sa_sigaction = segfault_handler; - sigaction(SIGSEGV, sa, NULL); - - fd = sys_perf_event_open(attr, 0, -1, -1, 0); - if (fd 0) { - pr_err(Error: sys_perf_event_open() syscall returned - with %d (%s)\n, fd, strerror(errno)); - return -1; - } - - addr = mmap(NULL, page_size, PROT_READ, MAP_SHARED, fd, 0); - if (addr == (void *)(-1)) { - pr_err(Error: mmap() syscall returned with (%s)\n, - strerror(errno)); - goto out_close; - } - - for (n = 0; n 6; n++) { - u64 stamp, now, delta; - - stamp = mmap_read_self(addr); - - for (i = 0; i loops; i++) - tmp++; - - now = mmap_read_self(addr); - loops *= 10; - - delta = now - stamp; - pr_debug(%14d: %14Lu\n, n, (long long)delta); - - delta_sum += delta; - } - - munmap(addr, page_size); - pr_debug
[PATCH 10/12] perf tests: Move pmu tests into separate object
Separating pmu's object tests into pmu object under tests directory. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 7 +- tools/perf/tests/pmu.c | 178 ++ tools/perf/tests/tests.h| 1 + tools/perf/util/pmu.c | 185 ++-- tools/perf/util/pmu.h | 4 + 6 files changed, 191 insertions(+), 185 deletions(-) create mode 100644 tools/perf/tests/pmu.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 1e50559..9af012f 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -440,6 +440,7 @@ LIB_OBJS += $(OUTPUT)tests/perf-record.o LIB_OBJS += $(OUTPUT)tests/rdpmc.o LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o +LIB_OBJS += $(OUTPUT)tests/pmu.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index bab8490..d3b95e0 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -30,11 +30,6 @@ #include sched.h -static int test__perf_pmu(void) -{ - return perf_pmu__test(); -} - static struct test { const char *desc; int (*func)(void); @@ -71,7 +66,7 @@ static struct test { }, { .desc = Test perf pmu format parsing, - .func = test__perf_pmu, + .func = test__pmu, }, { .desc = Test dso data interface, diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c new file mode 100644 index 000..a5f3798 --- /dev/null +++ b/tools/perf/tests/pmu.c @@ -0,0 +1,178 @@ +#include parse-events.h +#include pmu.h +#include util.h +#include tests.h + +/* Simulated format definitions. */ +static struct test_format { + const char *name; + const char *value; +} test_formats[] = { + { krava01, config:0-1,62-63\n, }, + { krava02, config:10-17\n, }, + { krava03, config:5\n, }, + { krava11, config1:0,2,4,6,8,20-28\n, }, + { krava12, config1:63\n, }, + { krava13, config1:45-47\n, }, + { krava21, config2:0-3,10-13,20-23,30-33,40-43,50-53,60-63\n, }, + { krava22, config2:8,18,48,58\n, }, + { krava23, config2:28-29,38\n, }, +}; + +#define TEST_FORMATS_CNT (sizeof(test_formats) / sizeof(struct test_format)) + +/* Simulated users input. */ +static struct parse_events__term test_terms[] = { + { + .config= (char *) krava01, + .val.num = 15, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava02, + .val.num = 170, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava03, + .val.num = 1, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava11, + .val.num = 27, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava12, + .val.num = 1, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava13, + .val.num = 2, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava21, + .val.num = 119, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava22, + .val.num = 11, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, + { + .config= (char *) krava23, + .val.num = 2, + .type_val = PARSE_EVENTS__TERM_TYPE_NUM, + .type_term = PARSE_EVENTS__TERM_TYPE_USER, + }, +}; +#define TERMS_CNT (sizeof(test_terms) / sizeof(struct parse_events__term)) + +/* + * Prepare format directory data, exported by kernel + * at /sys/bus/event_source/devices/dev/format. + */ +static char *test_format_dir_get
[PATCH 08/12] perf tests: Move perf_evsel__tp_sched_test into separate object
Separating perf_evsel__tp_sched_test test from the builtin-test into evsel-tp-sched object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 83 +- tools/perf/tests/evsel-tp-sched.c | 84 +++ tools/perf/tests/tests.h | 1 + 4 files changed, 87 insertions(+), 82 deletions(-) create mode 100644 tools/perf/tests/evsel-tp-sched.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index ad6fcb5..e510b53 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -438,6 +438,7 @@ LIB_OBJS += $(OUTPUT)tests/mmap-basic.o LIB_OBJS += $(OUTPUT)tests/perf-record.o LIB_OBJS += $(OUTPUT)tests/rdpmc.o LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o +LIB_OBJS += $(OUTPUT)tests/evsel-tp-sched.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 93f5e91..c66caa7 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -35,87 +35,6 @@ static int test__perf_pmu(void) return perf_pmu__test(); } -static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, - int size, bool should_be_signed) -{ - struct format_field *field = perf_evsel__field(evsel, name); - int is_signed; - int ret = 0; - - if (field == NULL) { - pr_debug(%s: \%s\ field not found!\n, evsel-name, name); - return -1; - } - - is_signed = !!(field-flags | FIELD_IS_SIGNED); - if (should_be_signed !is_signed) { - pr_debug(%s: \%s\ signedness(%d) is wrong, should be %d\n, -evsel-name, name, is_signed, should_be_signed); - ret = -1; - } - - if (field-size != size) { - pr_debug(%s: \%s\ size (%d) should be %d!\n, -evsel-name, name, field-size, size); - ret = -1; - } - - return ret; -} - -static int perf_evsel__tp_sched_test(void) -{ - struct perf_evsel *evsel = perf_evsel__newtp(sched, sched_switch, 0); - int ret = 0; - - if (evsel == NULL) { - pr_debug(perf_evsel__new\n); - return -1; - } - - if (perf_evsel__test_field(evsel, prev_comm, 16, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, prev_pid, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, prev_prio, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, prev_state, 8, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, next_comm, 16, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, next_pid, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, next_prio, 4, true)) - ret = -1; - - perf_evsel__delete(evsel); - - evsel = perf_evsel__newtp(sched, sched_wakeup, 0); - - if (perf_evsel__test_field(evsel, comm, 16, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, pid, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, prio, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, success, 4, true)) - ret = -1; - - if (perf_evsel__test_field(evsel, target_cpu, 4, true)) - ret = -1; - - return ret; -} - static int test__syscall_open_tp_fields(void) { struct perf_record_opts opts = { @@ -276,7 +195,7 @@ static struct test { }, { .desc = Check parsing of sched tracepoints fields, - .func = perf_evsel__tp_sched_test, + .func = test__perf_evsel__tp_sched_test, }, { .desc = Generate and check syscalls:sys_enter_open event fields, diff --git a/tools/perf/tests/evsel-tp-sched.c b/tools/perf/tests/evsel-tp-sched.c new file mode 100644 index 000..a5d2fcc --- /dev/null +++ b/tools/perf/tests/evsel-tp-sched.c @@ -0,0 +1,84 @@ +#include evsel.h +#include tests.h +#include event-parse.h + +static int perf_evsel__test_field(struct perf_evsel *evsel, const char *name, + int size, bool should_be_signed) +{ + struct format_field *field = perf_evsel__field(evsel, name); + int is_signed; + int ret = 0; + + if (field == NULL) { + pr_debug(%s: \%s\ field not found!\n, evsel-name, name); + return -1; + } + + is_signed = !!(field-flags | FIELD_IS_SIGNED
[PATCH 09/12] perf tests: Move test__syscall_open_tp_fields into separate object
Separating test__syscall_open_tp_fields test from the builtin-test into open-syscall-tp-fields object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 112 tools/perf/tests/open-syscall-tp-fields.c | 117 ++ tools/perf/tests/tests.h | 1 + 4 files changed, 119 insertions(+), 112 deletions(-) create mode 100644 tools/perf/tests/open-syscall-tp-fields.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index e510b53..1e50559 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -434,6 +434,7 @@ LIB_OBJS += $(OUTPUT)tests/attr.o LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o LIB_OBJS += $(OUTPUT)tests/open-syscall.o LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o +LIB_OBJS += $(OUTPUT)tests/open-syscall-tp-fields.o LIB_OBJS += $(OUTPUT)tests/mmap-basic.o LIB_OBJS += $(OUTPUT)tests/perf-record.o LIB_OBJS += $(OUTPUT)tests/rdpmc.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index c66caa7..bab8490 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -35,118 +35,6 @@ static int test__perf_pmu(void) return perf_pmu__test(); } -static int test__syscall_open_tp_fields(void) -{ - struct perf_record_opts opts = { - .target = { - .uid = UINT_MAX, - .uses_mmap = true, - }, - .no_delay = true, - .freq = 1, - .mmap_pages = 256, - .raw_samples = true, - }; - const char *filename = /etc/passwd; - int flags = O_RDONLY | O_DIRECTORY; - struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); - struct perf_evsel *evsel; - int err = -1, i, nr_events = 0, nr_polls = 0; - - if (evlist == NULL) { - pr_debug(%s: perf_evlist__new\n, __func__); - goto out; - } - - evsel = perf_evsel__newtp(syscalls, sys_enter_open, 0); - if (evsel == NULL) { - pr_debug(%s: perf_evsel__newtp\n, __func__); - goto out_delete_evlist; - } - - perf_evlist__add(evlist, evsel); - - err = perf_evlist__create_maps(evlist, opts.target); - if (err 0) { - pr_debug(%s: perf_evlist__create_maps\n, __func__); - goto out_delete_evlist; - } - - perf_evsel__config(evsel, opts, evsel); - - evlist-threads-map[0] = getpid(); - - err = perf_evlist__open(evlist); - if (err 0) { - pr_debug(perf_evlist__open: %s\n, strerror(errno)); - goto out_delete_evlist; - } - - err = perf_evlist__mmap(evlist, UINT_MAX, false); - if (err 0) { - pr_debug(perf_evlist__mmap: %s\n, strerror(errno)); - goto out_delete_evlist; - } - - perf_evlist__enable(evlist); - - /* -* Generate the event: -*/ - open(filename, flags); - - while (1) { - int before = nr_events; - - for (i = 0; i evlist-nr_mmaps; i++) { - union perf_event *event; - - while ((event = perf_evlist__mmap_read(evlist, i)) != NULL) { - const u32 type = event-header.type; - int tp_flags; - struct perf_sample sample; - - ++nr_events; - - if (type != PERF_RECORD_SAMPLE) - continue; - - err = perf_evsel__parse_sample(evsel, event, sample); - if (err) { - pr_err(Can't parse sample, err = %d\n, err); - goto out_munmap; - } - - tp_flags = perf_evsel__intval(evsel, sample, flags); - - if (flags != tp_flags) { - pr_debug(%s: Expected flags=%#x, got %#x\n, -__func__, flags, tp_flags); - goto out_munmap; - } - - goto out_ok; - } - } - - if (nr_events == before) - poll(evlist-pollfd, evlist-nr_fds, 10); - - if (++nr_polls 5) { - pr_debug(%s: no events!\n, __func__); - goto out_munmap
[PATCH 02/12] perf tests: Move test__open_syscall_event into separate object
Separating test__open_syscall_event test from the builtin-test into open-syscall object. Adding util object under tests directory to gather help functions common to more tests. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 2 + tools/perf/tests/builtin-test.c | 84 - tools/perf/tests/open-syscall.c | 66 tools/perf/tests/tests.h| 5 +++ tools/perf/tests/util.c | 30 +++ 5 files changed, 103 insertions(+), 84 deletions(-) create mode 100644 tools/perf/tests/open-syscall.c create mode 100644 tools/perf/tests/util.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 7c7ba4d..69f582c 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -432,6 +432,8 @@ LIB_OBJS += $(OUTPUT)tests/parse-events.o LIB_OBJS += $(OUTPUT)tests/dso-data.o LIB_OBJS += $(OUTPUT)tests/attr.o LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o +LIB_OBJS += $(OUTPUT)tests/open-syscall.o +LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o BUILTIN_OBJS += $(OUTPUT)builtin-bench.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 5bc9063..b6b1e46 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -27,90 +27,6 @@ #include tests.h -static int trace_event__id(const char *evname) -{ - char *filename; - int err = -1, fd; - - if (asprintf(filename, -%s/syscalls/%s/id, -tracing_events_path, evname) 0) - return -1; - - fd = open(filename, O_RDONLY); - if (fd = 0) { - char id[16]; - if (read(fd, id, sizeof(id)) 0) - err = atoi(id); - close(fd); - } - - free(filename); - return err; -} - -static int test__open_syscall_event(void) -{ - int err = -1, fd; - struct thread_map *threads; - struct perf_evsel *evsel; - struct perf_event_attr attr; - unsigned int nr_open_calls = 111, i; - int id = trace_event__id(sys_enter_open); - - if (id 0) { - pr_debug(is debugfs mounted on /sys/kernel/debug?\n); - return -1; - } - - threads = thread_map__new(-1, getpid(), UINT_MAX); - if (threads == NULL) { - pr_debug(thread_map__new\n); - return -1; - } - - memset(attr, 0, sizeof(attr)); - attr.type = PERF_TYPE_TRACEPOINT; - attr.config = id; - evsel = perf_evsel__new(attr, 0); - if (evsel == NULL) { - pr_debug(perf_evsel__new\n); - goto out_thread_map_delete; - } - - if (perf_evsel__open_per_thread(evsel, threads) 0) { - pr_debug(failed to open counter: %s, -tweak /proc/sys/kernel/perf_event_paranoid?\n, -strerror(errno)); - goto out_evsel_delete; - } - - for (i = 0; i nr_open_calls; ++i) { - fd = open(/etc/passwd, O_RDONLY); - close(fd); - } - - if (perf_evsel__read_on_cpu(evsel, 0, 0) 0) { - pr_debug(perf_evsel__read_on_cpu\n); - goto out_close_fd; - } - - if (evsel-counts-cpu[0].val != nr_open_calls) { - pr_debug(perf_evsel__read_on_cpu: expected to intercept %d calls, got % PRIu64 \n, -nr_open_calls, evsel-counts-cpu[0].val); - goto out_close_fd; - } - - err = 0; -out_close_fd: - perf_evsel__close_fd(evsel, 1, threads-nr); -out_evsel_delete: - perf_evsel__delete(evsel); -out_thread_map_delete: - thread_map__delete(threads); - return err; -} - #include sched.h static int test__open_syscall_event_on_all_cpus(void) diff --git a/tools/perf/tests/open-syscall.c b/tools/perf/tests/open-syscall.c new file mode 100644 index 000..98be8b5 --- /dev/null +++ b/tools/perf/tests/open-syscall.c @@ -0,0 +1,66 @@ +#include thread_map.h +#include evsel.h +#include debug.h +#include tests.h + +int test__open_syscall_event(void) +{ + int err = -1, fd; + struct thread_map *threads; + struct perf_evsel *evsel; + struct perf_event_attr attr; + unsigned int nr_open_calls = 111, i; + int id = trace_event__id(sys_enter_open); + + if (id 0) { + pr_debug(is debugfs mounted on /sys/kernel/debug?\n); + return -1; + } + + threads = thread_map__new(-1, getpid(), UINT_MAX); + if (threads == NULL) { + pr_debug(thread_map__new\n); + return -1; + } + + memset
[PATCH 07/12] perf tests: Move perf_evsel__roundtrip_name_test into separate object
Separating perf_evsel__roundtrip_name_test test from the builtin-test into evsel-roundtrip-name object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 112 +-- tools/perf/tests/evsel-roundtrip-name.c | 114 tools/perf/tests/tests.h| 1 + 4 files changed, 117 insertions(+), 111 deletions(-) create mode 100644 tools/perf/tests/evsel-roundtrip-name.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 2e5197a..ad6fcb5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -437,6 +437,7 @@ LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o LIB_OBJS += $(OUTPUT)tests/mmap-basic.o LIB_OBJS += $(OUTPUT)tests/perf-record.o LIB_OBJS += $(OUTPUT)tests/rdpmc.o +LIB_OBJS += $(OUTPUT)tests/evsel-roundtrip-name.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 1e9a0ea..93f5e91 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -35,116 +35,6 @@ static int test__perf_pmu(void) return perf_pmu__test(); } -static int perf_evsel__roundtrip_cache_name_test(void) -{ - char name[128]; - int type, op, err = 0, ret = 0, i, idx; - struct perf_evsel *evsel; -struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); - -if (evlist == NULL) -return -ENOMEM; - - for (type = 0; type PERF_COUNT_HW_CACHE_MAX; type++) { - for (op = 0; op PERF_COUNT_HW_CACHE_OP_MAX; op++) { - /* skip invalid cache type */ - if (!perf_evsel__is_cache_op_valid(type, op)) - continue; - - for (i = 0; i PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { - __perf_evsel__hw_cache_type_op_res_name(type, op, i, - name, sizeof(name)); - err = parse_events(evlist, name, 0); - if (err) - ret = err; - } - } - } - - idx = 0; - evsel = perf_evlist__first(evlist); - - for (type = 0; type PERF_COUNT_HW_CACHE_MAX; type++) { - for (op = 0; op PERF_COUNT_HW_CACHE_OP_MAX; op++) { - /* skip invalid cache type */ - if (!perf_evsel__is_cache_op_valid(type, op)) - continue; - - for (i = 0; i PERF_COUNT_HW_CACHE_RESULT_MAX; i++) { - __perf_evsel__hw_cache_type_op_res_name(type, op, i, - name, sizeof(name)); - if (evsel-idx != idx) - continue; - - ++idx; - - if (strcmp(perf_evsel__name(evsel), name)) { - pr_debug(%s != %s\n, perf_evsel__name(evsel), name); - ret = -1; - } - - evsel = perf_evsel__next(evsel); - } - } - } - - perf_evlist__delete(evlist); - return ret; -} - -static int __perf_evsel__name_array_test(const char *names[], int nr_names) -{ - int i, err; - struct perf_evsel *evsel; -struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); - -if (evlist == NULL) -return -ENOMEM; - - for (i = 0; i nr_names; ++i) { - err = parse_events(evlist, names[i], 0); - if (err) { - pr_debug(failed to parse event '%s', err %d\n, -names[i], err); - goto out_delete_evlist; - } - } - - err = 0; - list_for_each_entry(evsel, evlist-entries, node) { - if (strcmp(perf_evsel__name(evsel), names[evsel-idx])) { - --err; - pr_debug(%s != %s\n, perf_evsel__name(evsel), names[evsel-idx]); - } - } - -out_delete_evlist: - perf_evlist__delete(evlist); - return err; -} - -#define perf_evsel__name_array_test(names) \ - __perf_evsel__name_array_test(names, ARRAY_SIZE(names)) - -static int perf_evsel__roundtrip_name_test(void) -{ - int err = 0, ret = 0; - - err = perf_evsel__name_array_test
[PATCH 04/12] perf tests: Move test__basic_mmap into separate object
Separating test__basic_mmap test from the builtin-test into mmap-basic object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 157 -- tools/perf/tests/mmap-basic.c | 162 tools/perf/tests/tests.h| 1 + 4 files changed, 164 insertions(+), 157 deletions(-) create mode 100644 tools/perf/tests/mmap-basic.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index d413e89..337489e 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -434,6 +434,7 @@ LIB_OBJS += $(OUTPUT)tests/attr.o LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o LIB_OBJS += $(OUTPUT)tests/open-syscall.o LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o +LIB_OBJS += $(OUTPUT)tests/mmap-basic.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 98e883b..609f592 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -30,163 +30,6 @@ #include sched.h -/* - * This test will generate random numbers of calls to some getpid syscalls, - * then establish an mmap for a group of events that are created to monitor - * the syscalls. - * - * It will receive the events, using mmap, use its PERF_SAMPLE_ID generated - * sample.id field to map back to its respective perf_evsel instance. - * - * Then it checks if the number of syscalls reported as perf events by - * the kernel corresponds to the number of syscalls made. - */ -static int test__basic_mmap(void) -{ - int err = -1; - union perf_event *event; - struct thread_map *threads; - struct cpu_map *cpus; - struct perf_evlist *evlist; - struct perf_event_attr attr = { - .type = PERF_TYPE_TRACEPOINT, - .read_format= PERF_FORMAT_ID, - .sample_type= PERF_SAMPLE_ID, - .watermark = 0, - }; - cpu_set_t cpu_set; - const char *syscall_names[] = { getsid, getppid, getpgrp, - getpgid, }; - pid_t (*syscalls[])(void) = { (void *)getsid, getppid, getpgrp, - (void*)getpgid }; -#define nsyscalls ARRAY_SIZE(syscall_names) - int ids[nsyscalls]; - unsigned int nr_events[nsyscalls], -expected_nr_events[nsyscalls], i, j; - struct perf_evsel *evsels[nsyscalls], *evsel; - - for (i = 0; i nsyscalls; ++i) { - char name[64]; - - snprintf(name, sizeof(name), sys_enter_%s, syscall_names[i]); - ids[i] = trace_event__id(name); - if (ids[i] 0) { - pr_debug(Is debugfs mounted on /sys/kernel/debug?\n); - return -1; - } - nr_events[i] = 0; - expected_nr_events[i] = random() % 257; - } - - threads = thread_map__new(-1, getpid(), UINT_MAX); - if (threads == NULL) { - pr_debug(thread_map__new\n); - return -1; - } - - cpus = cpu_map__new(NULL); - if (cpus == NULL) { - pr_debug(cpu_map__new\n); - goto out_free_threads; - } - - CPU_ZERO(cpu_set); - CPU_SET(cpus-map[0], cpu_set); - sched_setaffinity(0, sizeof(cpu_set), cpu_set); - if (sched_setaffinity(0, sizeof(cpu_set), cpu_set) 0) { - pr_debug(sched_setaffinity() failed on CPU %d: %s , -cpus-map[0], strerror(errno)); - goto out_free_cpus; - } - - evlist = perf_evlist__new(cpus, threads); - if (evlist == NULL) { - pr_debug(perf_evlist__new\n); - goto out_free_cpus; - } - - /* anonymous union fields, can't be initialized above */ - attr.wakeup_events = 1; - attr.sample_period = 1; - - for (i = 0; i nsyscalls; ++i) { - attr.config = ids[i]; - evsels[i] = perf_evsel__new(attr, i); - if (evsels[i] == NULL) { - pr_debug(perf_evsel__new\n); - goto out_free_evlist; - } - - perf_evlist__add(evlist, evsels[i]); - - if (perf_evsel__open(evsels[i], cpus, threads) 0) { - pr_debug(failed to open counter: %s, -tweak /proc/sys/kernel/perf_event_paranoid?\n, -strerror(errno)); - goto out_close_fd; - } - } - - if (perf_evlist__mmap(evlist, 128, true
[PATCH 03/12] perf tests: Move test__open_syscall_event_on_all_cpus into separate object
Separating test__open_syscall_event_on_all_cpus test from the builtin-test into open-syscall-all-cpus object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 114 - tools/perf/tests/open-syscall-all-cpus.c | 120 +++ tools/perf/tests/tests.h | 1 + 4 files changed, 122 insertions(+), 114 deletions(-) create mode 100644 tools/perf/tests/open-syscall-all-cpus.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 69f582c..d413e89 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -433,6 +433,7 @@ LIB_OBJS += $(OUTPUT)tests/dso-data.o LIB_OBJS += $(OUTPUT)tests/attr.o LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o LIB_OBJS += $(OUTPUT)tests/open-syscall.o +LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index b6b1e46..98e883b 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -29,120 +29,6 @@ #include sched.h -static int test__open_syscall_event_on_all_cpus(void) -{ - int err = -1, fd, cpu; - struct thread_map *threads; - struct cpu_map *cpus; - struct perf_evsel *evsel; - struct perf_event_attr attr; - unsigned int nr_open_calls = 111, i; - cpu_set_t cpu_set; - int id = trace_event__id(sys_enter_open); - - if (id 0) { - pr_debug(is debugfs mounted on /sys/kernel/debug?\n); - return -1; - } - - threads = thread_map__new(-1, getpid(), UINT_MAX); - if (threads == NULL) { - pr_debug(thread_map__new\n); - return -1; - } - - cpus = cpu_map__new(NULL); - if (cpus == NULL) { - pr_debug(cpu_map__new\n); - goto out_thread_map_delete; - } - - - CPU_ZERO(cpu_set); - - memset(attr, 0, sizeof(attr)); - attr.type = PERF_TYPE_TRACEPOINT; - attr.config = id; - evsel = perf_evsel__new(attr, 0); - if (evsel == NULL) { - pr_debug(perf_evsel__new\n); - goto out_thread_map_delete; - } - - if (perf_evsel__open(evsel, cpus, threads) 0) { - pr_debug(failed to open counter: %s, -tweak /proc/sys/kernel/perf_event_paranoid?\n, -strerror(errno)); - goto out_evsel_delete; - } - - for (cpu = 0; cpu cpus-nr; ++cpu) { - unsigned int ncalls = nr_open_calls + cpu; - /* -* XXX eventually lift this restriction in a way that -* keeps perf building on older glibc installations -* without CPU_ALLOC. 1024 cpus in 2010 still seems -* a reasonable upper limit tho :-) -*/ - if (cpus-map[cpu] = CPU_SETSIZE) { - pr_debug(Ignoring CPU %d\n, cpus-map[cpu]); - continue; - } - - CPU_SET(cpus-map[cpu], cpu_set); - if (sched_setaffinity(0, sizeof(cpu_set), cpu_set) 0) { - pr_debug(sched_setaffinity() failed on CPU %d: %s , -cpus-map[cpu], -strerror(errno)); - goto out_close_fd; - } - for (i = 0; i ncalls; ++i) { - fd = open(/etc/passwd, O_RDONLY); - close(fd); - } - CPU_CLR(cpus-map[cpu], cpu_set); - } - - /* -* Here we need to explicitely preallocate the counts, as if -* we use the auto allocation it will allocate just for 1 cpu, -* as we start by cpu 0. -*/ - if (perf_evsel__alloc_counts(evsel, cpus-nr) 0) { - pr_debug(perf_evsel__alloc_counts(ncpus=%d)\n, cpus-nr); - goto out_close_fd; - } - - err = 0; - - for (cpu = 0; cpu cpus-nr; ++cpu) { - unsigned int expected; - - if (cpus-map[cpu] = CPU_SETSIZE) - continue; - - if (perf_evsel__read_on_cpu(evsel, cpu, 0) 0) { - pr_debug(perf_evsel__read_on_cpu\n); - err = -1; - break; - } - - expected = nr_open_calls + cpu; - if (evsel-counts-cpu[cpu].val != expected) { - pr_debug(perf_evsel__read_on_cpu: expected to intercept %d calls on cpu %d, got
[PATCH 12/12] perf tests: Check for mkstemp return value in dso-data test
Adding check for mkstemp return error value in dso-data test. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/tests/dso-data.c | 4 1 file changed, 4 insertions(+) diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index b5198f5..5eaffa2 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -26,6 +26,10 @@ static char *test_file(int size) unsigned char *buf; fd = mkstemp(templ); + if (fd 0) { + perror(mkstemp failed); + return NULL; + } buf = malloc(size); if (!buf) { -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 05/12] perf tests: Move test__PERF_RECORD into separate object
Separating test__PERF_RECORD test from the builtin-test into perf-record object. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 1 + tools/perf/tests/builtin-test.c | 307 --- tools/perf/tests/perf-record.c | 314 tools/perf/tests/tests.h| 1 + 4 files changed, 316 insertions(+), 307 deletions(-) create mode 100644 tools/perf/tests/perf-record.c diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 337489e..a2d6153 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -435,6 +435,7 @@ LIB_OBJS += $(OUTPUT)tests/vmlinux-kallsyms.o LIB_OBJS += $(OUTPUT)tests/open-syscall.o LIB_OBJS += $(OUTPUT)tests/open-syscall-all-cpus.o LIB_OBJS += $(OUTPUT)tests/mmap-basic.o +LIB_OBJS += $(OUTPUT)tests/perf-record.o LIB_OBJS += $(OUTPUT)tests/util.o BUILTIN_OBJS += $(OUTPUT)builtin-annotate.o diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index 609f592..7cb3928 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -31,313 +31,6 @@ -static int sched__get_first_possible_cpu(pid_t pid, cpu_set_t *maskp) -{ - int i, cpu = -1, nrcpus = 1024; -realloc: - CPU_ZERO(maskp); - - if (sched_getaffinity(pid, sizeof(*maskp), maskp) == -1) { - if (errno == EINVAL nrcpus (1024 8)) { - nrcpus = nrcpus 2; - goto realloc; - } - perror(sched_getaffinity); - return -1; - } - - for (i = 0; i nrcpus; i++) { - if (CPU_ISSET(i, maskp)) { - if (cpu == -1) - cpu = i; - else - CPU_CLR(i, maskp); - } - } - - return cpu; -} - -static int test__PERF_RECORD(void) -{ - struct perf_record_opts opts = { - .target = { - .uid = UINT_MAX, - .uses_mmap = true, - }, - .no_delay = true, - .freq = 10, - .mmap_pages = 256, - }; - cpu_set_t cpu_mask; - size_t cpu_mask_size = sizeof(cpu_mask); - struct perf_evlist *evlist = perf_evlist__new(NULL, NULL); - struct perf_evsel *evsel; - struct perf_sample sample; - const char *cmd = sleep; - const char *argv[] = { cmd, 1, NULL, }; - char *bname; - u64 prev_time = 0; - bool found_cmd_mmap = false, -found_libc_mmap = false, -found_vdso_mmap = false, -found_ld_mmap = false; - int err = -1, errs = 0, i, wakeups = 0; - u32 cpu; - int total_events = 0, nr_events[PERF_RECORD_MAX] = { 0, }; - - if (evlist == NULL || argv == NULL) { - pr_debug(Not enough memory to create evlist\n); - goto out; - } - - /* -* We need at least one evsel in the evlist, use the default -* one: cycles. -*/ - err = perf_evlist__add_default(evlist); - if (err 0) { - pr_debug(Not enough memory to create evsel\n); - goto out_delete_evlist; - } - - /* -* Create maps of threads and cpus to monitor. In this case -* we start with all threads and cpus (-1, -1) but then in -* perf_evlist__prepare_workload we'll fill in the only thread -* we're monitoring, the one forked there. -*/ - err = perf_evlist__create_maps(evlist, opts.target); - if (err 0) { - pr_debug(Not enough memory to create thread/cpu maps\n); - goto out_delete_evlist; - } - - /* -* Prepare the workload in argv[] to run, it'll fork it, and then wait -* for perf_evlist__start_workload() to exec it. This is done this way -* so that we have time to open the evlist (calling sys_perf_event_open -* on all the fds) and then mmap them. -*/ - err = perf_evlist__prepare_workload(evlist, opts, argv); - if (err 0) { - pr_debug(Couldn't run the workload!\n); - goto out_delete_evlist; - } - - /* -* Config the evsels, setting attr-comm on the first one, etc. -*/ - evsel = perf_evlist__first(evlist); - evsel-attr.sample_type |= PERF_SAMPLE_CPU; - evsel-attr.sample_type |= PERF_SAMPLE_TID; - evsel-attr.sample_type |= PERF_SAMPLE_TIME; - perf_evlist__config_attrs(evlist, opts); - - err = sched__get_first_possible_cpu(evlist-workload.pid, cpu_mask); - if (err 0
[PATCH 00/12] perf tests: Move tests from builtin-test
hi, I discussed with Arnaldo of moving tests from builtin-test into separated objects.. here it is. I swear not to touch test code for a while after this one ;-) Attached patches: 01/12 perf tests: Move test__vmlinux_matches_kallsyms into separate object 02/12 perf tests: Move test__open_syscall_event into separate object 03/12 perf tests: Move test__open_syscall_event_on_all_cpus into separate object 04/12 perf tests: Move test__basic_mmap into separate object 05/12 perf tests: Move test__PERF_RECORD into separate object 06/12 perf tests: Move test__rdpmc into separate object 07/12 perf tests: Move perf_evsel__roundtrip_name_test into separate object 08/12 perf tests: Move perf_evsel__tp_sched_test into separate object 09/12 perf tests: Move test__syscall_open_tp_fields into separate object 10/12 perf tests: Move pmu tests into separate object 11/12 perf tests: Final cleanup for builtin-test move 12/12 perf tests: Check for mkstemp return value in dso-data test Also available here: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git perf/tests thanks, jirka Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/Makefile | 11 + tools/perf/perf.h |1 - tools/perf/tests/attr.c |3 +- tools/perf/tests/builtin-test.c | 1399 +-- tools/perf/tests/dso-data.c |7 +- tools/perf/tests/evsel-roundtrip-name.c | 114 + tools/perf/tests/evsel-tp-sched.c | 84 tools/perf/tests/mmap-basic.c | 162 +++ tools/perf/tests/open-syscall-all-cpus.c | 120 + tools/perf/tests/open-syscall-tp-fields.c | 117 + tools/perf/tests/open-syscall.c | 66 +++ tools/perf/tests/parse-events.c |3 +- tools/perf/tests/perf-record.c| 314 ++ tools/perf/tests/pmu.c| 178 tools/perf/tests/rdpmc.c | 175 tools/perf/tests/tests.h | 22 + tools/perf/tests/util.c | 30 ++ tools/perf/tests/vmlinux-kallsyms.c | 230 ++ tools/perf/util/parse-events.h|1 - tools/perf/util/pmu.c | 185 +--- tools/perf/util/pmu.h |4 + tools/perf/util/symbol.h |1 - 22 files changed, 1654 insertions(+), 1573 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/12] perf tests: Final cleanup for builtin-test move
Final function renames to match test__* style and include cleanup. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/perf.h | 1 - tools/perf/tests/attr.c | 3 ++- tools/perf/tests/builtin-test.c | 34 +++--- tools/perf/tests/dso-data.c | 3 ++- tools/perf/tests/parse-events.c | 3 ++- tools/perf/tests/tests.h| 3 +++ tools/perf/util/parse-events.h | 1 - tools/perf/util/symbol.h| 1 - 8 files changed, 16 insertions(+), 33 deletions(-) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 054182e..0047264 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -178,7 +178,6 @@ extern bool test_attr__enabled; void test_attr__init(void); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, int fd, int group_fd, unsigned long flags); -int test_attr__run(void); static inline int sys_perf_event_open(struct perf_event_attr *attr, diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 6e2feee..25638a9 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -27,6 +27,7 @@ #include ../perf.h #include util.h #include exec_cmd.h +#include tests.h #define ENV PERF_TEST_ATTR @@ -151,7 +152,7 @@ static int run_dir(const char *d, const char *perf) return system(cmd); } -int test_attr__run(void) +int test__attr(void) { struct stat st; char path_perf[PATH_MAX]; diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c index d3b95e0..186f675 100644 --- a/tools/perf/tests/builtin-test.c +++ b/tools/perf/tests/builtin-test.c @@ -4,31 +4,11 @@ * Builtin regression testing command: ever growing number of sanity tests */ #include builtin.h - -#include util/cache.h -#include util/color.h -#include util/debug.h -#include util/debugfs.h -#include util/evlist.h -#include util/machine.h -#include util/parse-options.h -#include util/parse-events.h -#include util/symbol.h -#include util/thread_map.h -#include util/pmu.h -#include event-parse.h -#include ../../include/linux/hw_breakpoint.h - -#include sys/mman.h - -#include util/cpumap.h -#include util/evsel.h -#include sys/types.h - #include tests.h - -#include sched.h - +#include debug.h +#include color.h +#include parse-options.h +#include symbol.h static struct test { const char *desc; @@ -52,7 +32,7 @@ static struct test { }, { .desc = parse events tests, - .func = parse_events__test, + .func = test__parse_events, }, #if defined(__x86_64__) || defined(__i386__) { @@ -70,7 +50,7 @@ static struct test { }, { .desc = Test dso data interface, - .func = dso__test_data, + .func = test__dso_data, }, { .desc = roundtrip evsel-name check, @@ -86,7 +66,7 @@ static struct test { }, { .desc = struct perf_event_attr setup, - .func = test_attr__run, + .func = test__attr, }, { .func = NULL, diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 0cd42fc..b5198f5 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c @@ -8,6 +8,7 @@ #include machine.h #include symbol.h +#include tests.h #define TEST_ASSERT_VAL(text, cond) \ do { \ @@ -95,7 +96,7 @@ struct test_data_offset offsets[] = { }, }; -int dso__test_data(void) +int test__dso_data(void) { struct machine machine; struct dso *dso; diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c index b49c2ee..f2a82d0 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -4,6 +4,7 @@ #include evlist.h #include sysfs.h #include ../../../include/linux/hw_breakpoint.h +#include tests.h #define TEST_ASSERT_VAL(text, cond) \ do { \ @@ -1086,7 +1087,7 @@ static int test_pmu_events(void) return ret; } -int parse_events__test(void) +int test__parse_events(void) { int ret1, ret2 = 0; diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h index 88a55df..fc121ed 100644 --- a/tools/perf/tests/tests.h +++ b/tools/perf/tests/tests.h @@ -12,6 +12,9 @@ int test__perf_evsel__roundtrip_name_test(void); int test__perf_evsel__tp_sched_test(void); int test__syscall_open_tp_fields(void); int test__pmu(void); +int test__attr(void); +int test__dso_data(void); +int test__parse_events(void); /* Util */ int trace_event__id(const char *evname); diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index ac9a6aa..f639937 100644 --- a/tools/perf/util
Re: [GIT PULL 00/21] perf/core improvements and fixes
On Mon, Nov 12, 2012 at 11:10:52AM +0900, Namhyung Kim wrote: Hi Arnaldo, On Fri, 9 Nov 2012 18:42:49 -0300, Arnaldo Carvalho de Melo wrote: Hi Ingo, Please consider pulling. - Arnaldo The following changes since commit 8dfec403e39b7c37fd6e8813bacc01da1e1210ab: perf tests: Removing 'optional' field (2012-11-05 14:03:59 -0300) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux tags/perf-core-for-mingo for you to fetch changes up to 27f94d52394003d444a383eaf8d4824daf32432e: tools lib traceevent: Use 'const' in variables pointing to const strings (2012-11-09 17:42:47 -0300) perf/core improvements and fixes: . Add a 'link' method for hists, so that we can have the leader with buckets for all the entries in all the hists. This new method is now used in the default 'diff' output, making the sum of the 'baseline' column be 100%, eliminating blind spots. Now we need to use this for 'diff' with 2 perf.data files and for multi event 'report' and 'annotate'. I'm not sure it can be used for group report at least in its current form. IIUC it connects multiple hist entries using a list head and create a dummy entry in the leader if need be. But it didn't handle non-leader entries so it's hard to tell which is which if less entries are present only. For example consider following case: leader member1 member2 A A A B C D where leader, member1 and member2 are evsel/hists and A, B, C and D are hist entries. After 'linking' the entries the leader will have following linkage: leader A - A - A B C (dummy) -C D (dummy) - D In this case, for entry A the leader can determine which entry came from which hists by looking its order in the list. For entry B the leader can use zero value for them since the list is empty. However for entries C and D, it cannot know which one is the right hists unless it records a hist index or creates dummy entry and insert it in a correct order (looks far from an optimal solution). Am I missing something? there's hists pointer in hist_entry if that's what you look for jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/5] perf tool: Fix attributes for '{}' defined event groups
Fixing events attributes for groups defined via '{}'. Currently 'enable_on_exec' attribute in record command and both 'disabled ' and 'enable_on_exec' attributes in stat command are set based on the 'group' option. This eliminates proper setup for '{}' defined groups as they don't set 'group' option. Making above attributes values based on the 'evsel-leader' as this is common to both group definition. Moving perf_evlist__set_leader call within builtin-record ahead perf_evlist__config_attrs call, because the latter needs possible group leader links in place. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-record.c | 8 ++-- tools/perf/builtin-stat.c | 11 --- tools/perf/tests/attr/test-record-group1 | 4 +--- tools/perf/tests/attr/test-stat-group1| 6 ++ tools/perf/tests/open-syscall-tp-fields.c | 2 +- tools/perf/util/evlist.c | 6 ++ tools/perf/util/evsel.c | 8 +++- tools/perf/util/evsel.h | 3 +-- 8 files changed, 20 insertions(+), 28 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 5783c32..3717027 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -230,11 +230,15 @@ static int perf_record__open(struct perf_record *rec) struct perf_record_opts *opts = rec-opts; int rc = 0; - perf_evlist__config_attrs(evlist, opts); - + /* +* Set the evsel leader links before we configure attributes, +* since some might depend on this info. +*/ if (opts-group) perf_evlist__set_leader(evlist); + perf_evlist__config_attrs(evlist, opts); + list_for_each_entry(pos, evlist-entries, node) { struct perf_event_attr *attr = pos-attr; /* diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 6888960..557081e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -129,8 +129,7 @@ static struct stats runtime_itlb_cache_stats[MAX_NR_CPUS]; static struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS]; static struct stats walltime_nsecs_stats; -static int create_perf_stat_counter(struct perf_evsel *evsel, - struct perf_evsel *first) +static int create_perf_stat_counter(struct perf_evsel *evsel) { struct perf_event_attr *attr = evsel-attr; bool exclude_guest_missing = false; @@ -153,7 +152,7 @@ retry: return 0; } - if (!perf_target__has_task(target) (!group || evsel == first)) { + if (!perf_target__has_task(target) (!evsel-leader)) { attr-disabled = 1; attr-enable_on_exec = 1; } @@ -272,7 +271,7 @@ static int read_counter(struct perf_evsel *counter) static int __run_perf_stat(int argc __maybe_unused, const char **argv) { unsigned long long t0, t1; - struct perf_evsel *counter, *first; + struct perf_evsel *counter; int status = 0; int child_ready_pipe[2], go_pipe[2]; const bool forks = (argc 0); @@ -332,10 +331,8 @@ static int __run_perf_stat(int argc __maybe_unused, const char **argv) if (group) perf_evlist__set_leader(evsel_list); - first = perf_evlist__first(evsel_list); - list_for_each_entry(counter, evsel_list-entries, node) { - if (create_perf_stat_counter(counter, first) 0) { + if (create_perf_stat_counter(counter) 0) { /* * PPC returns ENXIO for HW counters until 2.6.37 * (behavior changed with commit b0a873e). diff --git a/tools/perf/tests/attr/test-record-group1 b/tools/perf/tests/attr/test-record-group1 index 39bf860..013572f 100644 --- a/tools/perf/tests/attr/test-record-group1 +++ b/tools/perf/tests/attr/test-record-group1 @@ -15,6 +15,4 @@ config=1 sample_type=327 mmap=0 comm=0 -# TODO this is disabled for --group option, enabled otherwise -# check why.. -enable_on_exec=1 +enable_on_exec=0 diff --git a/tools/perf/tests/attr/test-stat-group1 b/tools/perf/tests/attr/test-stat-group1 index 5ae2718..2a1f86e 100644 --- a/tools/perf/tests/attr/test-stat-group1 +++ b/tools/perf/tests/attr/test-stat-group1 @@ -11,7 +11,5 @@ group_fd=-1 fd=2 group_fd=1 config=1 -# TODO both disabled and enable_on_exec are disabled for --group option, -# enabled otherwise, check why.. -disabled=1 -enable_on_exec=1 +disabled=0 +enable_on_exec=0 diff --git a/tools/perf/tests/open-syscall-tp-fields.c b/tools/perf/tests/open-syscall-tp-fields.c index b05b6a6..1c52fdc 100644 --- a/tools/perf/tests/open-syscall-tp
[PATCH 3/5] perf tool: Ensure single disable call per event in record comand
It's possible we issue the event disable ioctl multiple times until we read the final portion of the mmap buffer. Ensuring just single disable ioctl call for event, because there's no need to do that more than once. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-record.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 268b356..f3151d3 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -502,6 +502,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) struct perf_evlist *evsel_list = rec-evlist; const char *output_name = rec-output_name; struct perf_session *session; + bool disabled = false; rec-progname = argv[0]; @@ -735,8 +736,10 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) * die with the process and we wait for that. Thus no need to * disable events in this case. */ - if (done !perf_target__none(opts-target)) + if (done !disabled !perf_target__none(opts-target)) { perf_evlist__disable(evsel_list); + disabled = true; + } } if (quiet || signr == SIGUSR1) -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/5] perf tool: Fix enable/disable events logic for record command
hi, this patchset fixes the event enable/disable logic for record command (patches 1 - 4) plus small fix for event parsing (patch 5). Attached patches: 1/5 perf tool: Fix attributes for '{}' defined event groups 2/5 perf tool: Fix 'disabled' attribute config for record command 3/5 perf tool: Ensure single disable call per event in record comand 4/5 perf tool: Omit group members from perf_evlist__disable/enable 5/5 perf tool: Add basic event modifier sanity check Also available in: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/linux.git perf/enable5 thanks, jirka Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Namhyung Kim namhy...@kernel.org Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-record.c | 26 ++ tools/perf/builtin-stat.c | 11 --- tools/perf/tests/attr/test-record-group | 1 + tools/perf/tests/attr/test-record-group1 | 5 ++--- tools/perf/tests/attr/test-stat-group1| 6 ++ tools/perf/tests/open-syscall-tp-fields.c | 2 +- tools/perf/util/evlist.c | 10 ++ tools/perf/util/evsel.c | 50 -- tools/perf/util/evsel.h | 3 +-- tools/perf/util/parse-events.c| 20 tools/perf/util/parse-events.l| 2 +- 11 files changed, 104 insertions(+), 32 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/5] perf tool: Omit group members from perf_evlist__disable/enable
There's no need to disable/enable ordinary group member events, because they are initialy enabled and get scheduled by the leader. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/util/evlist.c | 4 1 file changed, 4 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 04acae0..e9d2d5d 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -222,6 +222,8 @@ void perf_evlist__disable(struct perf_evlist *evlist) for (cpu = 0; cpu evlist-cpus-nr; cpu++) { list_for_each_entry(pos, evlist-entries, node) { + if (pos-leader) + continue; for (thread = 0; thread evlist-threads-nr; thread++) ioctl(FD(pos, cpu, thread), PERF_EVENT_IOC_DISABLE, 0); @@ -236,6 +238,8 @@ void perf_evlist__enable(struct perf_evlist *evlist) for (cpu = 0; cpu cpu_map__nr(evlist-cpus); cpu++) { list_for_each_entry(pos, evlist-entries, node) { + if (pos-leader) + continue; for (thread = 0; thread evlist-threads-nr; thread++) ioctl(FD(pos, cpu, thread), PERF_EVENT_IOC_ENABLE, 0); -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/5] perf tool: Fix 'disabled' attribute config for record command
Currently the record command sets all events initially as disabled. There's non conditional perf_evlist__enable call, that enables all events before we exec tracee program. That actually screws whole enable_on_exec logic, because the event is enabled before the traced program got executed. What we actually want is: 1) For any type of traced program: - all independent events and group leaders are disabled - all group members are enabled Group members are ruled by group leaders. They need to be enabled, because the group scheduling relies on that. 2) For traced programs executed by perf: - all independent events and group leaders have enable_on_exec set - we don't specifically enable or disable any event during the record command Independent events and group leaders are initially disabled and get enabled by exec. Group members are ruled by group leaders as stated in 1). 3) For traced programs attached by perf (pid/tid): - we specifically enable or disable all events during the record command When attaching events to already running traced we enable/disable events specifically, as there's no initial traced exec call. Fixing appropriate perf_event_attr test case to cover this change. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/builtin-record.c | 15 ++-- tools/perf/tests/attr/test-record-group | 1 + tools/perf/tests/attr/test-record-group1 | 1 + tools/perf/util/evsel.c | 42 +++- 4 files changed, 56 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3717027..268b356 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -701,7 +701,13 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) } } - perf_evlist__enable(evsel_list); + /* +* When perf is starting the traced process, all the events +* (apart from group members) have enable_on_exec=1 set, +* so don't spoil it by prematurely enabling them. +*/ + if (!perf_target__none(opts-target)) + perf_evlist__enable(evsel_list); /* * Let the child rip @@ -724,7 +730,12 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) waking++; } - if (done) + /* +* When perf is starting the traced process, at the end events +* die with the process and we wait for that. Thus no need to +* disable events in this case. +*/ + if (done !perf_target__none(opts-target)) perf_evlist__disable(evsel_list); } diff --git a/tools/perf/tests/attr/test-record-group b/tools/perf/tests/attr/test-record-group index b945f77..a6599e9 100644 --- a/tools/perf/tests/attr/test-record-group +++ b/tools/perf/tests/attr/test-record-group @@ -15,3 +15,4 @@ sample_type=327 mmap=0 comm=0 enable_on_exec=0 +disabled=0 diff --git a/tools/perf/tests/attr/test-record-group1 b/tools/perf/tests/attr/test-record-group1 index 013572f..5a8359d 100644 --- a/tools/perf/tests/attr/test-record-group1 +++ b/tools/perf/tests/attr/test-record-group1 @@ -16,3 +16,4 @@ sample_type=327 mmap=0 comm=0 enable_on_exec=0 +disabled=0 diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 6d4a5f6..fc4faaa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -404,13 +404,40 @@ const char *perf_evsel__name(struct perf_evsel *evsel) return evsel-name ?: unknown; } +/* + * The enable_on_exec/disabled value strategy: + * + * 1) For any type of traced program: + *- all independent events and group leaders are disabled + *- all group members are enabled + * + * Group members are ruled by group leaders. They need to + * be enabled, because the group scheduling relies on that. + * + * 2) For traced programs executed by perf: + * - all independent events and group leaders have + * enable_on_exec set + * - we don't specifically enable or disable any event during + * the record command + * + * Independent events and group leaders are initially disabled + * and get enabled by exec. Group members are ruled by group + * leaders as stated in 1). + * + * 3) For traced programs attached by perf (pid/tid): + * - we specifically enable or disable all events during + * the record command + * + * When attaching events to already running traced we + * enable/disable events specifically, as there's no + * initial traced exec call
[PATCH 5/5] perf tool: Add basic event modifier sanity check
Updating event parser to allow any non zero string containing [ukhpGH] characters for event modifier. The modifier sanity is checked later in parse-event object logic. The check validates modifier to contain only one instance of any modifier (apart from 'p') present. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com --- tools/perf/util/parse-events.c | 20 tools/perf/util/parse-events.l | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c0b785b..b321d43 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -722,6 +722,23 @@ static int get_event_modifier(struct event_modifier *mod, char *str, return 0; } +/* + * Basic modifier sanity check to validate it contains only one + * instance of any modifier (apart from 'p') present. + */ +static int check_modifier(char *str) +{ + char *p = str; + + while (*p) { + if (*p != 'p' strchr(p + 1, *p)) + return -1; + p++; + } + + return 0; +} + int parse_events__modifier_event(struct list_head *list, char *str, bool add) { struct perf_evsel *evsel; @@ -730,6 +747,9 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) if (str == NULL) return 0; + if (check_modifier(str)) + return -EINVAL; + if (!add get_event_modifier(mod, str, NULL)) return -EINVAL; diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 66959fa..e9d1134 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -82,7 +82,7 @@ num_hex 0x[a-fA-F0-9]+ num_raw_hex[a-fA-F0-9]+ name [a-zA-Z_*?][a-zA-Z0-9_*?]* name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* -modifier_event [ukhpGH]{1,8} +modifier_event [ukhpGH]+ modifier_bp[rwx]{1,3} %% -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCHv2 5/5] perf tool: Add basic event modifier sanity check
On Tue, Nov 13, 2012 at 11:22:24AM +0900, Namhyung Kim wrote: Hi Jiri, On Mon, 12 Nov 2012 18:34:04 +0100, Jiri Olsa wrote: Updating event parser to allow any non zero string containing [ukhpGH] characters for event modifier. The modifier sanity is checked later in parse-event object logic. The check validates modifier to contain only one instance of any modifier (apart from 'p') present. [snip] +/* + * Basic modifier sanity check to validate it contains only one + * instance of any modifier (apart from 'p') present. + */ +static int check_modifier(char *str) +{ + char *p = str; + + while (*p) { + if (*p != 'p' strchr(p + 1, *p)) + return -1; + p++; + } How about adding a length check too? i.e. something like: if ((p - str) strlen(ukhGHppp)) return -1; ok, v2 attached thanks, jirka --- Updating event parser to allow any non zero string containing [ukhpGH] characters for event modifier. The modifier sanity is checked later in parse-event object logic. The check validates modifier to contain only one instance of any modifier (apart from 'p') present. v2: - added length check suggested Namhyung Kim Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Arnaldo Carvalho de Melo a...@redhat.com Cc: Namhyung Kim namhy...@kernel.org --- tools/perf/util/parse-events.c | 24 tools/perf/util/parse-events.l | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index c0b785b..020323a 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -722,6 +722,27 @@ static int get_event_modifier(struct event_modifier *mod, char *str, return 0; } +/* + * Basic modifier sanity check to validate it contains only one + * instance of any modifier (apart from 'p') present. + */ +static int check_modifier(char *str) +{ + char *p = str; + + /* The sizeof includes 0 byte as well. */ + if (strlen(str) (sizeof(ukhGHppp) - 1)) + return -1; + + while (*p) { + if (*p != 'p' strchr(p + 1, *p)) + return -1; + p++; + } + + return 0; +} + int parse_events__modifier_event(struct list_head *list, char *str, bool add) { struct perf_evsel *evsel; @@ -730,6 +751,9 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add) if (str == NULL) return 0; + if (check_modifier(str)) + return -EINVAL; + if (!add get_event_modifier(mod, str, NULL)) return -EINVAL; diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 66959fa..e9d1134 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -82,7 +82,7 @@ num_hex 0x[a-fA-F0-9]+ num_raw_hex[a-fA-F0-9]+ name [a-zA-Z_*?][a-zA-Z0-9_*?]* name_minus [a-zA-Z_*?][a-zA-Z0-9\-_*?]* -modifier_event [ukhpGH]{1,8} +modifier_event [ukhpGH]+ modifier_bp[rwx]{1,3} %% -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 3/4] perf/POWER7: Make event translations available in sysfs
On Wed, Nov 07, 2012 at 11:19:28AM -0800, Sukadev Bhattiprolu wrote: SNIP +struct perf_pmu_events_attr { + struct device_attribute attr; + u64 id; +}; + +extern ssize_t power_events_sysfs_show(struct device *dev, + struct device_attribute *attr, char *page); + +#define EVENT_VAR(_id) event_attr_##_id +#define EVENT_PTR(_id) event_attr_##_id.attr.attr + +#define EVENT_ATTR(_name, _id) \ + static struct perf_pmu_events_attr EVENT_VAR(_id) = { \ + .attr = __ATTR(_name, 0444, power_events_sysfs_show, NULL),\ + .id = PM_##_id, \ + }; this is duplicating the x86 code, perhaps it could be moved to include/linux/perf_event.h and shared globaly diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index aa2465e..19b23bd 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -1305,6 +1305,16 @@ static int power_pmu_event_idx(struct perf_event *event) return event-hw.idx; } +ssize_t power_events_sysfs_show(struct device *dev, + struct device_attribute *attr, char *page) +{ + struct perf_pmu_events_attr *pmu_attr; + + pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr); + + return sprintf(page, event=0x%02llx\n, pmu_attr-id); whitespace issues jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/4] perf: Create a sysfs entry for Power event format
On Wed, Nov 07, 2012 at 11:19:52AM -0800, Sukadev Bhattiprolu wrote: From bafc551c31ce23c1cba0b75d23de6c46aba90f26 Mon Sep 17 00:00:00 2001 From: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Date: Tue, 6 Nov 2012 16:30:28 -0800 Subject: [PATCH 4/4] perf: Create a sysfs entry for Power event format Create a sysfs entry, '/sys/bus/event_source/devices/cpu/format/event' which describes the format of a POWER cpu. $ cat /sys/bus/event_source/devices/cpu/format/event config:0-20 The format of the event is the same for all POWER cpus, so bulk of this change is in the code common to POWER cpus. Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com --- arch/powerpc/include/asm/perf_event_server.h |8 arch/powerpc/perf/core-book3s.c | 19 +++ arch/powerpc/perf/power7-pmu.c |1 + 3 files changed, 28 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h index ad84f73..20a49bf 100644 --- a/arch/powerpc/include/asm/perf_event_server.h +++ b/arch/powerpc/include/asm/perf_event_server.h @@ -130,3 +130,11 @@ extern ssize_t power_events_sysfs_show(struct device *dev, .attr = __ATTR(_name, 0444, power_events_sysfs_show, NULL),\ .id = PM_##_id, \ }; + +/* + * Format of a perf event is the same on all POWER cpus. Declare a + * common sysfs attribute group that individual POWER cpus can share. + */ +extern struct attribute_group power_pmu_format_group; + + diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index 19b23bd..388e2a1 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c @@ -1315,6 +1315,25 @@ ssize_t power_events_sysfs_show(struct device *dev, return sprintf(page, event=0x%02llx\n, pmu_attr-id); } +static ssize_t power_config_sysfs_show(struct device *dev, + struct device_attribute *attr, char *page) +{ + return sprintf(page, config:0-20\n); +} + +static struct device_attribute config_dev_attr = \ + __ATTR(event, 0444, power_config_sysfs_show, NULL); there's PMU_FORMAT_ATTR in include/linux/perf_event.h macro doing this jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] perf ui/browser: Fix off-by-two bug on the first column
On Mon, Oct 15, 2012 at 11:33:58AM +0900, Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com The commit 5395a04841fc (perf hists: Separate overhead and baseline columns) makes the Overhead column no more the first one. So it resulted in the mis-aligned column in the normal (non-diff) output. Reported-by: Markus Trippelsdorf mar...@trippelsdorf.de Cc: Jiri Olsa jo...@redhat.com Signed-off-by: Namhyung Kim namhy...@kernel.org eek, missed that one ;) thanks! Acked-by: Jiri Olsa jo...@redhat.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 00/20] perf report: Add support for event group view (v3)
On Thu, Oct 04, 2012 at 09:49:34PM +0900, Namhyung Kim wrote: Hi, This is my v3 of event group view support. For basic idea and usage example, please see my original post [1]. I rebased the series on top of selected hpp changes from Jiri's diff patchset [2] since it contains cleanups and improves that can be used in this series too. You can also get it via my tree at: git://git.kernel.org/pub/scm/linux/kernel/git/namhyung/linux-perf.git perf/group-v3 Any comments are welcome, thanks, Namhyung v2 - v3: * drop patch 1 since it's merged into acme/perf/core * cherry-pick Jiri's hpp changes * add missing bswap_32 on reading nr_groups (Jiri) * remove perf_evlist__recalc_nr_groups() in favor of list_is_last (Jiri) Acked-by: Jiri Olsa jo...@redhat.com for patches 10 to 20, the rest is already in thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv3 0/3] perf tool: Add new event group management
On Tue, Jul 17, 2012 at 09:15:23AM +0200, Stephane Eranian wrote: On Mon, Jul 9, 2012 at 1:05 PM, Jiri Olsa jo...@redhat.com wrote: On Fri, Jul 06, 2012 at 03:42:54AM +0200, Stephane Eranian wrote: On Fri, Jul 6, 2012 at 3:32 AM, Ulrich Drepper drep...@gmail.com wrote: On Thu, Jul 5, 2012 at 12:15 PM, Stephane Eranian eran...@google.com wrote: I don't understand why you actually need the :2 suffix. There can only be one leader. So assume it is the first one. Users have to know the first one is the leader which seems like a natural thing to do for me. It would make you syntax less ugly than it already is. In a blue sky world I would have done this. In fact, this is what I tried before reading the sources to find out there is no group support so far. But given that multiple -e options already have a meaning I would be hesitant to change this. That's why I said you activate grouping via -e only when you have the --group-events or --group-reads option in front. That would not change the meaning of the multiple -e when none of those group options are specified. I discussed this with peter.. peterz the {} thing allows: 1) multiple groups in a single -e, 2) group attributes And what's the value of 1) exactly? What's wrong with passing multiple -e ? The only group attribute I can think of would be :u, :k. Not so much typing. as for the leader sampling, we can have the first event to become the leader by default (omit the leader index modifier) and enable the leader sampling by another modifier: I don't understand this sentence. peterz right, just make it a single 'l' (el not one) to indicate 'leader' sampling To me ,this looks a bit of an over-engineered design and it is not based on any actual user requests. Don't get me wrong, grouping is useful and required but nobody has ever asked for that level of flexibility. The syntax you have now is already very rich for my taste. Well, I personally like the '{}' syntax more than '--group-events or --group-reads option in front', it feels more user friendly.. anyway, we can easily have both ways. As for the group attributes and group leader sampling, I don't mind omitting them at this point and get back to that if we find it useful in future. jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCHv3 0/3] perf tool: Add new event group management
On Wed, Jul 18, 2012 at 08:34:10AM -0400, Ulrich Drepper wrote: On Wed, Jul 18, 2012 at 6:21 AM, Jiri Olsa jo...@redhat.com wrote: Well, I personally like the '{}' syntax more than '--group-events or --group-reads option in front', it feels more user friendly.. anyway, we can easily have both ways. I like the actual visual grouping better, too. Also, it doesn't require us to define what -e E1,E2 --group-events -e E3,E4 means. Does --group-events also apply to the first parameter? As for the group attributes and group leader sampling, I don't mind omitting them at this point and get back to that if we find it useful in future. Just define the first event the leader. What reason is there which prevents this? yep, no problem.. first one is the leader The group sampling is just another feature where you enable sampling only for the leader and the rest of the events in the group are only being read on leader's sample - they don't sample by themselves. But this feature needs more testing, and event modifier syntax rethinking ;) I'll send it later.. I can only second what Andi wrote: just get it done quickly. This is functionality that is desperately needed. I have new patchset ready with group modifiers adding modifiers to events in the group, like: {cycles:u,instructions:u}:p adds 'p' to both events in the group (in current patchset group modifier overwrites events modifiers) if there's strong opinion/reasons against it, I can simply remove it, but it looks helpful jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/4] perf, tool: Add support to update event modifier
Adding support to update already defined event's attribute with event modifier. This change will allow to use group modifier as an update to the existing event modifiers. Adding 'add' parameter to the parse_events__modifier_event function. Calling it with 'add' = false/true, the event modifier is initialized/updated respectively. Added exclude_GH flag to evsel struct, because we need to remember if one of 'GH' modifiers was used for event. The reason is that the default settings for exclude_guest is 1 and during the group modifier processing we have no other way of knowing if it was set by default or by event modifier. Keeping the current behaviour, that any event/group modifier reset the defaults for exclude_host (0) and exclude_guest (1). Signed-off-by: Jiri Olsa jo...@redhat.com --- tools/perf/util/evsel.h|2 ++ tools/perf/util/parse-events.c | 74 +--- tools/perf/util/parse-events.h |2 +- tools/perf/util/parse-events.y |2 +- 4 files changed, 66 insertions(+), 14 deletions(-) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 67cc503..fbbdfa0 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -66,6 +66,8 @@ struct perf_evsel { void*data; } handler; boolsupported; + /* parse modifier helper */ + int exclude_GH; }; struct cpu_map; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 82938df..a191f4c 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -631,14 +631,38 @@ void parse_events_update_lists(struct list_head *list_event, free(list_event); } -int parse_events__modifier_event(struct list_head *list, char *str) +struct event_modifier { + int eu; + int ek; + int eh; + int eH; + int eG; + int precise; + int exclude_GH; +}; + +static int get_event_modifier(struct event_modifier *mod, char *str, + struct perf_evsel *evsel) { - struct perf_evsel *evsel; - int exclude = 0, exclude_GH = 0; - int eu = 0, ek = 0, eh = 0, eH = 0, eG = 0, precise = 0; + int eu = evsel ? evsel-attr.exclude_user : 0; + int ek = evsel ? evsel-attr.exclude_kernel : 0; + int eh = evsel ? evsel-attr.exclude_hv : 0; + int eH = evsel ? evsel-attr.exclude_host : 0; + int eG = evsel ? evsel-attr.exclude_guest : 0; + int precise = evsel ? evsel-attr.precise_ip : 0; - if (str == NULL) - return 0; + int exclude = eu | ek | eh; + int exclude_GH = evsel ? evsel-exclude_GH : 0; + + /* +* We are here for group and 'GH' was not set as event +* modifier and whatever event/group modifier override +* default 'GH' setup. +*/ + if (evsel !exclude_GH) + eH = eG = 0; + + memset(mod, 0, sizeof(*mod)); while (*str) { if (*str == 'u') { @@ -682,13 +706,39 @@ int parse_events__modifier_event(struct list_head *list, char *str) if (precise 3) return -EINVAL; + mod-eu = eu; + mod-ek = ek; + mod-eh = eh; + mod-eH = eH; + mod-eG = eG; + mod-precise = precise; + mod-exclude_GH = exclude_GH; + return 0; +} + +int parse_events__modifier_event(struct list_head *list, char *str, bool add) +{ + struct perf_evsel *evsel; + struct event_modifier mod; + + if (str == NULL) + return 0; + + if (!add get_event_modifier(mod, str, NULL)) + return -EINVAL; + list_for_each_entry(evsel, list, node) { - evsel-attr.exclude_user = eu; - evsel-attr.exclude_kernel = ek; - evsel-attr.exclude_hv = eh; - evsel-attr.precise_ip = precise; - evsel-attr.exclude_host = eH; - evsel-attr.exclude_guest = eG; + + if (add get_event_modifier(mod, str, evsel)) + return -EINVAL; + + evsel-attr.exclude_user = mod.eu; + evsel-attr.exclude_kernel = mod.ek; + evsel-attr.exclude_hv = mod.eh; + evsel-attr.precise_ip = mod.precise; + evsel-attr.exclude_host = mod.eH; + evsel-attr.exclude_guest = mod.eG; + evsel-exclude_GH = mod.exclude_GH; } return 0; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index c2f2ed9..84228d5 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -79,7 +79,7 @@ int parse_events__term_str(struct parse_events__term **_term, int parse_events__term_clone(struct parse_events__term **new, struct parse_events__term *term); void parse_events__free_terms(struct list_head *terms
[PATCHv4 0/4] perf tool: Add new event group management
hi, adding support for creating event groups based on the way they are specified on the command line. This patchset adds the '{}' style grammar to express event group, allowing so far only the 'event modifier' as group modifier. v4 changes: - group modifier updates events modifiers (not overwrite as in v3) Attached patches: perf, tool: Add support to parse event group syntax perf, tool: Add support to update event modifier perf, tool: Enable grouping logic for parsed events perf, test: Add automated tests for event group parsing wbr, jirka --- tools/perf/builtin-record.c | 13 ++- tools/perf/builtin-stat.c | 13 ++- tools/perf/builtin-test.c |8 +- tools/perf/builtin-top.c| 12 +-- tools/perf/util/evlist.c| 20 ++--- tools/perf/util/evlist.h|3 +- tools/perf/util/evsel.c | 51 +++ tools/perf/util/evsel.h | 13 +-- tools/perf/util/parse-events-test.c | 303 - tools/perf/util/parse-events.c | 104 +++--- tools/perf/util/parse-events.h |5 +- tools/perf/util/parse-events.l |2 + tools/perf/util/parse-events.y | 93 +--- tools/perf/util/python.c|7 +- 14 files changed, 552 insertions(+), 95 deletions(-) -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 3/4] perf, tool: Enable grouping logic for parsed events
This patch adds a functionality that allows to create event groups based on the way they are specified on the command line. Adding functionality to the '{}' group syntax introduced in earlier patch. The current '--group/-g' option behaviour remains intact. If you specify it for record/stat/top command, all the specified events become members of a single group with the first event as a group leader. With the new '{}' group syntax you can create group like: # perf record -e '{cycles,faults}' ls resulting in single event group containing 'cycles' and 'faults' events, with cycles event as group leader. All groups are created with regards to threads and cpus. Thus recording an event group within a 2 threads on server with 4 CPUs will create 8 separate groups. Examples (first event in brackets is group leader): # 1 group (cpu-clock,task-clock) perf record --group -e cpu-clock,task-clock ls perf record -e '{cpu-clock,task-clock}' ls # 2 groups (cpu-clock,task-clock) (minor-faults,major-faults) perf record -e '{cpu-clock,task-clock},{minor-faults,major-faults}' ls # 1 group (cpu-clock,task-clock,minor-faults,major-faults) perf record --group -e cpu-clock,task-clock -e minor-faults,major-faults ls perf record -e '{cpu-clock,task-clock,minor-faults,major-faults}' ls # 2 groups (cpu-clock,task-clock) (minor-faults,major-faults) perf record -e '{cpu-clock,task-clock} -e '{minor-faults,major-faults}' \ -e instructions ls # 1 group (cpu-clock,task-clock,minor-faults,major-faults,instructions) perf record --group -e cpu-clock,task-clock \ -e minor-faults,major-faults -e instructions ls perf record -e '{cpu-clock,task-clock,minor-faults,major-faults,instructions}' ls It's possible to use standard event modifier for a group, which spans over all events in the group and updates each event modifier settings, for example: # perf record -r '{faults:k,cache-references}:p' resulting in ':kp' modifier being used for 'faults' and ':p' modifier being used for 'cache-references' event. Signed-off-by: Jiri Olsa jo...@redhat.com --- tools/perf/builtin-record.c| 13 -- tools/perf/builtin-stat.c | 13 -- tools/perf/builtin-test.c |8 +++ tools/perf/builtin-top.c | 12 -- tools/perf/util/evlist.c | 20 +++- tools/perf/util/evlist.h |3 ++- tools/perf/util/evsel.c| 51 ++-- tools/perf/util/evsel.h| 11 - tools/perf/util/parse-events.c | 26 tools/perf/util/parse-events.h |1 + tools/perf/util/python.c |7 -- 11 files changed, 96 insertions(+), 69 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f5a6452..94d6b12 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -176,18 +176,18 @@ static bool perf_evlist__equal(struct perf_evlist *evlist, static void perf_record__open(struct perf_record *rec) { - struct perf_evsel *pos, *first; + struct perf_evsel *pos; struct perf_evlist *evlist = rec-evlist; struct perf_session *session = rec-session; struct perf_record_opts *opts = rec-opts; - first = list_entry(evlist-entries.next, struct perf_evsel, node); - perf_evlist__config_attrs(evlist, opts); + if (opts-group) + perf_evlist__group(evlist); + list_for_each_entry(pos, evlist-entries, node) { struct perf_event_attr *attr = pos-attr; - struct xyarray *group_fd = NULL; /* * Check if parse_single_tracepoint_event has already asked for * PERF_SAMPLE_TIME. @@ -202,16 +202,13 @@ static void perf_record__open(struct perf_record *rec) */ bool time_needed = attr-sample_type PERF_SAMPLE_TIME; - if (opts-group pos != first) - group_fd = first-fd; fallback_missing_features: if (opts-exclude_guest_missing) attr-exclude_guest = attr-exclude_host = 0; retry_sample_id: attr-sample_id_all = opts-sample_id_all_missing ? 0 : 1; try_again: - if (perf_evsel__open(pos, evlist-cpus, evlist-threads, -opts-group, group_fd) 0) { + if (perf_evsel__open(pos, evlist-cpus, evlist-threads) 0) { int err = errno; if (err == EPERM || err == EACCES) { diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 861f0ae..23908a8 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -281,13 +281,9 @@ static int create_perf_stat_counter(struct perf_evsel *evsel, struct perf_evsel *first) { struct perf_event_attr *attr = evsel-attr; - struct xyarray *group_fd = NULL; bool
[PATCH 1/4] perf, tool: Add support to parse event group syntax
Adding scanner/parser bits to parse event groups. The grammar for group is: groups: groups ',' group | group group: group_name '{' events '}' group_mod group_name: name | empty group_mod: ':' group_mods | empty group_mods: event_mod It's possible to use standard event modifier as a modifier for group. It'll be used as an update to existing event modifiers. It's necessary to use quoting ('\) when specifying group on command line, since {} characters are interpreted by most of the shells. It is now possible to specify groups in event syntax like: '{cycles,faults}' - anonymous group 'group1{cycles,faults} - group with name 'group1' '{cycles,faults}:k - anonymous group with event modifier 'k' '{cpu-clock,task-clock},{minor-faults,major-faults}' - two anonymous groups The grouping functionality itself is coming shortly. Signed-off-by: Jiri Olsa jo...@redhat.com --- tools/perf/util/parse-events.c | 14 +- tools/perf/util/parse-events.h |4 +- tools/perf/util/parse-events.l |2 + tools/perf/util/parse-events.y | 93 ++-- 4 files changed, 97 insertions(+), 16 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 1aa721d..82938df 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -609,19 +609,29 @@ int parse_events_add_pmu(struct list_head **list, int *idx, pmu_event_name(head_config)); } +int parse_events__modifier_group(struct list_head *list __used, +char *event_mod __used) +{ + return 0; +} + +void parse_events__group(char *name __used, struct list_head *list __used) +{ +} + void parse_events_update_lists(struct list_head *list_event, struct list_head *list_all) { /* * Called for single event definition. Update the -* 'all event' list, and reinit the 'signle event' +* 'all event' list, and reinit the 'single event' * list, for next event definition. */ list_splice_tail(list_event, list_all); free(list_event); } -int parse_events_modifier(struct list_head *list, char *str) +int parse_events__modifier_event(struct list_head *list, char *str) { struct perf_evsel *evsel; int exclude = 0, exclude_GH = 0; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index ee9c218..c2f2ed9 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -79,7 +79,8 @@ int parse_events__term_str(struct parse_events__term **_term, int parse_events__term_clone(struct parse_events__term **new, struct parse_events__term *term); void parse_events__free_terms(struct list_head *terms); -int parse_events_modifier(struct list_head *list, char *str); +int parse_events__modifier_event(struct list_head *list, char *str); +int parse_events__modifier_group(struct list_head *list, char *event_mod); int parse_events_add_tracepoint(struct list_head **list, int *idx, char *sys, char *event); int parse_events_add_numeric(struct list_head **list, int *idx, @@ -91,6 +92,7 @@ int parse_events_add_breakpoint(struct list_head **list, int *idx, void *ptr, char *type); int parse_events_add_pmu(struct list_head **list, int *idx, char *pmu , struct list_head *head_config); +void parse_events__group(char *name, struct list_head *list); void parse_events_update_lists(struct list_head *list_event, struct list_head *list_all); void parse_events_error(void *data, void *scanner, char const *msg); diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index 384ca74..153c6ee 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -151,6 +151,8 @@ r{num_raw_hex} { return raw(yyscanner); } - { return '-'; } , { return ','; } : { return ':'; } +{{ return '{'; } +}{ return '}'; } = { return '='; } \n { } diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y index 2bc5fbf..11b6972 100644 --- a/tools/perf/util/parse-events.y +++ b/tools/perf/util/parse-events.y @@ -30,7 +30,7 @@ do { \ %token PE_NAME %token PE_MODIFIER_EVENT PE_MODIFIER_BP %token PE_NAME_CACHE_TYPE PE_NAME_CACHE_OP_RESULT -%token PE_PREFIX_MEM PE_PREFIX_RAW +%token PE_PREFIX_MEM PE_PREFIX_RAW PE_PREFIX_GROUP %token PE_ERROR %type num PE_VALUE %type num PE_VALUE_SYM_HW @@ -53,6 +53,11 @@ do { \ %type head event_legacy_numeric %type head event_legacy_raw %type head event_def +%type head event +%type head events +%type head group_def +%type head group +%type head groups %union { @@ -64,33 +69,95
[PATCH 4/4] perf, test: Add automated tests for event group parsing
Adding 5 more tests for new event group syntax. Tests are executed within the 'perf test parse' test suite. Signed-off-by: Jiri Olsa jo...@redhat.com --- tools/perf/util/parse-events-test.c | 303 ++- 1 file changed, 300 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c index 1b997d2..6200e3f 100644 --- a/tools/perf/util/parse-events-test.c +++ b/tools/perf/util/parse-events-test.c @@ -513,6 +513,286 @@ static int test__checkterms_simple(struct list_head *terms) return 0; } +static int test__group1(struct perf_evlist *evlist) +{ + struct perf_evsel *evsel, *leader; + + TEST_ASSERT_VAL(wrong number of entries, 2 == evlist-nr_entries); + + /* instructions:k */ + evsel = leader = list_entry(evlist-entries.next, + struct perf_evsel, node); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type); + TEST_ASSERT_VAL(wrong config, + PERF_COUNT_HW_INSTRUCTIONS == evsel-attr.config); + TEST_ASSERT_VAL(wrong exclude_user, evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest); + TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host); + TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip); + TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL); + + /* cycles:upp */ + evsel = list_entry(evsel-node.next, struct perf_evsel, node); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type); + TEST_ASSERT_VAL(wrong config, + PERF_COUNT_HW_CPU_CYCLES == evsel-attr.config); + TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest); + TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host); + TEST_ASSERT_VAL(wrong precise_ip, evsel-attr.precise_ip == 2); + TEST_ASSERT_VAL(wrong leader, evsel-leader == leader); + + return 0; +} + +static int test__group2(struct perf_evlist *evlist) +{ + struct perf_evsel *evsel, *leader; + + TEST_ASSERT_VAL(wrong number of entries, 3 == evlist-nr_entries); + + /* faults + :ku modifier */ + evsel = leader = list_entry(evlist-entries.next, + struct perf_evsel, node); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_SOFTWARE == evsel-attr.type); + TEST_ASSERT_VAL(wrong config, + PERF_COUNT_SW_PAGE_FAULTS == evsel-attr.config); + TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest); + TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host); + TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip); + TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL); + + /* cache-references + :u modifier */ + evsel = list_entry(evsel-node.next, struct perf_evsel, node); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type); + TEST_ASSERT_VAL(wrong config, + PERF_COUNT_HW_CACHE_REFERENCES == evsel-attr.config); + TEST_ASSERT_VAL(wrong exclude_user, !evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest); + TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host); + TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip); + TEST_ASSERT_VAL(wrong leader, evsel-leader == leader); + + /* cycles:k */ + evsel = list_entry(evsel-node.next, struct perf_evsel, node); + TEST_ASSERT_VAL(wrong type, PERF_TYPE_HARDWARE == evsel-attr.type); + TEST_ASSERT_VAL(wrong config, + PERF_COUNT_HW_CPU_CYCLES == evsel-attr.config); + TEST_ASSERT_VAL(wrong exclude_user, evsel-attr.exclude_user); + TEST_ASSERT_VAL(wrong exclude_kernel, !evsel-attr.exclude_kernel); + TEST_ASSERT_VAL(wrong exclude_hv, evsel-attr.exclude_hv); + TEST_ASSERT_VAL(wrong exclude guest, !evsel-attr.exclude_guest); + TEST_ASSERT_VAL(wrong exclude host, !evsel-attr.exclude_host); + TEST_ASSERT_VAL(wrong precise_ip, !evsel-attr.precise_ip); + TEST_ASSERT_VAL(wrong leader, evsel-leader == NULL); + + return 0; +} + +static int test__group3
Re: [PATCHv4 0/4] perf tool: Add new event group management
On Fri, Jul 20, 2012 at 05:09:33PM +0900, Namhyung Kim wrote: Hi, Jiri On Thu, 19 Jul 2012 23:53:53 +0200, Jiri Olsa wrote: hi, adding support for creating event groups based on the way they are specified on the command line. This patchset adds the '{}' style grammar to express event group, allowing so far only the 'event modifier' as group modifier. v4 changes: - group modifier updates events modifiers (not overwrite as in v3) Attached patches: perf, tool: Add support to parse event group syntax perf, tool: Add support to update event modifier perf, tool: Enable grouping logic for parsed events perf, test: Add automated tests for event group parsing Thanks for keeping working on this. You can add my Reviewed-by: Namhyung Kim namhy...@kernel.org for all of the patches if you want. great, thanks! Btw, is it all of your user-space changes? I have changes for the group leader sampling, which needs more testing.. also maybe some redo after I saw your hist changes.. ;) jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 0/5] perf: Add support for hardware breakpoint address masks
On Tue, Apr 09, 2013 at 12:21:48PM -0500, Jacob Shin wrote: The following patchset adds address masks to existing perf hardware breakpoint mechanism to allow trapping on an address range (currently only single address) on supported architectures. perf uapi is updated, x86 AMD implementation (for AMD Family 16h and beyond) is provided, and perf tool has been extended to do: $ perf stat -e mem:0x1000:w:0xf a.out ^^^ don't care bit mask which will count writes to [0x1000 ~ 0x1010) Jacob Shin (2): perf: Add hardware breakpoint address mask perf, x86: AMD implementation for hardware breakpoint address mask Suravee Suthikulpanit (3): perf tools: Add breakpoint address mask to the mem event parser perf tools: Add breakpoint address mask syntax to perf list and documentation perf tools: Add breakpoint address mask test case to tests/parse-events hi, the perf tool patches look ok.. thanks for tests! ;) jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC/PATCH] perf: Expand definition of sysfs format attribute
On Mon, Apr 08, 2013 at 09:57:50PM +1000, Michael Ellerman wrote: SNIP ISTR discussing this with Jiri at some point.. I think we ended up with being fine with overlapping ranges but having perf issue a warning (not an error) when attributes of a single event have overlap. OK great. I'm not sure the latter was ever implemented in the userspace side. Yeah not that I can see with a quick look. It's fairly advanced usage IMHO so a warning would be nice, but not essential. oops, missed this email.. sry it should be ok to overlap.. we don't check those ranges in perf tool now.. just take whatever is defined in format file adding the warning to my todo list ;-) jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 02/27] perf tools: Fix tab vs spaces issue in Makefile ifdef/endif
Unmatched spaces/tabs Makefile indentation could make the Makefile fails. While the tabed line could be considered sometimes as follow up for rule command, the mixed space tab meses up with makefile if conditions. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index b0f164b..c8fb0fd 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -90,7 +90,7 @@ endif # Treat warnings as errors unless directed not to ifneq ($(WERROR),0) - CFLAGS_WERROR := -Werror + CFLAGS_WERROR := -Werror endif ifeq ($(origin DEBUG), command line) @@ -819,10 +819,10 @@ endif ifdef NO_DEMANGLE BASIC_CFLAGS += -DNO_DEMANGLE else -ifdef HAVE_CPLUS_DEMANGLE + ifdef HAVE_CPLUS_DEMANGLE EXTLIBS += -liberty BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE -else + else FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) ifeq ($(has_bfd),y) -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 06/27] perf tools: Move libelf check config into config/Makefile
Moving libelf check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 46 - tools/perf/config/Makefile | 47 ++ 2 files changed, 47 insertions(+), 46 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index dcae71b..0ea3359 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -461,45 +461,6 @@ ifneq ($(MAKECMDGOALS),tags) # because maintaining the nesting to match is a pain. If # we had elif things would have been much nicer... -ifdef NO_LIBELF - NO_DWARF := 1 - NO_DEMANGLE := 1 - NO_LIBUNWIND := 1 -else -FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) - FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) - ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) - LIBC_SUPPORT := 1 - endif - ifeq ($(BIONIC),1) - LIBC_SUPPORT := 1 - endif - ifeq ($(LIBC_SUPPORT),1) - msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); - - NO_LIBELF := 1 - NO_DWARF := 1 - NO_DEMANGLE := 1 - else - msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); - endif -else - # for linking with debug library, run like: - # make DEBUG=1 LIBDW_DIR=/opt/libdw/ - ifdef LIBDW_DIR - LIBDW_CFLAGS := -I$(LIBDW_DIR)/include - LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib - endif - - FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) - ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) - msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); - NO_DWARF := 1 - endif # Dwarf support -endif # SOURCE_LIBELF -endif # NO_LIBELF - # There's only x86 (both 32 and 64) support for CFI unwind so far ifneq ($(ARCH),x86) NO_LIBUNWIND := 1 @@ -541,13 +502,6 @@ BUILTIN_OBJS := $(filter-out $(OUTPUT)builtin-probe.o,$(BUILTIN_OBJS)) LIB_OBJS += $(OUTPUT)util/symbol-minimal.o else # NO_LIBELF -BASIC_CFLAGS += -DLIBELF_SUPPORT - -FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) - BASIC_CFLAGS += -DLIBELF_MMAP -endif - ifndef NO_DWARF ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 9ce522a..ef09d6c 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -108,3 +108,50 @@ ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) BASIC_CFLAGS += -I. endif + +ifdef NO_LIBELF + NO_DWARF := 1 + NO_DEMANGLE := 1 + NO_LIBUNWIND := 1 +else +FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) +ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) + FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) + ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) + LIBC_SUPPORT := 1 + endif + ifeq ($(BIONIC),1) + LIBC_SUPPORT := 1 + endif + ifeq ($(LIBC_SUPPORT),1) + msg := $(warning No libelf found, disables 'probe' tool, please install elfutils-libelf-devel/libelf-dev); + + NO_LIBELF := 1 + NO_DWARF := 1 + NO_DEMANGLE := 1 + else + msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + endif +else + # for linking with debug library, run like: + # make DEBUG=1 LIBDW_DIR=/opt/libdw/ + ifdef LIBDW_DIR + LIBDW_CFLAGS := -I$(LIBDW_DIR)/include + LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib + endif + + FLAGS_DWARF=$(ALL_CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) + ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) + msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); + NO_DWARF := 1
[PATCH 05/27] perf tools: Move compiler and linker flags check into config/Makefile
Moving compiler and linker flags check into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 110 - tools/perf/config/Makefile | 66 +++ 2 files changed, 85 insertions(+), 91 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 8dd3320..dcae71b 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -52,6 +52,20 @@ include config/utilities.mak # # Define NO_LIBNUMA if you do not want numa perf benchmark +ifeq ($(srctree),) +srctree := $(patsubst %/,%,$(dir $(shell pwd))) +srctree := $(patsubst %/,%,$(dir $(srctree))) +#$(info Determined 'srctree' to be $(srctree)) +endif + +ifneq ($(objtree),) +#$(info Determined 'objtree' to be $(objtree)) +endif + +ifneq ($(OUTPUT),) +#$(info Determined 'OUTPUT' to be $(OUTPUT)) +endif + $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) @@ -66,37 +80,17 @@ FLEX= flex BISON = bison STRIP ?= strip +LK_DIR = ../lib/lk/ +TRACE_EVENT_DIR = ../lib/traceevent/ + ifeq ($(filter clean tags,$(MAKECMDGOALS)),) include config/Makefile endif -# Treat warnings as errors unless directed not to -ifneq ($(WERROR),0) - CFLAGS_WERROR := -Werror -endif - -ifeq ($(origin DEBUG), command line) - PERF_DEBUG = $(DEBUG) -endif -ifndef PERF_DEBUG - CFLAGS_OPTIMIZE = -O6 -endif - -ifdef PARSER_DEBUG - PARSER_DEBUG_BISON := -t - PARSER_DEBUG_FLEX := -d - PARSER_DEBUG_CFLAGS := -DPARSER_DEBUG -endif - ifdef NO_NEWT NO_SLANG=1 endif -CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) $(PARSER_DEBUG_CFLAGS) -EXTLIBS = -lpthread -lrt -lelf -lm -ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -ALL_LDFLAGS = $(LDFLAGS) - # Among the variables below, these: # perfexecdir # template_dir @@ -136,71 +130,6 @@ export prefix bindir sharedir sysconfdir # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),tags) --include config/feature-tests.mak - -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) - CFLAGS := $(CFLAGS) -fstack-protector-all -endif - -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wstack-protector,-Wstack-protector),y) - CFLAGS := $(CFLAGS) -Wstack-protector -endif - -ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -Wvolatile-register-var,-Wvolatile-register-var),y) - CFLAGS := $(CFLAGS) -Wvolatile-register-var -endif - -ifndef PERF_DEBUG - ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y) - CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2 - endif -endif - -### --- END CONFIGURATION SECTION --- - -ifeq ($(srctree),) -srctree := $(patsubst %/,%,$(dir $(shell pwd))) -srctree := $(patsubst %/,%,$(dir $(srctree))) -#$(info Determined 'srctree' to be $(srctree)) -endif - -ifneq ($(objtree),) -#$(info Determined 'objtree' to be $(objtree)) -endif - -ifneq ($(OUTPUT),) -#$(info Determined 'OUTPUT' to be $(OUTPUT)) -endif - -BASIC_CFLAGS = \ - -Iutil/include \ - -Iarch/$(ARCH)/include \ - $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ - -I$(srctree)/arch/$(ARCH)/include/uapi \ - -I$(srctree)/arch/$(ARCH)/include \ - $(if $(objtree),-I$(objtree)/include/generated/uapi) \ - -I$(srctree)/include/uapi \ - -I$(srctree)/include \ - -I$(OUTPUT)util \ - -Iutil \ - -I. \ - -I$(TRACE_EVENT_DIR) \ - -I../lib/ \ - -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE - -BASIC_LDFLAGS = - -ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) - BIONIC := 1 - EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) - EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) - BASIC_CFLAGS += -I. -endif -endif # MAKECMDGOALS != tags -endif # MAKECMDGOALS != clean - # Guard against environment variables BUILTIN_OBJS = LIB_H = @@ -213,9 +142,6 @@ SCRIPT_SH += perf-archive.sh grep-libs = $(filter -l%,$(1)) strip-libs = $(filter-out -l%,$(1)) -LK_DIR = ../lib/lk/ -TRACE_EVENT_DIR = ../lib/traceevent/ - LK_PATH=$(LK_DIR) ifneq ($(OUTPUT),) @@ -529,6 +455,8 @@ PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT) ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),tags) +-include config/feature
[PATCH 09/27] perf tools: Move libaudit check config into config/Makefile
Moving libaudit check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 9 + tools/perf/config/Makefile | 11 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 5e877a4..16d1362 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -493,14 +493,7 @@ ifndef NO_LIBUNWIND endif ifndef NO_LIBAUDIT - FLAGS_LIBAUDIT = $(ALL_CFLAGS) $(ALL_LDFLAGS) -laudit - ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) - msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); - else - BASIC_CFLAGS += -DLIBAUDIT_SUPPORT - BUILTIN_OBJS += $(OUTPUT)builtin-trace.o - EXTLIBS += -laudit - endif + BUILTIN_OBJS += $(OUTPUT)builtin-trace.o endif ifndef NO_SLANG diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 92c395f..52d6fe9 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -197,3 +197,14 @@ ifndef NO_LIBUNWIND BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) endif # NO_LIBUNWIND + +ifndef NO_LIBAUDIT + FLAGS_LIBAUDIT = $(ALL_CFLAGS) $(ALL_LDFLAGS) -laudit + ifneq ($(call try-cc,$(SOURCE_LIBAUDIT),$(FLAGS_LIBAUDIT),libaudit),y) + msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev); + NO_LIBAUDIT := 1 + else + BASIC_CFLAGS += -DLIBAUDIT_SUPPORT + EXTLIBS += -laudit + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 04/27] perf tools: Move programs check into config/Makefile
Moving programs check into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 24 tools/perf/config/Makefile | 10 ++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 032e099..8dd3320 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -58,6 +58,14 @@ $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar +RM = rm -f +MKDIR = mkdir +FIND= find +INSTALL = install +FLEX= flex +BISON = bison +STRIP ?= strip + ifeq ($(filter clean tags,$(MAKECMDGOALS)),) include config/Makefile endif @@ -88,7 +96,6 @@ CFLAGS = -fno-omit-frame-pointer -ggdb3 -funwind-tables -Wall -Wextra -std=gnu99 EXTLIBS = -lpthread -lrt -lelf -lm ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE ALL_LDFLAGS = $(LDFLAGS) -STRIP ?= strip # Among the variables below, these: # perfexecdir @@ -125,13 +132,6 @@ lib = lib export prefix bindir sharedir sysconfdir -RM = rm -f -MKDIR = mkdir -FIND = find -INSTALL = install -FLEX = flex -BISON= bison - # sparse is architecture-neutral, which means that we need to tell it # explicitly what architecture to check for. Fix this up for yours.. SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__ @@ -140,14 +140,6 @@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),tags) -include config/feature-tests.mak -ifeq ($(call get-executable,$(FLEX)),) - dummy := $(error Error: $(FLEX) is missing on this system, please install it) -endif - -ifeq ($(call get-executable,$(BISON)),) - dummy := $(error Error: $(BISON) is missing on this system, please install it) -endif - ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) CFLAGS := $(CFLAGS) -fstack-protector-all endif diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index fe317c2..04bf8ac 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -32,3 +32,13 @@ endif ifeq ($(NO_PERF_REGS),0) BASIC_CFLAGS += -DHAVE_PERF_REGS endif + +-include config/feature-tests.mak + +ifeq ($(call get-executable,$(FLEX)),) + dummy := $(error Error: $(FLEX) is missing on this system, please install it) +endif + +ifeq ($(call get-executable,$(BISON)),) + dummy := $(error Error: $(BISON) is missing on this system, please install it) +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC 00/27] perf tools: Build changes and kbuild support
hi, sending RFC for build changes and kbuild support. The build changes mostly consists of separating the config stuff into config/Makefile which is then used for kbuild. I kept the original/current Makefile in place and put the kbuild support into Makefile.kbuild. The final touch would be to move Makefile.kbuild into Makefile. I kept the original one to have easy way of testing the old system. To run the kbuild make: $ make -f Makefile.kbuild In pristine tree above command behaves as the current Makefile - does the system checks and builds perf. After that '.config' and '.config-detected' files are created and managed as explained in last patch of this set. It's published in: git://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git perf/kbuild7 I tested this so far on x86_64. I'm CC-ing Michal Marek and linux-kbuild list on kbuild patches. thanks for comments, jirka Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- Jiri Olsa (27): perf tools: Add automated make test suite perf tools: Fix tab vs spaces issue in Makefile ifdef/endif perf tools: Move arch check into config/Makefile perf tools: Move programs check into config/Makefile perf tools: Move compiler and linker flags check into config/Makefile perf tools: Move libelf check config into config/Makefile perf tools: Move libdw check config into config/Makefile perf tools: Move libunwind check config into config/Makefile perf tools: Move libaudit check config into config/Makefile perf tools: Move slang check config into config/Makefile perf tools: Move gtk2 check config into config/Makefile perf tools: Move libperl check config into config/Makefile perf tools: Move libpython check config into config/Makefile perf tools: Move libbfd check config into config/Makefile perf tools: Move stdlib check config into config/Makefile perf tools: Move libnuma check config into config/Makefile perf tools: Move paths config into config/Makefile perf tools: Final touches for CHK config move perf tools: Merge all *CFLAGS* make variable into CFLAGS perf tools: Merge all *LDFLAGS* make variable into LDFLAGS perf tools: Switch to full patch C include directories perf tools: Add NO_BIONIC variable to confiure bionic setup kbuild: Introduce KBUILD_AUTOCONF variable for auto.conf include kbuild: Introduce KCONFIG_AUTOCONFIGDEP variable for conf tool perf tools: Kbuild builtin source related fixies perf tools: Kbuild source related fixies perf tools: Add kbuild support into Makefile.kbuild scripts/Makefile.build | 3 +- scripts/kconfig/confdata.c | 11 +- scripts/kconfig/lkc.h| 1 + tools/perf/Kbuild| 47 ++ tools/perf/Kconfig | 256 ++ tools/perf/Makefile | 598 --- tools/perf/Makefile.kbuild | 411 tools/perf/arch/Kbuild | 3 + tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/util/Kbuild | 3 + tools/perf/bench/Kbuild | 9 + tools/perf/builtin-cmds.h| 31 ++ tools/perf/builtin-help.c| 1 + tools/perf/builtin-lock.c| 2 + tools/perf/builtin-report.c | 9 +- tools/perf/builtin-sched.c | 2 + tools/perf/config/Makefile | 528 tools/perf/config/Makefile.fix-config| 104 tools/perf/config/Makefile.fix-legacy| 46 ++ tools/perf/config/defconfig | 54 ++ tools/perf/perf.c| 51 +- tools/perf/perf.h| 2 + tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 3 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 4 + tools/perf/tests/Kbuild | 23 + tools/perf/tests/make| 122 + tools/perf/ui/Kbuild | 14 + tools/perf/ui/browsers/Kbuild| 6 + tools/perf/ui/browsers/scripts.c | 4 + tools/perf/ui/gtk/Kbuild | 7 + tools/perf/ui/setup.c| 10 +- tools/perf/ui/stdio/Kbuild | 1
[PATCH 12/27] perf tools: Move libperl check config into config/Makefile
Moving libperl check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 20 +++- tools/perf/config/Makefile | 21 + 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 8d3dd8e..972aa94 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -518,23 +518,9 @@ ifndef NO_GTK2 LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o endif -ifdef NO_LIBPERL - BASIC_CFLAGS += -DNO_LIBPERL -else - PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2/dev/null) - PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) - PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2/dev/null` - FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) - - ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) - BASIC_CFLAGS += -DNO_LIBPERL - else - ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) - EXTLIBS += $(PERL_EMBED_LIBADD) - LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o - LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o - endif +ifndef NO_LIBPERL + LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-perl.o + LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o endif disable-python = $(eval $(disable-python_code)) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 6fc2089..2c9e0a5 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -240,3 +240,24 @@ ifndef NO_GTK2 EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2/dev/null) endif endif + +grep-libs = $(filter -l%,$(1)) +strip-libs = $(filter-out -l%,$(1)) + +ifdef NO_LIBPERL + BASIC_CFLAGS += -DNO_LIBPERL +else + PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2/dev/null) + PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS)) + PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2/dev/null` + FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS) + + ifneq ($(call try-cc,$(SOURCE_PERL_EMBED),$(FLAGS_PERL_EMBED),perl),y) + BASIC_CFLAGS += -DNO_LIBPERL + NO_LIBPERL := 1 + else + ALL_LDFLAGS += $(PERL_EMBED_LDFLAGS) + EXTLIBS += $(PERL_EMBED_LIBADD) + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 15/27] perf tools: Move stdlib check config into config/Makefile
Moving stdlib check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 18 -- tools/perf/config/Makefile | 18 ++ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 09ac64a..ad826b5 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -532,24 +532,6 @@ ifeq ($(NO_PERF_REGS),0) endif endif -ifndef NO_STRLCPY - ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) - BASIC_CFLAGS += -DHAVE_STRLCPY - endif -endif - -ifndef NO_ON_EXIT - ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) - BASIC_CFLAGS += -DHAVE_ON_EXIT - endif -endif - -ifndef NO_BACKTRACE - ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) - BASIC_CFLAGS += -DBACKTRACE_SUPPORT - endif -endif - ifndef NO_LIBNUMA FLAGS_LIBNUMA = $(ALL_CFLAGS) $(ALL_LDFLAGS) -lnuma ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 68c6a2b..8c832f7 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -361,3 +361,21 @@ else endif endif endif + +ifndef NO_STRLCPY + ifeq ($(call try-cc,$(SOURCE_STRLCPY),,-DHAVE_STRLCPY),y) + BASIC_CFLAGS += -DHAVE_STRLCPY + endif +endif + +ifndef NO_ON_EXIT + ifeq ($(call try-cc,$(SOURCE_ON_EXIT),,-DHAVE_ON_EXIT),y) + BASIC_CFLAGS += -DHAVE_ON_EXIT + endif +endif + +ifndef NO_BACKTRACE + ifeq ($(call try-cc,$(SOURCE_BACKTRACE),,-DBACKTRACE_SUPPORT),y) + BASIC_CFLAGS += -DBACKTRACE_SUPPORT + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 16/27] perf tools: Move libnuma check config into config/Makefile
Moving libnuma check config into config/Makefile Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 9 + tools/perf/config/Makefile | 11 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index ad826b5..1524de7 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -533,14 +533,7 @@ ifeq ($(NO_PERF_REGS),0) endif ifndef NO_LIBNUMA - FLAGS_LIBNUMA = $(ALL_CFLAGS) $(ALL_LDFLAGS) -lnuma - ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) - msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); - else - BASIC_CFLAGS += -DLIBNUMA_SUPPORT - BUILTIN_OBJS += $(OUTPUT)bench/numa.o - EXTLIBS += -lnuma - endif + BUILTIN_OBJS += $(OUTPUT)bench/numa.o endif ifdef ASCIIDOC8 diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 8c832f7..b559693 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -379,3 +379,14 @@ ifndef NO_BACKTRACE BASIC_CFLAGS += -DBACKTRACE_SUPPORT endif endif + +ifndef NO_LIBNUMA + FLAGS_LIBNUMA = $(ALL_CFLAGS) $(ALL_LDFLAGS) -lnuma + ifneq ($(call try-cc,$(SOURCE_LIBNUMA),$(FLAGS_LIBNUMA),libnuma),y) + msg := $(warning No numa.h found, disables 'perf bench numa mem' benchmark, please install numa-libs-devel or libnuma-dev); + NO_LIBNUMA := 1 + else + BASIC_CFLAGS += -DLIBNUMA_SUPPORT + EXTLIBS += -lnuma + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 17/27] perf tools: Move paths config into config/Makefile
Moving paths config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 58 -- tools/perf/config/Makefile | 52 + 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 1524de7..e9c9258 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -87,39 +87,6 @@ ifeq ($(filter clean tags,$(MAKECMDGOALS)),) include config/Makefile endif -# Among the variables below, these: -# perfexecdir -# template_dir -# mandir -# infodir -# htmldir -# ETC_PERFCONFIG (but not sysconfdir) -# can be specified as a relative path some/where/else; -# this is interpreted as relative to $(prefix) and perf at -# runtime figures out where they are based on the path to the executable. -# This can help installing the suite in a relocatable way. - -# Make the path relative to DESTDIR, not to prefix -ifndef DESTDIR -prefix = $(HOME) -endif -bindir_relative = bin -bindir = $(prefix)/$(bindir_relative) -mandir = share/man -infodir = share/info -perfexecdir = libexec/perf-core -sharedir = $(prefix)/share -template_dir = share/perf-core/templates -htmldir = share/doc/perf-doc -ifeq ($(prefix),/usr) -sysconfdir = /etc -ETC_PERFCONFIG = $(sysconfdir)/perfconfig -else -sysconfdir = $(prefix)/etc -ETC_PERFCONFIG = etc/perfconfig -endif -lib = lib - export prefix bindir sharedir sysconfdir # sparse is architecture-neutral, which means that we need to tell it @@ -543,23 +510,6 @@ endif endif # MAKECMDGOALS != tags endif # MAKECMDGOALS != clean -# Shell quote (do not use $(call) to accommodate ancient setups); - -ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) - -DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) -bindir_SQ = $(subst ','\'',$(bindir)) -bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) -mandir_SQ = $(subst ','\'',$(mandir)) -infodir_SQ = $(subst ','\'',$(infodir)) -perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) -template_dir_SQ = $(subst ','\'',$(template_dir)) -htmldir_SQ = $(subst ','\'',$(htmldir)) -prefix_SQ = $(subst ','\'',$(prefix)) -sysconfdir_SQ = $(subst ','\'',$(sysconfdir)) - -SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) - LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group ALL_CFLAGS += $(BASIC_CFLAGS) @@ -568,7 +518,6 @@ ALL_LDFLAGS += $(BASIC_LDFLAGS) export INSTALL SHELL_PATH - ### Build rules SHELL = $(SHELL_PATH) @@ -810,13 +759,6 @@ check: $(OUTPUT)common-cmds.h ### Installation rules -ifneq ($(filter /%,$(firstword $(perfexecdir))),) -perfexec_instdir = $(perfexecdir) -else -perfexec_instdir = $(prefix)/$(perfexecdir) -endif -perfexec_instdir_SQ = $(subst ','\'',$(perfexec_instdir)) - install-bin: all $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bindir_SQ)' $(INSTALL) $(OUTPUT)perf '$(DESTDIR_SQ)$(bindir_SQ)' diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index b559693..a0dbc24 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -390,3 +390,55 @@ ifndef NO_LIBNUMA EXTLIBS += -lnuma endif endif + +# Among the variables below, these: +# perfexecdir +# template_dir +# mandir +# infodir +# htmldir +# ETC_PERFCONFIG (but not sysconfdir) +# can be specified as a relative path some/where/else; +# this is interpreted as relative to $(prefix) and perf at +# runtime figures out where they are based on the path to the executable. +# This can help installing the suite in a relocatable way. + +# Make the path relative to DESTDIR, not to prefix +ifndef DESTDIR +prefix = $(HOME) +endif +bindir_relative = bin +bindir = $(prefix)/$(bindir_relative) +mandir = share/man +infodir = share/info +perfexecdir = libexec/perf-core +sharedir = $(prefix)/share +template_dir = share/perf-core/templates +htmldir = share/doc/perf-doc +ifeq ($(prefix),/usr) +sysconfdir = /etc +ETC_PERFCONFIG = $(sysconfdir)/perfconfig +else +sysconfdir = $(prefix)/etc +ETC_PERFCONFIG = etc/perfconfig +endif +lib = lib + +# Shell quote (do not use $(call) to accommodate ancient setups); +ETC_PERFCONFIG_SQ = $(subst ','\'',$(ETC_PERFCONFIG)) +DESTDIR_SQ = $(subst ','\'',$(DESTDIR)) +bindir_SQ = $(subst ','\'',$(bindir)) +mandir_SQ = $(subst ','\'',$(mandir)) +infodir_SQ = $(subst ','\'',$(infodir)) +perfexecdir_SQ = $(subst ','\'',$(perfexecdir)) +template_dir_SQ = $(subst ','\'',$(template_dir)) +htmldir_SQ = $(subst ','\'',$(htmldir)) +prefix_SQ = $(subst ','\'',$(prefix)) +sysconfdir_SQ = $(subst ','\'',$(sysconfdir
[PATCH 18/27] perf tools: Final touches for CHK config move
Removing no longer needed ifdefs. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile | 11 --- 1 file changed, 11 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index e9c9258..c25997f 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -410,14 +410,6 @@ BUILTIN_OBJS += $(OUTPUT)builtin-mem.o PERFLIBS = $(LIB_FILE) $(LIBLK) $(LIBTRACEEVENT) -# -# Platform specific tweaks -# -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),tags) - --include config/feature-tests.mak - # We choose to avoid if .. else if .. else .. endif endif # because maintaining the nesting to match is a pain. If # we had elif things would have been much nicer... @@ -507,9 +499,6 @@ ifdef ASCIIDOC8 export ASCIIDOC8 endif -endif # MAKECMDGOALS != tags -endif # MAKECMDGOALS != clean - LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group ALL_CFLAGS += $(BASIC_CFLAGS) -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 14/27] perf tools: Move libbfd check config into config/Makefile
Moving libbfd check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 37 - tools/perf/config/Makefile | 37 + 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index f02c0fd..09ac64a 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -526,43 +526,6 @@ ifndef NO_LIBPYTHON LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o endif -ifdef NO_DEMANGLE - BASIC_CFLAGS += -DNO_DEMANGLE -else - ifdef HAVE_CPLUS_DEMANGLE - EXTLIBS += -liberty - BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE - else - FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd - has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) - ifeq ($(has_bfd),y) - EXTLIBS += -lbfd - else - FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty - has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) - ifeq ($(has_bfd_iberty),y) - EXTLIBS += -lbfd -liberty - else - FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz - has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) - ifeq ($(has_bfd_iberty_z),y) - EXTLIBS += -lbfd -liberty -lz - else - FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty - has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) - ifeq ($(has_cplus_demangle),y) - EXTLIBS += -liberty - BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE - else - msg := $(warning No bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol demangling) - BASIC_CFLAGS += -DNO_DEMANGLE - endif - endif - endif - endif - endif -endif - ifeq ($(NO_PERF_REGS),0) ifeq ($(ARCH),x86) LIB_H += arch/x86/include/perf_regs.h diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index d5e0386..68c6a2b 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -324,3 +324,40 @@ else endif endif endif + +ifdef NO_DEMANGLE + BASIC_CFLAGS += -DNO_DEMANGLE +else + ifdef HAVE_CPLUS_DEMANGLE + EXTLIBS += -liberty + BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE + else + FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -DPACKAGE='perf' -lbfd + has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD),libbfd) + ifeq ($(has_bfd),y) + EXTLIBS += -lbfd + else + FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty + has_bfd_iberty := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY),liberty) + ifeq ($(has_bfd_iberty),y) + EXTLIBS += -lbfd -liberty + else + FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz + has_bfd_iberty_z := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z),libz) + ifeq ($(has_bfd_iberty_z),y) + EXTLIBS += -lbfd -liberty -lz + else + FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -liberty + has_cplus_demangle := $(call try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE),demangle) + ifeq ($(has_cplus_demangle),y) + EXTLIBS += -liberty + BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE + else + msg := $(warning No bfd.h/libbfd found, install
[PATCH 23/27] kbuild: Introduce KBUILD_AUTOCONF variable for auto.conf include
Introducing KBUILD_AUTOCONF variable for auto.conf include allowing to specify custom auto.conf file. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- scripts/Makefile.build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 0e801c3..a3254a1 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -31,7 +31,8 @@ subdir-asflags-y := subdir-ccflags-y := # Read auto.conf if it exists, otherwise ignore --include include/config/auto.conf +kbuild-autoconf := $(if $(KBUILD_AUTOCONF),$(KBUILD_AUTOCONF),include/config/auto.conf) +-include $(kbuild-autoconf) include scripts/Kbuild.include -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 26/27] perf tools: Kbuild source related fixies
Fixing several sources config dependencies to allow separate config builds. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- tools/perf/builtin-lock.c| 2 ++ tools/perf/builtin-report.c | 9 - tools/perf/builtin-sched.c | 2 ++ tools/perf/perf.c| 6 ++ tools/perf/perf.h| 2 ++ tools/perf/ui/browsers/scripts.c | 4 tools/perf/ui/setup.c| 10 +- 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-lock.c b/tools/perf/builtin-lock.c index 4258300..bb1f729 100644 --- a/tools/perf/builtin-lock.c +++ b/tools/perf/builtin-lock.c @@ -972,9 +972,11 @@ int cmd_lock(int argc, const char **argv, const char *prefix __maybe_unused) usage_with_options(report_usage, report_options); } __cmd_report(); +#ifdef CONFIG_BULTIN_SCRIPT } else if (!strcmp(argv[0], script)) { /* Aliased to 'perf script' */ return cmd_script(argc, argv, prefix); +#endif } else if (!strcmp(argv[0], info)) { if (argc) { argc = parse_options(argc, argv, diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index bd0ca81..87690f5 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -573,6 +573,7 @@ static int __cmd_report(struct perf_report *rep) if (use_browser 0) { if (use_browser == 1) { +#ifdef CONFIG_TUI ret = perf_evlist__tui_browse_hists(session-evlist, help, NULL, @@ -583,10 +584,16 @@ static int __cmd_report(struct perf_report *rep) */ if (ret != K_SWITCH_INPUT_DATA) ret = 0; - +#else + ret = -1; +#endif } else if (use_browser == 2) { +#ifdef CONFIG_GUI perf_evlist__gtk_browse_hists(session-evlist, help, NULL); +#else + ret = -1; +#endif } } else perf_evlist__tty_browse_hists(session-evlist, rep, help); diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 2da2a6c..4c4046a 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c @@ -1747,11 +1747,13 @@ int cmd_sched(int argc, const char **argv, const char *prefix __maybe_unused) if (!argc) usage_with_options(sched_usage, sched_options); +#ifdef CONFIG_BULTIN_SCRIPT /* * Aliased to 'perf script' for now: */ if (!strcmp(argv[0], script)) return cmd_script(argc, argv, prefix); +#endif symbol__init(); if (!strncmp(argv[0], rec, 3)) { diff --git a/tools/perf/perf.c b/tools/perf/perf.c index ccc6c52..f277b98 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -92,7 +92,9 @@ static struct cmd_struct commands[] = { #ifdef CONFIG_BUILTIN_KVM { kvm,cmd_kvm,0 }, #endif +#ifdef CONFIG_BUILTIN_TEST { test, cmd_test, 0 }, +#endif #if defined LIBAUDIT_SUPPORT defined CONFIG_BUILTIN_TRACE { trace, cmd_trace, 0 }, #endif @@ -535,13 +537,17 @@ int main(int argc, const char **argv) } else { /* The user didn't specify a command; give them help */ printf(\n usage: %s\n\n, perf_usage_string); +#ifdef CONFIG_BUILTIN_HELP list_common_cmds_help(); printf(\n %s\n\n, perf_more_info_string); +#endif goto out; } cmd = argv[0]; +#ifdef CONFIG_BUILTIN_TEST test_attr__init(); +#endif /* * We use PATH to find perf commands, but we prepend some higher diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 32bd102..978659e 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -162,8 +162,10 @@ sys_perf_event_open(struct perf_event_attr *attr, fd = syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags); +#ifdef CONFIG_BUILTIN_TEST if (unlikely(test_attr__enabled)) test_attr__open(attr, pid, cpu, fd, group_fd, flags); +#endif return fd; } diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c index 12f009e..effdf38 100644 --- a/tools/perf
[PATCH 25/27] perf tools: Kbuild builtin source related fixies
Adding CONFIG_BUILTIN_* defines to govern builtin commands. This will be usefull for kbuild process switch. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- tools/perf/builtin-cmds.h | 27 ++ tools/perf/builtin-help.c | 1 + tools/perf/perf.c | 45 +++-- tools/perf/util/generate-cmdlist.sh | 10 + 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tools/perf/builtin-cmds.h diff --git a/tools/perf/builtin-cmds.h b/tools/perf/builtin-cmds.h new file mode 100644 index 000..fec342a --- /dev/null +++ b/tools/perf/builtin-cmds.h @@ -0,0 +1,27 @@ +#ifndef BUILTIN_CMDS_H +#define BUILTIN_CMDS_H + +#define CONFIG_BUILTIN_REPORT 1 +#define CONFIG_BUILTIN_SCRIPT 1 +#define CONFIG_BUILTIN_BENCH 1 +#define CONFIG_BUILTIN_SCHED 1 +#define CONFIG_BUILTIN_TRACE 1 +#define CONFIG_BUILTIN_TOP 1 +#define CONFIG_BUILTIN_RECORD 1 +#define CONFIG_BUILTIN_BUILDID_LIST 1 +#define CONFIG_BUILTIN_INJECT 1 +#define CONFIG_BUILTIN_LOCK 1 +#define CONFIG_BUILTIN_KVM 1 +#define CONFIG_BUILTIN_BUILDID_CACHE 1 +#define CONFIG_BUILTIN_EVLIST 1 +#define CONFIG_BUILTIN_KMEM 1 +#define CONFIG_BUILTIN_STAT 1 +#define CONFIG_BUILTIN_DIFF 1 +#define CONFIG_BUILTIN_ANNOTATE 1 +#define CONFIG_BUILTIN_TIMECHART 1 +#define CONFIG_BUILTIN_LIST 1 +#define CONFIG_BUILTIN_HELP 1 +#define CONFIG_BUILTIN_PROBE 1 +#define CONFIG_BUILTIN_MEM 1 + +#endif /* BUILTIN_CMDS_H */ diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c index 178b88a..b6c78a6 100644 --- a/tools/perf/builtin-help.c +++ b/tools/perf/builtin-help.c @@ -7,6 +7,7 @@ #include util/cache.h #include builtin.h #include util/exec_cmd.h +#include builtin-cmds.h #include common-cmds.h #include util/parse-options.h #include util/run-command.h diff --git a/tools/perf/perf.c b/tools/perf/perf.c index 85e1aed..ccc6c52 100644 --- a/tools/perf/perf.c +++ b/tools/perf/perf.c @@ -7,6 +7,7 @@ * perf top, perf record, perf report, etc.) are started. */ #include builtin.h +#include builtin-cmds.h #include util/exec_cmd.h #include util/cache.h @@ -33,34 +34,74 @@ struct cmd_struct { }; static struct cmd_struct commands[] = { +#ifdef CONFIG_BUILTIN_BUILDID_CACHE { buildid-cache, cmd_buildid_cache, 0 }, +#endif +#ifdef CONFIG_BUILTIN_BUILDID_LIST { buildid-list, cmd_buildid_list, 0 }, +#endif +#ifdef CONFIG_BUILTIN_DIFF { diff, cmd_diff, 0 }, +#endif +#ifdef CONFIG_BUILTIN_EVLIST { evlist, cmd_evlist, 0 }, +#endif +#ifdef CONFIG_BUILTIN_HELP { help, cmd_help, 0 }, +#endif +#ifdef CONFIG_BUILTIN_LIST { list, cmd_list, 0 }, +#endif +#ifdef CONFIG_BUILTIN_RECORD { record, cmd_record, 0 }, +#endif +#ifdef CONFIG_BUILTIN_REPORT { report, cmd_report, 0 }, +#endif +#ifdef CONFIG_BUILTIN_BENCH { bench, cmd_bench, 0 }, +#endif +#ifdef CONFIG_BUILTIN_STAT { stat, cmd_stat, 0 }, +#endif +#ifdef CONFIG_BUILTIN_TIMECHART { timechart, cmd_timechart, 0 }, +#endif +#ifdef CONFIG_BUILTIN_TOP { top,cmd_top,0 }, +#endif +#ifdef CONFIG_BUILTIN_ANNOTATE { annotate, cmd_annotate, 0 }, +#endif { version,cmd_version,0 }, +#ifdef CONFIG_BUILTIN_SCRIPT { script, cmd_script, 0 }, +#endif +#ifdef CONFIG_BUILTIN_SCHED { sched, cmd_sched, 0 }, -#ifdef LIBELF_SUPPORT +#endif +#if defined LIBELF_SUPPORT defined CONFIG_BUILTIN_PROBE { probe, cmd_probe, 0 }, #endif +#ifdef CONFIG_BUILTIN_KMEM { kmem, cmd_kmem, 0 }, +#endif +#ifdef CONFIG_BUILTIN_LOCK { lock, cmd_lock, 0 }, +#endif +#ifdef CONFIG_BUILTIN_KVM { kvm,cmd_kvm,0 }, +#endif { test, cmd_test, 0 }, -#ifdef LIBAUDIT_SUPPORT +#if defined LIBAUDIT_SUPPORT defined CONFIG_BUILTIN_TRACE { trace, cmd_trace, 0 }, #endif +#ifdef CONFIG_BUILTIN_INJECT { inject, cmd_inject, 0 }, +#endif +#ifdef CONFIG_BUILTIN_MEM { mem,cmd_mem,0 }, +#endif }; struct pager_config { diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh index 3ac3803..ef9a4f6 100755 --- a/tools/perf/util/generate-cmdlist.sh +++ b/tools/perf/util/generate-cmdlist.sh @@ -1,5 +1,11 @@ #!/bin/sh +function cfg() +{ + cfg=`echo $1 | tr '[:lower:]' '[:upper:]' | sed 's/-/_/g'` + echo $cfg +} + echo
[PATCH 27/27] perf tools: Add kbuild support into Makefile.kbuild
Adding kbuild support into Makefile.kbuild. The 'legacy' Makefile still stays untouched as it was. It's possible to use kbuild by running 'make -f Makefile.kbuild' with any option supported by 'legacy' Makefile. We now have 2 config files: '.config' - user configured setup '.config-detected' - system detected setup The '.config-detected' affects '.config' and if there's configured feature in '.config' which was not detected it is automatically disabled. The '.config-detected' is re/created if: - there's no '.config-detected' - '.config' was changed In a cleaned tree the perf is built with 'allyesconfig' having disabled all non-detected features, just as it is done now. You can change '.config' via: make -f Makefile.kbuild menuconfig There's difference for O=DIR build. The DIR is populated based on kernel source tree, so the final binary is created under DIR/tools/perf. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- tools/perf/Kbuild| 47 +++ tools/perf/Kconfig | 256 ++ tools/perf/Makefile | 2 +- tools/perf/Makefile.kbuild | 411 +++ tools/perf/arch/Kbuild | 3 + tools/perf/arch/x86/Kbuild | 1 + tools/perf/arch/x86/util/Kbuild | 3 + tools/perf/bench/Kbuild | 9 + tools/perf/builtin-cmds.h| 4 + tools/perf/config/Makefile | 46 +++ tools/perf/config/Makefile.fix-config| 104 ++ tools/perf/config/Makefile.fix-legacy| 46 +++ tools/perf/config/defconfig | 54 +++ tools/perf/scripts/perl/Perf-Trace-Util/Kbuild | 3 + tools/perf/scripts/python/Perf-Trace-Util/Kbuild | 4 + tools/perf/tests/Kbuild | 23 ++ tools/perf/ui/Kbuild | 14 + tools/perf/ui/browsers/Kbuild| 6 + tools/perf/ui/gtk/Kbuild | 7 + tools/perf/ui/stdio/Kbuild | 1 + tools/perf/ui/tui/Kbuild | 4 + tools/perf/util/Kbuild | 113 +++ tools/perf/util/PERF-VERSION-GEN | 6 +- tools/perf/util/generate-cmdlist.sh | 8 +- tools/perf/util/scripting-engines/Kbuild | 7 + tools/perf/util/setup.py | 10 +- 26 files changed, 1183 insertions(+), 9 deletions(-) create mode 100644 tools/perf/Kbuild create mode 100644 tools/perf/Kconfig create mode 100644 tools/perf/Makefile.kbuild create mode 100644 tools/perf/arch/Kbuild create mode 100644 tools/perf/arch/x86/Kbuild create mode 100644 tools/perf/arch/x86/util/Kbuild create mode 100644 tools/perf/bench/Kbuild create mode 100644 tools/perf/config/Makefile.fix-config create mode 100644 tools/perf/config/Makefile.fix-legacy create mode 100644 tools/perf/config/defconfig create mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/Kbuild create mode 100644 tools/perf/scripts/python/Perf-Trace-Util/Kbuild create mode 100644 tools/perf/tests/Kbuild create mode 100644 tools/perf/ui/Kbuild create mode 100644 tools/perf/ui/browsers/Kbuild create mode 100644 tools/perf/ui/gtk/Kbuild create mode 100644 tools/perf/ui/stdio/Kbuild create mode 100644 tools/perf/ui/tui/Kbuild create mode 100644 tools/perf/util/Kbuild create mode 100644 tools/perf/util/scripting-engines/Kbuild diff --git a/tools/perf/Kbuild b/tools/perf/Kbuild new file mode 100644 index 000..80b9184 --- /dev/null +++ b/tools/perf/Kbuild @@ -0,0 +1,47 @@ +obj-y += perf.o + +obj-$(CONFIG_BUILTIN_ANNOTATE) += builtin-annotate.o +obj-$(CONFIG_BUILTIN_BENCH) += builtin-bench.o +obj-$(CONFIG_BUILTIN_BENCH) += bench/ +obj-$(CONFIG_BUILTIN_BUILDID_CACHE) += builtin-buildid-cache.o +obj-$(CONFIG_BUILTIN_BUILDID_LIST) += builtin-buildid-list.o +obj-$(CONFIG_BUILTIN_DIFF) += builtin-diff.o +obj-$(CONFIG_BUILTIN_EVLIST)+= builtin-evlist.o +obj-$(CONFIG_BUILTIN_HELP) += builtin-help.o +obj-$(CONFIG_BUILTIN_INJECT)+= builtin-inject.o +obj-$(CONFIG_BUILTIN_KMEM) += builtin-kmem.o +obj-$(CONFIG_BUILTIN_KVM) += builtin-kvm.o +obj-$(CONFIG_BUILTIN_LIST) += builtin-list.o +obj-$(CONFIG_BUILTIN_LOCK) += builtin-lock.o +obj-$(CONFIG_BUILTIN_PROBE) += builtin-probe.o +obj-$(CONFIG_BUILTIN_RECORD)+= builtin-record.o
[PATCH 24/27] kbuild: Introduce KCONFIG_AUTOCONFIGDEP variable for conf tool
Introducing KCONFIG_AUTOCONFIGDEP variable for conf tool allowing to specify custom auto.conf.cmd file. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Michal Marek mma...@suse.cz Cc: linux-kbu...@vger.kernel.org Cc: Stephane Eranian eran...@google.com --- scripts/kconfig/confdata.c | 11 ++- scripts/kconfig/lkc.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 13ddf11..435c361 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -75,6 +75,14 @@ const char *conf_get_autoconfig_name(void) return name ? name : include/config/auto.conf; } +const char *conf_get_autoconfigdep_name(void) +{ + char *name = getenv(KCONFIG_AUTOCONFIGDEP); + + return name ? name : include/config/auto.conf.cmd; +} + + static char *conf_expand_value(const char *in) { struct symbol *sym; @@ -948,7 +956,8 @@ int conf_write_autoconf(void) sym_clear_all_valid(); - file_write_dep(include/config/auto.conf.cmd); + name = conf_get_autoconfigdep_name(); + file_write_dep(name); if (conf_split_config()) return 1; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index f8aee5f..5e370b1 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -83,6 +83,7 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); +const char *conf_get_autoconfigdep_name(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 22/27] perf tools: Add NO_BIONIC variable to confiure bionic setup
Adding NO_BIONIC variable to confiure bionic setup Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 4 tools/perf/config/Makefile | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 92dc204..bc35337 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -51,6 +51,10 @@ include config/utilities.mak # Define NO_BACKTRACE if you do not want stack backtrace debug feature # # Define NO_LIBNUMA if you do not want numa perf benchmark +# +# Define NO_LIBAUDIT if you do not want libaudit support +# +# Define NO_LIBBIONIC if you do not want bionic support ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(shell pwd))) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 8762209..cc464f1 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -131,11 +131,13 @@ CFLAGS += \ CFLAGS += \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE +ifndef NO_BIONIC ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) BIONIC := 1 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) EXTLIBS := $(filter-out -lpthread,$(EXTLIBS)) endif +endif # NO_BIONIC ifdef NO_LIBELF NO_DWARF := 1 -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 13/27] perf tools: Move libpython check config into config/Makefile
Moving libpython check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 68 ++ tools/perf/config/Makefile | 63 ++ 2 files changed, 66 insertions(+), 65 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 972aa94..f02c0fd 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -184,8 +184,6 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) # PROGRAMS += $(OUTPUT)perf -LANG_BINDINGS = - # what 'all' will build and 'install' will install, in perfexecdir ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS) @@ -523,69 +521,9 @@ ifndef NO_LIBPERL LIB_OBJS += $(OUTPUT)scripts/perl/Perf-Trace-Util/Context.o endif -disable-python = $(eval $(disable-python_code)) -define disable-python_code - BASIC_CFLAGS += -DNO_LIBPYTHON - $(if $(1),$(warning No $(1) was found)) - $(warning Python support will not be built) -endef - -override PYTHON := \ - $(call get-executable-or-default,PYTHON,python) - -ifndef PYTHON - $(call disable-python,python interpreter) -else - - PYTHON_WORD := $(call shell-wordify,$(PYTHON)) - - ifdef NO_LIBPYTHON -$(call disable-python) - else - -override PYTHON_CONFIG := \ - $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) - -ifndef PYTHON_CONFIG - $(call disable-python,python-config tool) -else - - PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) - - PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2/dev/null) - PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) - PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) - PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2/dev/null) - FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS) - - ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED),python),y) -$(call disable-python,Python.h (for Python 2.x)) - else - -ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED),python version),y) - $(warning Python 3 is not yet supported; please set) - $(warning PYTHON and/or PYTHON_CONFIG appropriately.) - $(warning If you also have Python 2 installed, then) - $(warning try something like:) - $(warning $(and ,)) - $(warning $(and ,) make PYTHON=python2) - $(warning $(and ,)) - $(warning Otherwise, disable Python support entirely:) - $(warning $(and ,)) - $(warning $(and ,) make NO_LIBPYTHON=1) - $(warning $(and ,)) - $(error $(and ,)) -else - ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS) - EXTLIBS += $(PYTHON_EMBED_LIBADD) - LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o - LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o - LANG_BINDINGS += $(OUTPUT)python/perf.so -endif - - endif -endif - endif +ifndef NO_LIBPYTHON + LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o + LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o endif ifdef NO_DEMANGLE diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 2c9e0a5..d5e0386 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -261,3 +261,66 @@ else EXTLIBS += $(PERL_EMBED_LIBADD) endif endif + +disable-python = $(eval $(disable-python_code)) +define disable-python_code + BASIC_CFLAGS += -DNO_LIBPYTHON + $(if $(1),$(warning No $(1) was found)) + $(warning Python support will not be built) + NO_LIBPYTHON := 1 +endef + +override PYTHON := \ + $(call get-executable-or-default,PYTHON,python) + +ifndef PYTHON + $(call disable-python,python interpreter) +else + + PYTHON_WORD := $(call shell-wordify,$(PYTHON)) + + ifdef NO_LIBPYTHON +$(call disable-python) + else + +override PYTHON_CONFIG := \ + $(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config) + +ifndef PYTHON_CONFIG + $(call disable-python,python-config tool) +else + + PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG)) + + PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2/dev/null) + PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS)) + PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS)) + PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2/dev/null) + FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS
[PATCH 21/27] perf tools: Switch to full patch C include directories
Switching to full patch C include directories, to make the includes clear. Plus little include cleanup. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 4 ++-- tools/perf/config/Makefile | 49 ++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index a1170a1..92dc204 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -80,8 +80,8 @@ FLEX= flex BISON = bison STRIP ?= strip -LK_DIR = ../lib/lk/ -TRACE_EVENT_DIR = ../lib/traceevent/ +LK_DIR = $(srctree)/tools/lib/lk/ +TRACE_EVENT_DIR = $(srctree)/tools/lib/traceevent/ ifeq ($(filter clean tags,$(MAKECMDGOALS)),) include config/Makefile diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index c6e4902..8762209 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -34,7 +34,23 @@ ifeq ($(NO_PERF_REGS),0) CFLAGS += -DHAVE_PERF_REGS endif --include config/feature-tests.mak +ifeq ($(src-perf),) +src-perf := $(srctree)/tools/perf +endif + +ifeq ($(obj-perf),) +obj-perf := $(objtree) +endif + +ifneq ($(obj-perf),) +obj-perf := $(abspath $(obj-perf))/ +endif + +# include ARCH specific config +-include $(src-perf)/arch/$(ARCH)/Makefile + +include $(src-perf)/config/feature-tests.mak +include $(src-perf)/config/utilities.mak ifeq ($(call get-executable,$(FLEX)),) dummy := $(error Error: $(FLEX) is missing on this system, please install it) @@ -91,19 +107,28 @@ ifndef PERF_DEBUG endif CFLAGS += \ - -Iutil/include \ - -Iarch/$(ARCH)/include \ - $(if $(objtree),-I$(objtree)/arch/$(ARCH)/include/generated/uapi) \ + -I$(src-perf)/util/include \ + -I$(src-perf)/arch/$(ARCH)/include \ -I$(srctree)/arch/$(ARCH)/include/uapi \ -I$(srctree)/arch/$(ARCH)/include \ - $(if $(objtree),-I$(objtree)/include/generated/uapi) \ -I$(srctree)/include/uapi \ - -I$(srctree)/include \ - -I$(OUTPUT)util \ - -Iutil \ - -I. \ + -I$(srctree)/include + +# $(obj-perf) for generated common-cmds.h +# $(obj-perf)/util for generated bison/flex headers +ifneq ($(OUTPUT),) +CFLAGS += \ + -I$(obj-perf)/util \ + -I$(obj-perf) +endif + +CFLAGS += \ + -I$(src-perf)/util \ + -I$(src-perf) \ -I$(TRACE_EVENT_DIR) \ - -I../lib/ \ + -I$(srctree)/tools/lib/ + +CFLAGS += \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) @@ -159,7 +184,7 @@ ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) endif # include ARCH specific config --include arch/$(ARCH)/Makefile +-include $(src-perf)/arch/$(ARCH)/Makefile ifndef NO_DWARF ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) @@ -329,7 +354,7 @@ else else LDFLAGS += $(PYTHON_EMBED_LDFLAGS) EXTLIBS += $(PYTHON_EMBED_LIBADD) - LANG_BINDINGS += $(OUTPUT)python/perf.so + LANG_BINDINGS += $(obj-perf)python/perf.so endif endif endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 01/27] perf tools: Add automated make test suite
Adding automatd test for testing the build process. To run it you needto be in perf directory or specify one with PERF variable. It's also possible to specify optional Makefile to test via MK variable. Whole suite is executed twice, the second time with O=/tmp/xxx option added. To run the whole suite: $ make -f tests/make MAKE_PURE: cd . make -f Makefile TEST: test -x ./perf MAKE_DEBUG: cd . make -f Makefile DEBUG=1 TEST: test -x ./perf ... You see command line for 'MAKE_PURE' test right away, and the output is stored into MAKE_PURE file. To run simple test: $ make -f tests/make MAKE_DEBUG MAKE_DEBUG: cd . make -f Makefile DEBUG=1 TEST: test -x ./perf At this moment tests checks for succesfull build and for existence of several built files. Additional after-build checks could be added. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/tests/make | 122 ++ 1 file changed, 122 insertions(+) create mode 100644 tools/perf/tests/make diff --git a/tools/perf/tests/make b/tools/perf/tests/make new file mode 100644 index 000..0cc64ea --- /dev/null +++ b/tools/perf/tests/make @@ -0,0 +1,122 @@ +ifndef PERF +PERF := . +endif + +ifndef MK +MK := Makefile +endif + +MAKE_DEBUG := DEBUG=1 +MAKE_NO_LIBPERL := NO_LIBPERL=1 +MAKE_NO_LIBPYTHON := NO_LIBPYTHON=1 +MAKE_NO_SCRIPTS := NO_LIBPYTHON=1 NO_LIBPERL=1 +MAKE_NO_NEWT:= NO_NEWT=1 +MAKE_NO_SLANG := NO_SLANG=1 +MAKE_NO_GTK2:= NO_GTK2=1 +MAKE_NO_UI := NO_NEWT=1 NO_SLANG=1 NO_GTK2=1 +MAKE_NO_DEMANGLE:= NO_DEMANGLE=1 +MAKE_NO_LIBELF := NO_LIBELF=1 +MAKE_NO_LIBUNWIND := NO_LIBUNWIND=1 +MAKE_NO_BACKTRACE := NO_BACKTRACE=1 +MAKE_NO_LIBNUMA := NO_LIBNUMA=1 +MAKE_NO_LIBAUDIT:= NO_LIBAUDIT=1 +MAKE_NO_LIBBIONIC := NO_LIBBIONIC=1 +MAKE_MINIMAL:= NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 +MAKE_TAGS := tags +MAKE_CSCOPE := cscope +MAKE_HELP := help +MAKE_DOC:= doc +MAKE_PERF_O := perf.o +MAKE_UTIL_MAP_O := util/map.o + +RUN := \ + MAKE_PURE \ + MAKE_DEBUG \ + MAKE_NO_LIBPERL \ + MAKE_NO_LIBPYTHON \ + MAKE_NO_SCRIPTS \ + MAKE_NO_NEWT \ + MAKE_NO_SLANG \ + MAKE_NO_GTK2 \ + MAKE_NO_UI \ + MAKE_NO_DEMANGLE \ + MAKE_NO_LIBELF \ + MAKE_NO_LIBUNWIND \ + MAKE_NO_BACKTRACE \ + MAKE_NO_LIBNUMA \ + MAKE_NO_LIBAUDIT \ + MAKE_NO_LIBBIONIC \ + MAKE_MINIMAL \ + MAKE_TAGS \ + MAKE_CSCOPE \ + MAKE_HELP \ + MAKE_DOC \ + MAKE_PERF_O \ + MAKE_UTIL_MAP_O + +RUN_O := $(addsuffix _O,$(RUN)) + +TEST_MAKE_TAGS = test -f tags +TEST_MAKE_CSCOPE = test -f cscope.out + +TEST_MAKE_TAGS_O := $(TEST_MAKE_TAGS) +TEST_MAKE_CSCOPE_O := $(TEST_MAKE_CSCOPE) + +TEST_OK := true +TEST_MAKE_HELP := $(TEST_OK) +TEST_MAKE_DOC:= $(TEST_OK) +TEST_MAKE_HELP_O := $(TEST_OK) +TEST_MAKE_DOC_O := $(TEST_OK) + +TEST_MAKE_PERF_O := test -f $(PERF)/perf.o +TEST_MAKE_UTIL_MAP_O := test -f $(PERF)/util/map.o + +# Kbuild tests only +#TEST_MAKE_PERF_O_O := test -f $$TMP/tools/perf/perf.o +#TEST_MAKE_UTIL_MAP_O_O := test -f $$TMP/tools/perf/util/map.o + +TEST_MAKE_PERF_O_O := true +TEST_MAKE_UTIL_MAP_O_O := true + +TEST_DEFAULT = test -x $(PERF)/perf +test = $(if $(TEST_$1),$(TEST_$1),$(TEST_DEFAULT)) + +TEST_DEFAULT_O = test -x $$TMP/perf +test_o = $(if $(TEST_$1),$(TEST_$1),$(TEST_DEFAULT_O)) + +all: + +ifdef DEBUG +d := $(info RUN $(RUN)) +d := $(info RUN_O $(RUN_O)) +endif + +MAKEFLAGS := --no-print-directory + +clean := @cd $(PERF); make -s -f $(MK) clean /dev/null + +$(RUN): + $(call clean) \ + cmd=cd $(PERF) make -f $(MK) $($@); \ + echo $@: $$cmd echo $$cmd $@ \ + ( eval $$cmd ) $@ 21; \ + echo TEST: $(call test,$@); \ + $(call test,$@) + +$(RUN_O): + $(call clean) \ + TMP=$$(mktemp -d); \ + cmd=cd $(PERF) make -f $(MK) $($(patsubst %_O,%,$@)) O=$$TMP; \ + echo $@: $$cmd echo $$cmd $@ \ + ( eval $$cmd ) $@ 21 \ + echo TEST: $(call test_o,$@); \ + $(call test_o,$@) \ + rm -rf $$TMP + +all: $(RUN) $(RUN_O) + @echo OK + +out: $(RUN_O) + @echo OK + +.PHONY: all $(RUN) $(RUN_O) clean -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/27] perf tools: Move arch check into config/Makefile
Moving arch check into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 31 ++- tools/perf/config/Makefile | 34 ++ 2 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 tools/perf/config/Makefile diff --git a/tools/perf/Makefile b/tools/perf/Makefile index c8fb0fd..032e099 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -55,37 +55,11 @@ include config/utilities.mak $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE @$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) -uname_M := $(shell uname -m 2/dev/null || echo not) - -ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) -NO_PERF_REGS := 1 - CC = $(CROSS_COMPILE)gcc AR = $(CROSS_COMPILE)ar -# Additional ARCH settings for x86 -ifeq ($(ARCH),i386) - override ARCH := x86 - NO_PERF_REGS := 0 - LIBUNWIND_LIBS = -lunwind -lunwind-x86 -endif -ifeq ($(ARCH),x86_64) - override ARCH := x86 - IS_X86_64 := 0 - ifeq (, $(findstring m32,$(EXTRA_CFLAGS))) - IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) - endif - ifeq (${IS_X86_64}, 1) - RAW_ARCH := x86_64 - ARCH_CFLAGS := -DARCH_X86_64 - ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S - endif - NO_PERF_REGS := 0 - LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 +ifeq ($(filter clean tags,$(MAKECMDGOALS)),) +include config/Makefile endif # Treat warnings as errors unless directed not to @@ -857,7 +831,6 @@ ifeq ($(NO_PERF_REGS),0) ifeq ($(ARCH),x86) LIB_H += arch/x86/include/perf_regs.h endif - BASIC_CFLAGS += -DHAVE_PERF_REGS endif ifndef NO_STRLCPY diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile new file mode 100644 index 000..fe317c2 --- /dev/null +++ b/tools/perf/config/Makefile @@ -0,0 +1,34 @@ +uname_M := $(shell uname -m 2/dev/null || echo not) + +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) +NO_PERF_REGS := 1 + +# Additional ARCH settings for x86 +ifeq ($(ARCH),i386) + override ARCH := x86 + NO_PERF_REGS := 0 + LIBUNWIND_LIBS = -lunwind -lunwind-x86 +endif + +ifeq ($(ARCH),x86_64) + override ARCH := x86 + IS_X86_64 := 0 + ifeq (, $(findstring m32,$(EXTRA_CFLAGS))) + IS_X86_64 := $(shell echo __x86_64__ | ${CC} -E -x c - | tail -n 1) + endif + ifeq (${IS_X86_64}, 1) + RAW_ARCH := x86_64 + ARCH_CFLAGS := -DARCH_X86_64 + ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S ../../arch/x86/lib/memset_64.S + endif + NO_PERF_REGS := 0 + LIBUNWIND_LIBS = -lunwind -lunwind-x86_64 +endif + +ifeq ($(NO_PERF_REGS),0) +BASIC_CFLAGS += -DHAVE_PERF_REGS +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 07/27] perf tools: Move libdw check config into config/Makefile
Moving libdw check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 7 --- tools/perf/config/Makefile | 15 +++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 0ea3359..ed5e8c9 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -503,15 +503,8 @@ LIB_OBJS += $(OUTPUT)util/symbol-minimal.o else # NO_LIBELF ifndef NO_DWARF -ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) - msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); -else - BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS) - BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) - EXTLIBS += -lelf -ldw LIB_OBJS += $(OUTPUT)util/probe-finder.o LIB_OBJS += $(OUTPUT)util/dwarf-aux.o -endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF endif # NO_LIBELF diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index ef09d6c..3620877 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -154,4 +154,19 @@ FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) BASIC_CFLAGS += -DLIBELF_MMAP endif + +# include ARCH specific config +-include arch/$(ARCH)/Makefile + +ifndef NO_DWARF +ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) + msg := $(warning DWARF register mappings have not been defined for architecture $(ARCH), DWARF support disabled); + NO_DWARF := 1 +else + BASIC_CFLAGS := -DDWARF_SUPPORT $(LIBDW_CFLAGS) $(BASIC_CFLAGS) + BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) + EXTLIBS += -lelf -ldw +endif # PERF_HAVE_DWARF_REGS +endif # NO_DWARF + endif # NO_LIBELF -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 10/27] perf tools: Move slang check config into config/Makefile
Moving slang check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 39 +-- tools/perf/config/Makefile | 17 + 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index 16d1362..f6744cb 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -87,10 +87,6 @@ ifeq ($(filter clean tags,$(MAKECMDGOALS)),) include config/Makefile endif -ifdef NO_NEWT - NO_SLANG=1 -endif - # Among the variables below, these: # perfexecdir # template_dir @@ -497,28 +493,19 @@ ifndef NO_LIBAUDIT endif ifndef NO_SLANG - FLAGS_SLANG=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang - ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y) - msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); - else - # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h - BASIC_CFLAGS += -I/usr/include/slang - BASIC_CFLAGS += -DSLANG_SUPPORT - EXTLIBS += -lslang - LIB_OBJS += $(OUTPUT)ui/browser.o - LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o - LIB_OBJS += $(OUTPUT)ui/browsers/hists.o - LIB_OBJS += $(OUTPUT)ui/browsers/map.o - LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o - LIB_OBJS += $(OUTPUT)ui/tui/setup.o - LIB_OBJS += $(OUTPUT)ui/tui/util.o - LIB_OBJS += $(OUTPUT)ui/tui/helpline.o - LIB_OBJS += $(OUTPUT)ui/tui/progress.o - LIB_H += ui/browser.h - LIB_H += ui/browsers/map.h - LIB_H += ui/keysyms.h - LIB_H += ui/libslang.h - endif + LIB_OBJS += $(OUTPUT)ui/browser.o + LIB_OBJS += $(OUTPUT)ui/browsers/annotate.o + LIB_OBJS += $(OUTPUT)ui/browsers/hists.o + LIB_OBJS += $(OUTPUT)ui/browsers/map.o + LIB_OBJS += $(OUTPUT)ui/browsers/scripts.o + LIB_OBJS += $(OUTPUT)ui/tui/setup.o + LIB_OBJS += $(OUTPUT)ui/tui/util.o + LIB_OBJS += $(OUTPUT)ui/tui/helpline.o + LIB_OBJS += $(OUTPUT)ui/tui/progress.o + LIB_H += ui/browser.h + LIB_H += ui/browsers/map.h + LIB_H += ui/keysyms.h + LIB_H += ui/libslang.h endif ifndef NO_GTK2 diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 52d6fe9..008b212 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -208,3 +208,20 @@ ifndef NO_LIBAUDIT EXTLIBS += -laudit endif endif + +ifdef NO_NEWT + NO_SLANG=1 +endif + +ifndef NO_SLANG + FLAGS_SLANG=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) -I/usr/include/slang -lslang + ifneq ($(call try-cc,$(SOURCE_SLANG),$(FLAGS_SLANG),libslang),y) + msg := $(warning slang not found, disables TUI support. Please install slang-devel or libslang-dev); + NO_SLANG := 1 + else + # Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h + BASIC_CFLAGS += -I/usr/include/slang + BASIC_CFLAGS += -DSLANG_SUPPORT + EXTLIBS += -lslang + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 11/27] perf tools: Move gtk2 check config into config/Makefile
Moving gtk2 check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 25 +++-- tools/perf/config/Makefile | 15 +++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index f6744cb..8d3dd8e 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -509,24 +509,13 @@ ifndef NO_SLANG endif ifndef NO_GTK2 - FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2/dev/null) - ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) - msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); - else - ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) - BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR - endif - BASIC_CFLAGS += -DGTK2_SUPPORT - BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2/dev/null) - EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2/dev/null) - LIB_OBJS += $(OUTPUT)ui/gtk/browser.o - LIB_OBJS += $(OUTPUT)ui/gtk/hists.o - LIB_OBJS += $(OUTPUT)ui/gtk/setup.o - LIB_OBJS += $(OUTPUT)ui/gtk/util.o - LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o - LIB_OBJS += $(OUTPUT)ui/gtk/progress.o - LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o - endif + LIB_OBJS += $(OUTPUT)ui/gtk/browser.o + LIB_OBJS += $(OUTPUT)ui/gtk/hists.o + LIB_OBJS += $(OUTPUT)ui/gtk/setup.o + LIB_OBJS += $(OUTPUT)ui/gtk/util.o + LIB_OBJS += $(OUTPUT)ui/gtk/helpline.o + LIB_OBJS += $(OUTPUT)ui/gtk/progress.o + LIB_OBJS += $(OUTPUT)ui/gtk/annotate.o endif ifdef NO_LIBPERL diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 008b212..6fc2089 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -225,3 +225,18 @@ ifndef NO_SLANG EXTLIBS += -lslang endif endif + +ifndef NO_GTK2 + FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2/dev/null) + ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2),gtk2),y) + msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); + NO_GTK2 := 1 + else + ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2),-DHAVE_GTK_INFO_BAR),y) + BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR + endif + BASIC_CFLAGS += -DGTK2_SUPPORT + BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2/dev/null) + EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2/dev/null) + endif +endif -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 08/27] perf tools: Move libunwind check config into config/Makefile
Moving libunwind check config into config/Makefile. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 24 tools/perf/config/Makefile | 27 +++ 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index ed5e8c9..5e877a4 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -461,26 +461,6 @@ ifneq ($(MAKECMDGOALS),tags) # because maintaining the nesting to match is a pain. If # we had elif things would have been much nicer... -# There's only x86 (both 32 and 64) support for CFI unwind so far -ifneq ($(ARCH),x86) - NO_LIBUNWIND := 1 -endif - -ifndef NO_LIBUNWIND -# for linking with debug library, run like: -# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ -ifdef LIBUNWIND_DIR - LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include - LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib -endif - -FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) -ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) - msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] = 0.99); - NO_LIBUNWIND := 1 -endif # Libunwind support -endif # NO_LIBUNWIND - -include arch/$(ARCH)/Makefile ifneq ($(OUTPUT),) @@ -509,10 +489,6 @@ endif # NO_DWARF endif # NO_LIBELF ifndef NO_LIBUNWIND - BASIC_CFLAGS += -DLIBUNWIND_SUPPORT - EXTLIBS += $(LIBUNWIND_LIBS) - BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) - BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) LIB_OBJS += $(OUTPUT)util/unwind.o endif diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index 3620877..92c395f 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -170,3 +170,30 @@ endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF endif # NO_LIBELF + +# There's only x86 (both 32 and 64) support for CFI unwind so far +ifneq ($(ARCH),x86) + NO_LIBUNWIND := 1 +endif + +ifndef NO_LIBUNWIND +# for linking with debug library, run like: +# make DEBUG=1 LIBUNWIND_DIR=/opt/libunwind/ +ifdef LIBUNWIND_DIR + LIBUNWIND_CFLAGS := -I$(LIBUNWIND_DIR)/include + LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib +endif + +FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(ALL_CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(LIBUNWIND_LIBS) +ifneq ($(call try-cc,$(SOURCE_LIBUNWIND),$(FLAGS_UNWIND),libunwind),y) + msg := $(warning No libunwind found, disabling post unwind support. Please install libunwind-dev[el] = 0.99); + NO_LIBUNWIND := 1 +endif # Libunwind support +endif # NO_LIBUNWIND + +ifndef NO_LIBUNWIND + BASIC_CFLAGS += -DLIBUNWIND_SUPPORT + EXTLIBS += $(LIBUNWIND_LIBS) + BASIC_CFLAGS := $(LIBUNWIND_CFLAGS) $(BASIC_CFLAGS) + BASIC_LDFLAGS := $(LIBUNWIND_LDFLAGS) $(BASIC_LDFLAGS) +endif # NO_LIBUNWIND -- 1.7.11.7 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 20/27] perf tools: Merge all *LDFLAGS* make variable into LDFLAGS
Merging all *LDFLAGS* make variable into LDFLAGS to eliminate all special *LDFLAGS* variables and make the setup clear. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 6 ++ tools/perf/config/Makefile | 41 +++-- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index d467820..a1170a1 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -501,8 +501,6 @@ endif LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group -ALL_LDFLAGS += $(BASIC_LDFLAGS) - export INSTALL SHELL_PATH ### Build rules @@ -525,7 +523,7 @@ $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS $(CFLAGS) -c $(filter %.c,$^) -o $@ $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \ + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OUTPUT)perf.o \ $(BUILTIN_OBJS) $(LIBS) -o $@ $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS @@ -630,7 +628,7 @@ $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o: scripts/python/Perf-Trace-Uti $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs $ $(OUTPUT)perf-%: %.o $(PERFLIBS) - $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + $(QUIET_LINK)$(CC) $(CFLAGS) -o $@ $(LDFLAGS) $(filter %.o,$^) $(LIBS) $(LIB_OBJS) $(BUILTIN_OBJS): $(LIB_H) $(patsubst perf-%,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h) diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile index a53d2b3..c6e4902 100644 --- a/tools/perf/config/Makefile +++ b/tools/perf/config/Makefile @@ -71,7 +71,6 @@ CFLAGS += \ -std=gnu99 EXTLIBS = -lpthread -lrt -lelf -lm -ALL_LDFLAGS = $(LDFLAGS) ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -Werror -fstack-protector-all,-fstack-protector-all),y) CFLAGS += -fstack-protector-all @@ -107,8 +106,6 @@ CFLAGS += \ -I../lib/ \ -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -BASIC_LDFLAGS = - ifeq ($(call try-cc,$(SOURCE_BIONIC),$(CFLAGS),bionic),y) BIONIC := 1 EXTLIBS := $(filter-out -lrt,$(EXTLIBS)) @@ -120,9 +117,9 @@ ifdef NO_LIBELF NO_DEMANGLE := 1 NO_LIBUNWIND := 1 else -FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) +FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF),libelf),y) - FLAGS_GLIBC=$(CFLAGS) $(ALL_LDFLAGS) + FLAGS_GLIBC=$(CFLAGS) $(LDFLAGS) ifeq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC),glibc),y) LIBC_SUPPORT := 1 endif @@ -146,7 +143,7 @@ else LIBDW_LDFLAGS := -L$(LIBDW_DIR)/lib endif - FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) + FLAGS_DWARF=$(CFLAGS) $(LIBDW_CFLAGS) -ldw -lelf $(LIBDW_LDFLAGS) $(LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_DWARF),$(FLAGS_DWARF),libdw),y) msg := $(warning No libdw.h found or old libdw.h found or elfutils is older than 0.138, disables dwarf support. Please install new elfutils-devel/libdw-dev); NO_DWARF := 1 @@ -156,7 +153,7 @@ endif # NO_LIBELF ifndef NO_LIBELF CFLAGS += -DLIBELF_SUPPORT -FLAGS_LIBELF=$(CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) +FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) CFLAGS += -DLIBELF_MMAP endif @@ -170,13 +167,21 @@ ifeq ($(origin PERF_HAVE_DWARF_REGS), undefined) NO_DWARF := 1 else CFLAGS += -DDWARF_SUPPORT $(LIBDW_CFLAGS) - BASIC_LDFLAGS := $(LIBDW_LDFLAGS) $(BASIC_LDFLAGS) + LDFLAGS += $(LIBDW_LDFLAGS) EXTLIBS += -lelf -ldw endif # PERF_HAVE_DWARF_REGS endif # NO_DWARF endif # NO_LIBELF +ifndef NO_LIBELF +CFLAGS += -DLIBELF_SUPPORT +FLAGS_LIBELF=$(CFLAGS) $(LDFLAGS) $(EXTLIBS) +ifeq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_LIBELF),-DLIBELF_MMAP),y) + CFLAGS += -DLIBELF_MMAP +endif # try-cc +endif # NO_LIBELF + # There's only x86 (both 32 and 64) support for CFI unwind so far ifneq ($(ARCH),x86) NO_LIBUNWIND := 1 @@ -190,7 +195,7 @@ ifdef LIBUNWIND_DIR LIBUNWIND_LDFLAGS := -L$(LIBUNWIND_DIR)/lib endif -FLAGS_UNWIND=$(LIBUNWIND_CFLAGS) $(CFLAGS) $(LIBUNWIND_LDFLAGS) $(ALL_LDFLAGS) $(EXTLIBS
[PATCH 19/27] perf tools: Merge all *CFLAGS* make variable into CFLAGS
Merging all *CFLAGS* make variable into CFLAGS to eliminate all special *_CFLAGS_* variables and make the setup clear. Signed-off-by: Jiri Olsa jo...@redhat.com Cc: Arnaldo Carvalho de Melo a...@ghostprotocols.net Cc: Peter Zijlstra a.p.zijls...@chello.nl Cc: Ingo Molnar mi...@elte.hu Cc: Paul Mackerras pau...@samba.org Cc: Corey Ashford cjash...@linux.vnet.ibm.com Cc: Frederic Weisbecker fweis...@gmail.com Cc: Namhyung Kim namhy...@kernel.org Cc: Borislav Petkov b...@alien8.de Cc: Stephane Eranian eran...@google.com --- tools/perf/Makefile| 62 +-- tools/perf/config/Makefile | 104 - tools/perf/util/setup.py | 2 +- 3 files changed, 86 insertions(+), 82 deletions(-) diff --git a/tools/perf/Makefile b/tools/perf/Makefile index c25997f..d467820 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -136,7 +136,7 @@ PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py $(LIBTRACEEVENT) $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) - $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ + $(QUIET_GEN)CFLAGS='$(CFLAGS)' $(PYTHON_WORD) util/setup.py \ --quiet build_ext; \ mkdir -p $(OUTPUT)python \ cp $(PYTHON_EXTBUILD_LIB)perf.so $(OUTPUT)python/ @@ -501,8 +501,6 @@ endif LIBS = -Wl,--whole-archive $(PERFLIBS) -Wl,--no-whole-archive -Wl,--start-group $(EXTLIBS) -Wl,--end-group -ALL_CFLAGS += $(BASIC_CFLAGS) -ALL_CFLAGS += $(ARCH_CFLAGS) ALL_LDFLAGS += $(BASIC_LDFLAGS) export INSTALL SHELL_PATH @@ -524,20 +522,20 @@ strip: $(PROGRAMS) $(OUTPUT)perf $(OUTPUT)perf.o: perf.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS $(QUIET_CC)$(CC) -include $(OUTPUT)PERF-VERSION-FILE \ '-DPERF_HTML_PATH=$(htmldir_SQ)' \ - $(ALL_CFLAGS) -c $(filter %.c,$^) -o $@ + $(CFLAGS) -c $(filter %.c,$^) -o $@ $(OUTPUT)perf: $(OUTPUT)perf.o $(BUILTIN_OBJS) $(PERFLIBS) - $(QUIET_LINK)$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \ + $(QUIET_LINK)$(CC) $(CFLAGS) $(ALL_LDFLAGS) $(OUTPUT)perf.o \ $(BUILTIN_OBJS) $(LIBS) -o $@ $(OUTPUT)builtin-help.o: builtin-help.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ '-DPERF_HTML_PATH=$(htmldir_SQ)' \ '-DPERF_MAN_PATH=$(mandir_SQ)' \ '-DPERF_INFO_PATH=$(infodir_SQ)' $ $(OUTPUT)builtin-timechart.o: builtin-timechart.c $(OUTPUT)common-cmds.h $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ '-DPERF_HTML_PATH=$(htmldir_SQ)' \ '-DPERF_MAN_PATH=$(mandir_SQ)' \ '-DPERF_INFO_PATH=$(infodir_SQ)' $ @@ -562,77 +560,77 @@ $(OUTPUT)perf.o perf.spec \ # over the general rule for .o $(OUTPUT)util/%-flex.o: $(OUTPUT)util/%-flex.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(ALL_CFLAGS) -w $ + $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -w $ $(OUTPUT)util/%-bison.o: $(OUTPUT)util/%-bison.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(ALL_CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $ + $(QUIET_CC)$(CC) -o $@ -c -Iutil/ $(CFLAGS) -DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=0 -w $ $(OUTPUT)%.o: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $ $(OUTPUT)%.i: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $ + $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $ $(OUTPUT)%.s: %.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -S $(ALL_CFLAGS) $ + $(QUIET_CC)$(CC) -o $@ -S $(CFLAGS) $ $(OUTPUT)%.o: %.S - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) $ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $ $(OUTPUT)%.s: %.S - $(QUIET_CC)$(CC) -o $@ -E $(ALL_CFLAGS) $ + $(QUIET_CC)$(CC) -o $@ -E $(CFLAGS) $ $(OUTPUT)util/exec_cmd.o: util/exec_cmd.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ '-DPERF_EXEC_PATH=$(perfexecdir_SQ)' \ '-DPREFIX=$(prefix_SQ)' \ $ $(OUTPUT)tests/attr.o: tests/attr.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ '-DBINDIR=$(bindir_SQ)' -DPYTHON='$(PYTHON_WORD)' \ $ $(OUTPUT)tests/python-use.o: tests/python-use.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) \ + $(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) \ -DPYTHONPATH='$(OUTPUT)python' \ -DPYTHON='$(PYTHON_WORD)' \ $ $(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS - $(QUIET_CC
Re: [PATCH 5/9] perf sort: Separate out memory-specific sort keys
On Mon, Apr 01, 2013 at 08:35:21PM +0900, Namhyung Kim wrote: SNIP + int sort_dimension__add(const char *tok) { unsigned int i; @@ -964,6 +971,33 @@ int sort_dimension__add(const char *tok) return 0; } + for (i = 0; i ARRAY_SIZE(memory_sort_dimensions); i++) { + struct sort_dimension *sd = memory_sort_dimensions[i]; + + if (strncasecmp(tok, sd-name, strlen(tok))) + continue; + + if (sort__mode != SORT_MODE__MEMORY) + return -EINVAL; + + if (sd-entry == sort_mem_daddr_sym) + sort__has_sym = 1; + + if (sd-taken) + return 0; + + if (sd-entry-se_collapse) + sort__need_collapse = 1; + + if (list_empty(hist_entry__sort_list)) + sort__first_dimension = i + __SORT_MEMORY_MODE; + + list_add_tail(sd-entry-list, hist_entry__sort_list); + sd-taken = 1; + + return 0; nice idea, I wonder some of the above code be put into function and used also in previous loop, no big deal though jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 6/9] perf sort: Add 'addr' sort key
On Mon, Apr 01, 2013 at 08:35:22PM +0900, Namhyung Kim wrote: From: Namhyung Kim namhyung@lge.com New addr sort key provides a way to sort the entries by the symbol addresses. It can be helpful to figure out symbol resolution problem when a dso cannot do it properly as well as finding hotpath in a dso and/or a function. maybe it's just the recent mem profiling patches, but wouldn't it be better to use 'ip' instead of 'addr'? also it's following code getting the data: ... if (sample_type PERF_SAMPLE_IP) data-ip = perf_instruction_pointer(regs); ... same for the perf sort: Add 'addr_to/from' sort key patch jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 27/27] perf tools: Add kbuild support into Makefile.kbuild
On Mon, Apr 01, 2013 at 10:03:42PM +0200, Sam Ravnborg wrote: On Mon, Apr 01, 2013 at 09:18:50PM +0200, Jiri Olsa wrote: Adding kbuild support into Makefile.kbuild. The 'legacy' Makefile still stays untouched as it was. When readign the Kbuild file I get confused. the obj-y syntax is used for kernel built-in stuff, and obj-m for modules. I had expected either a perf specific syntax or something like the syntax used for host programs. While building kernel you need to have separate flags for internal objects and for host programs. First, I thought I need to separate it as you say, but perf build is separated from kernel built process, so AFAICS we can use obj-y with no harm in perf. It's quite possible I missed something and kbuild folks prove me wrong ;-) The Makefile.kbuild defines flags to be used for obj-y. jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 03/27] perf tools: Move arch check into config/Makefile
On Mon, Apr 01, 2013 at 09:54:46PM +0200, Sam Ravnborg wrote: SNIP diff --git a/tools/perf/config/Makefile b/tools/perf/config/Makefile new file mode 100644 index 000..fe317c2 --- /dev/null +++ b/tools/perf/config/Makefile @@ -0,0 +1,34 @@ +uname_M := $(shell uname -m 2/dev/null || echo not) + +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ ) this is shared with the top-level kernel Makefile. Could we find a way to share this? right, maybe we could place it under some scripts/ lib file, I'll check thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 01/27] perf tools: Add automated make test suite
On Mon, Apr 01, 2013 at 09:53:18PM +0200, Sam Ravnborg wrote: SNIP + +MAKE_DEBUG := DEBUG=1 +MAKE_NO_LIBPERL := NO_LIBPERL=1 Why all these ugly UPPERCASE names? In kbuild files the unwritten rule is that variables with global scope are upper-case. And variables with local scope are lower case. You can find many examples where this is not followed - but this is the general approach. ok, for some reason I'm used to use capitals for makefile variables ;) +MAKE_MINIMAL:= NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 NO_DEMANGLE=1 NO_LIBELF=1 NO_LIBUNWIND=1 NO_BACKTRACE=1 NO_LIBNUMA=1 NO_LIBAUDIT=1 NO_LIBBIONIC=1 Keeping lines less than 120 chars long is good. Some people swer to 80 chars. ok +RUN := \ + MAKE_PURE \ + MAKE_DEBUG \ + MAKE_NO_LIBPERL \ RUN += MAKE_PURE RUN += MAKE_DEBUG RUN += MAKE_NO_LIBPERL Is so much more readable. As a general rule - use \ to continue lines only when you really have to. ok thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 02/27] perf tools: Fix tab vs spaces issue in Makefile ifdef/endif
On Mon, Apr 01, 2013 at 09:49:05PM +0200, Sam Ravnborg wrote: On Mon, Apr 01, 2013 at 09:18:25PM +0200, Jiri Olsa wrote: Unmatched spaces/tabs Makefile indentation could make the Makefile fails. While the tabed line could be considered sometimes as follow up for rule command, the mixed space tab meses up with makefile if conditions. I have too many times been beaten that asssignments was ignored because I used tabs to indendt the assignmnet. So in all Makefile I edit spaces are used for indent. Tabs are only used for commands. sounds like good idea, I'll make separate patch for that thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [RFC 00/27] perf tools: Build changes and kbuild support
On Mon, Apr 01, 2013 at 02:45:09PM -0600, David Ahern wrote: Hi Jiri: On 4/1/13 1:18 PM, Jiri Olsa wrote: hi, sending RFC for build changes and kbuild support. Have you seen this patch set: https://lkml.org/lkml/2012/8/20/59 yep, I remember checking it.. but I decided to start over because I wanted to use kbuild build support as well Now when I'm checking that I see you made also some source changes to make the build separation possible. I haven't done much on this part and some of the libraries/features/builtins could not be disabled at the moment, because the code is not properly separated. It hooks into the conf commands to generate a .config file. Coincidentally I updated and expanded the patch series this morning to include dependencies and such. Latest Pconfig attached to give you an idea. I need to collapse a few patches and send them out tonight. I'll check your repost thanks, jirka -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/