perf tools: Miscellaneous fix from the previous cycle
cover perf tools: Miscellaneous fix from the previous cycle
Good day Arnaldo,
Here are 3 patches that were sent late in the v4.15 cycle, too late for you to pick up for the v4.16 cycle. I don't know if they are on a backlog of yours somewhere or if you've made a mental note of them - if so kindly disregard this set. Otherwise, here they are again, rebased to your latest perf/core [1].
All 3 patches are required for proper functionning of the CoreSight trace decoding integration that is in the current cycle.
Regards,
Mathieu
[1]. f13c88d836d8 perf report: Add support to display group output for non group events
Jin Yao (1):
perf util: Use target->per_thread and target->system_wide flags
Mathieu Poirier (2):
perf tools: Freeing allocated memory
perf tools: Fixing uninitialised variable
tools/perf/arch/arm/util/auxtrace.c | 2 +- tools/perf/util/cs-etm.c | 6 ++++++ tools/perf/util/evlist.c | 21 ++++++++++++++++++++- tools/perf/util/thread_map.c | 4 ++-- tools/perf/util/thread_map.h | 2 +- 5 files changed, 30 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 perf tools: Freeing allocated memory
This patch frees all the memory allocated in function cs_etm__alloc_queue().
--- tools/perf/util/cs-etm.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/cs-etm.c +6 -0
@@ -174,6 +174,12 @@ static void cs_etm__free_queue(void *priv) {struct cs_etm_queue *etmq = priv; +if (!etmq) +return ; + +thread__zput (etmq->thread); +cs_etm_decoder__free (etmq->decoder); +zfree (&etmq->event_buf);free (etmq); }
Signature · 1 line
2.7.4
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf cs-etm: Freeing allocated memory
perf cs-etm: Freeing allocated memory
Commit-ID: 099c1130998fd2234a200b55d69713ec66d88325 Gitweb: https://git.kernel.org/tip/099c1130998fd2234a200b55d69713ec66d88325 Author: Mathieu Poirier <[email protected]> AuthorDate: Mon, 12 Feb 2018 13:32:35 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 16 Feb 2018 14:55:39 -0300
perf cs-etm: Freeing allocated memory
This patch frees all the memory allocated in function cs_etm__alloc_queue().
--- tools/perf/util/cs-etm.c | 6 ++++++ 1 file changed, 6 insertions(+)
tools/perf/util/cs-etm.c +6 -0
@@ -174,6 +174,12 @@ static void cs_etm__free_queue(void *priv) {struct cs_etm_queue *etmq = priv; +if (!etmq) +return ; + +thread__zput (etmq->thread); +cs_etm_decoder__free (etmq->decoder); +zfree (&etmq->event_buf);free (etmq); }
PATCH 2/3 perf util: Use target->per_thread and target->system_wide flags
In reply to Mathieu PoirierFrom: Jin Yao <[email protected]>
Mathieu Poirier reports issue in commit ("73c0ca1eee3d perf thread_map:
Enumerate all threads from /proc") that it has negative impact on 'perf record --per-thread'. It has the effect of creating a kernel event for each thread in the system for 'perf record --per-thread'.
Mathieu Poirier's patch ("perf util: Do not reuse target->per_thread flag") can fix this issue by creating a new target->all_threads flag.
This patch is based on Mathieu Poirier's patch but it doesn't use a new target->all_threads flag. This patch just uses 'target->per_thread && target->system_wide' as a condition to check for all threads case.
--- tools/perf/util/evlist.c | 21 ++++++++++++++++++++- tools/perf/util/thread_map.c | 4 ++-- tools/perf/util/thread_map.h | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-)
tools/perf/util/evlist.c +20 -1
@@ -1086,11 +1086,30 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)int perf_evlist__create_maps (struct perf_evlist *evlist,struct target *target) { +bool all_threads = (target->per_thread && target->system_wide);struct cpu_map *cpus;struct thread_map *threads; +/* +* If specify '-a' and '--per-thread' to perf record, perf record +* will override '--per-thread'. target->per_thread = false and +* target->system_wide = true. +* +* If specify '--per-thread' only to perf record, +* target->per_thread = true and target->system_wide = false. +* +* So target->per_thread && target->system_wide is false. +* For perf record, thread_map__new_str doesn't call +* thread_map__new_all_cpus. That will keep perf record's +* current behavior. +* +* For perf stat, it allows the case that target->per_thread and +* target->system_wide are all true. It means to collect system-wide +* per-thread data. thread_map__new_str will call +* thread_map__new_all_cpus to enumerate all threads. +*/ threads =thread_map__new_str (target->pid, target->tid, target->uid, - target->per_thread); + all_threads);if (!threads)return -1 ;
tools/perf/util/thread_map.c +2 -2
@@ -323,7 +323,7 @@ struct thread_map *thread_map__new_by_tid_str(const char *tid_str) }struct thread_map *thread_map__new_str (const char *pid,const char *tid, -uid_t uid,bool per_thread) +uid_t uid,bool all_threads) {if (pid)return thread_map__new_by_pid_str (pid);
@@ -331,7 +331,7 @@ struct thread_map *thread_map__new_str(const char *pid, const char *tid,if (!tid && uid !=UINT_MAX )return thread_map__new_by_uid (uid); -if (per_thread) +if (all_threads)return thread_map__new_all_cpus ();return thread_map__new_by_tid_str (tid);
tools/perf/util/thread_map.h +1 -1
@@ -31,7 +31,7 @@ struct thread_map *thread_map__get(struct thread_map *map);void thread_map__put (struct thread_map *map);struct thread_map *thread_map__new_str (const char *pid, -const char *tid,uid_t uid,bool per_thread); +const char *tid,uid_t uid,bool all_threads);struct thread_map *thread_map__new_by_tid_str (const char *tid_str);
Signature · 1 line
2.7.4
tip-bot for Jin Yao
merge bot[tip:perf/core] perf tools: Use target->per_thread and target->system_wide flags
perf tools: Use target->per_thread and target->system_wide flags
Commit-ID: 147c508f3004df6e2958f6c8867909531c2a15e2 Gitweb: https://git.kernel.org/tip/147c508f3004df6e2958f6c8867909531c2a15e2 Author: Jin Yao <[email protected]> AuthorDate: Mon, 12 Feb 2018 13:32:36 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 16 Feb 2018 14:55:40 -0300
perf tools: Use target->per_thread and target->system_wide flags
Mathieu Poirier reports issue in commit ("73c0ca1eee3d perf thread_map:
Enumerate all threads from /proc") that it has negative impact on 'perf record --per-thread'. It has the effect of creating a kernel event for each thread in the system for 'perf record --per-thread'.
Mathieu Poirier's patch ("perf util: Do not reuse target->per_thread flag") can fix this issue by creating a new target->all_threads flag.
This patch is based on Mathieu Poirier's patch but it doesn't use a new target->all_threads flag. This patch just uses 'target->per_thread && target->system_wide' as a condition to check for all threads case.
--- tools/perf/util/evlist.c | 21 ++++++++++++++++++++- tools/perf/util/thread_map.c | 4 ++-- tools/perf/util/thread_map.h | 2 +- 3 files changed, 23 insertions(+), 4 deletions(-)
tools/perf/util/evlist.c +20 -1
@@ -1086,11 +1086,30 @@ int perf_evlist__mmap(struct perf_evlist *evlist, unsigned int pages)int perf_evlist__create_maps (struct perf_evlist *evlist,struct target *target) { +bool all_threads = (target->per_thread && target->system_wide);struct cpu_map *cpus;struct thread_map *threads; +/* +* If specify '-a' and '--per-thread' to perf record, perf record +* will override '--per-thread'. target->per_thread = false and +* target->system_wide = true. +* +* If specify '--per-thread' only to perf record, +* target->per_thread = true and target->system_wide = false. +* +* So target->per_thread && target->system_wide is false. +* For perf record, thread_map__new_str doesn't call +* thread_map__new_all_cpus. That will keep perf record's +* current behavior. +* +* For perf stat, it allows the case that target->per_thread and +* target->system_wide are all true. It means to collect system-wide +* per-thread data. thread_map__new_str will call +* thread_map__new_all_cpus to enumerate all threads. +*/ threads =thread_map__new_str (target->pid, target->tid, target->uid, - target->per_thread); + all_threads);if (!threads)return -1 ;
tools/perf/util/thread_map.c +2 -2
@@ -323,7 +323,7 @@ out_free_threads: }struct thread_map *thread_map__new_str (const char *pid,const char *tid, -uid_t uid,bool per_thread) +uid_t uid,bool all_threads) {if (pid)return thread_map__new_by_pid_str (pid);
@@ -331,7 +331,7 @@ struct thread_map *thread_map__new_str(const char *pid, const char *tid,if (!tid && uid !=UINT_MAX )return thread_map__new_by_uid (uid); -if (per_thread) +if (all_threads)return thread_map__new_all_cpus ();return thread_map__new_by_tid_str (tid);
tools/perf/util/thread_map.h +1 -1
@@ -31,7 +31,7 @@ struct thread_map *thread_map__get(struct thread_map *map);void thread_map__put (struct thread_map *map);struct thread_map *thread_map__new_str (const char *pid, -const char *tid,uid_t uid,bool per_thread); +const char *tid,uid_t uid,bool all_threads);struct thread_map *thread_map__new_by_tid_str (const char *tid_str);
PATCH 3/3 perf tools: Fixing uninitialised variable
In reply to Mathieu PoirierWhen working natively on arm64 the compiler gets pesky and complains that variable 'i' is uninitialised, something that breaks the compilation. Here no further checks are needed since variable 'found_spe' can only be true if variable 'i' has been initialised as part of the for loop.
--- tools/perf/arch/arm/util/auxtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/arm/util/auxtrace.c +1 -1
@@ -68,7 +68,7 @@ struct auxtrace_recordbool found_spe = false;static struct perf_pmu **arm_spe_pmus =NULL ;static int nr_spes =0 ; -int i; +int i =0 ;if (!evlist)return NULL ;
Signature · 1 line
2.7.4
tip-bot for Mathieu Poirier
merge bot[tip:perf/core] perf auxtrace arm: Fixing uninitialised variable
perf auxtrace arm: Fixing uninitialised variable
Commit-ID: d2785de15f1bd42d613d56bbac5a007e7293b874 Gitweb: https://git.kernel.org/tip/d2785de15f1bd42d613d56bbac5a007e7293b874 Author: Mathieu Poirier <[email protected]> AuthorDate: Mon, 12 Feb 2018 13:32:37 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 16 Feb 2018 14:55:40 -0300
perf auxtrace arm: Fixing uninitialised variable
When working natively on arm64 the compiler gets pesky and complains that variable 'i' is uninitialised, something that breaks the compilation. Here no further checks are needed since variable 'found_spe' can only be true if variable 'i' has been initialised as part of the for loop.
--- tools/perf/arch/arm/util/auxtrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/arm/util/auxtrace.c +1 -1
@@ -68,7 +68,7 @@ struct auxtrace_recordbool found_spe = false;static struct perf_pmu **arm_spe_pmus =NULL ;static int nr_spes =0 ; -int i; +int i =0 ;if (!evlist)return NULL ;
Em Mon, Feb 12, 2018 at 01:32:34PM -0700, Mathieu Poirier escreveu:
Quoted 10 lines
Good day Arnaldo,
Here are 3 patches that were sent late in the v4.15 cycle, too late for you to pick up for the v4.16 cycle. I don't know if they are on a backlog of yours somewhere or if you've made a mental note of them - if so kindly disregard this set. Otherwise, here they are again, rebased to your latest perf/core [1].
All 3 patches are required for proper functionning of the CoreSight trace decoding integration that is in the current cycle.
Thanks, applied the 3 patches.
- Arnaldo