perf tools: Initial libperf separation
Subsystems (9)
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions
In reply to Jiri Olsalibperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions
Commit-ID: 9c3516d1b850ea938b074df33e4c86d721c77720 Gitweb: https://git.kernel.org/tip/9c3516d1b850ea938b074df33e4c86d721c77720 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:30 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_cpu_map__new()/perf_cpu_map__read() functions
Moving the following functions from tools/perf:
cpu_map__new()
cpu_map__read()
to libperf with the following names:
perf_cpu_map__new()
perf_cpu_map__read()
Committer notes:
Fixed up this one:
tools/perf/arch/arm/util/cs-etm.c
--- tools/perf/arch/arm/util/cs-etm.c | 6 +- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 3 +- tools/perf/bench/epoll-ctl.c | 3 +- tools/perf/bench/epoll-wait.c | 3 +- tools/perf/bench/futex-hash.c | 3 +- tools/perf/bench/futex-lock-pi.c | 3 +- tools/perf/bench/futex-requeue.c | 3 +- tools/perf/bench/futex-wake-parallel.c | 2 +- tools/perf/bench/futex-wake.c | 3 +- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-sched.c | 4 +- tools/perf/lib/cpumap.c | 184 +++++++++++++++++++++++++++ tools/perf/lib/include/internal/cpumap.h | 4 + tools/perf/lib/include/perf/cpumap.h | 3 + tools/perf/lib/libperf.map | 2 + tools/perf/tests/bitmap.c | 3 +- tools/perf/tests/code-reading.c | 5 +- tools/perf/tests/cpumap.c | 7 +- tools/perf/tests/event-times.c | 9 +- tools/perf/tests/event_update.c | 3 +- tools/perf/tests/keep-tracking.c | 3 +- tools/perf/tests/mem2node.c | 3 +- tools/perf/tests/mmap-basic.c | 3 +- tools/perf/tests/openat-syscall-all-cpus.c | 2 +- tools/perf/tests/switch-tracking.c | 5 +- tools/perf/tests/topology.c | 3 +- tools/perf/util/cpumap.c | 181 +------------------------- tools/perf/util/cpumap.h | 2 - tools/perf/util/cputopo.c | 5 +- tools/perf/util/evlist.c | 5 +- tools/perf/util/header.c | 3 +- tools/perf/util/parse-events.c | 3 +- tools/perf/util/pmu.c | 3 +- tools/perf/util/python.c | 3 +- tools/perf/util/record.c | 7 +- tools/perf/util/session.c | 3 +- tools/perf/util/svghelper.c | 3 +- 37 files changed, 265 insertions(+), 227 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +3 -3
@@ -156,7 +156,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr, {int i, err = -EINVAL ;struct perf_cpu_map *event_cpus = evsel->evlist->cpus; -struct perf_cpu_map *online_cpus =cpu_map__new (NULL ); +struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );/* Set option of each CPU we have */ for (i =0 ; i <cpu__max_cpu (); i++) {
@@ -490,7 +490,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused,int i;int etmv3 =0 , etmv4 =0 ;struct perf_cpu_map *event_cpus = evlist->cpus; -struct perf_cpu_map *online_cpus =cpu_map__new (NULL ); +struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );/* cpu map is not empty, we have specific CPUs to work with */ if (!cpu_map__empty (event_cpus)) {
@@ -637,7 +637,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,u64 nr_cpu, type;struct perf_cpu_map *cpu_map;struct perf_cpu_map *event_cpus = session->evlist->cpus; -struct perf_cpu_map *online_cpus =cpu_map__new (NULL ); +struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr);struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;
tools/perf/arch/x86/tests/perf-time-to-tsc.c +2 -1
@@ -5,6 +5,7 @@#include <unistd.h> #include <linux/types.h> #include <sys/prctl.h> +#include <perf/cpumap.h> #include "parse-events.h" #include "evlist.h"
@@ -65,7 +66,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads); - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );CHECK_NOT_NULL__ (cpus); evlist =evlist__new ();
tools/perf/bench/epoll-ctl.c +2 -1
@@ -20,6 +20,7 @@#include <sys/resource.h> #include <sys/epoll.h> #include <sys/eventfd.h> +#include <perf/cpumap.h> #include "../util/stat.h" #include <subcmd/parse-options.h>
@@ -315,7 +316,7 @@ int bench_epoll_ctl(int argc, const char **argv) act.sa_sigaction = toggle_done;sigaction (SIGINT , &act,NULL ); - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu) goto errmem;
tools/perf/bench/epoll-wait.c +2 -1
@@ -75,6 +75,7 @@#include <sys/epoll.h> #include <sys/eventfd.h> #include <sys/types.h> +#include <perf/cpumap.h> #include "../util/stat.h" #include <subcmd/parse-options.h>
@@ -429,7 +430,7 @@ int bench_epoll_wait(int argc, const char **argv) act.sa_sigaction = toggle_done;sigaction (SIGINT , &act,NULL ); - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu) goto errmem;
tools/perf/bench/futex-hash.c +2 -1
@@ -20,6 +20,7 @@#include <linux/kernel.h> #include <linux/zalloc.h> #include <sys/time.h> +#include <perf/cpumap.h> #include "../util/stat.h" #include <subcmd/parse-options.h>
@@ -132,7 +133,7 @@ int bench_futex_hash(int argc, const char **argv)exit (EXIT_FAILURE ); } - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu) goto errmem;
tools/perf/bench/futex-lock-pi.c +2 -1
@@ -14,6 +14,7 @@#include <linux/kernel.h> #include <linux/zalloc.h> #include <errno.h> +#include <perf/cpumap.h> #include "bench.h" #include "futex.h" #include "cpumap.h"
@@ -156,7 +157,7 @@ int bench_futex_lock_pi(int argc, const char **argv)if (argc) goto err; - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu)err (EXIT_FAILURE ,"calloc" );
tools/perf/bench/futex-requeue.c +2 -1
@@ -20,6 +20,7 @@#include <linux/kernel.h> #include <linux/time64.h> #include <errno.h> +#include <perf/cpumap.h> #include "bench.h" #include "futex.h" #include "cpumap.h"
@@ -123,7 +124,7 @@ int bench_futex_requeue(int argc, const char **argv)if (argc) goto err; - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu)err (EXIT_FAILURE ,"cpu_map__new" );
tools/perf/bench/futex-wake-parallel.c +1 -1
@@ -237,7 +237,7 @@ int bench_futex_wake_parallel(int argc, const char **argv) act.sa_sigaction = toggle_done;sigaction (SIGINT , &act,NULL ); - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu)err (EXIT_FAILURE ,"calloc" );
tools/perf/bench/futex-wake.c +2 -1
@@ -20,6 +20,7 @@#include <linux/kernel.h> #include <linux/time64.h> #include <errno.h> +#include <perf/cpumap.h> #include "bench.h" #include "futex.h" #include "cpumap.h"
@@ -131,7 +132,7 @@ int bench_futex_wake(int argc, const char **argv)exit (EXIT_FAILURE ); } - cpu =cpu_map__new (NULL ); + cpu =perf_cpu_map__new (NULL );if (!cpu)err (EXIT_FAILURE ,"calloc" );
tools/perf/builtin-ftrace.c +1 -1
@@ -202,7 +202,7 @@ static int set_tracing_cpu(struct perf_ftrace *ftrace)static int reset_tracing_cpu (void ) { -struct perf_cpu_map *cpumap =cpu_map__new (NULL ); +struct perf_cpu_map *cpumap =perf_cpu_map__new (NULL );int ret; ret =set_tracing_cpumask (cpumap);
tools/perf/builtin-sched.c +2 -2
@@ -3183,7 +3183,7 @@ static int setup_map_cpus(struct perf_sched *sched)if (!sched->map.cpus_str)return 0 ; - map =cpu_map__new (sched->map.cpus_str); + map =perf_cpu_map__new (sched->map.cpus_str);if (!map) {pr_err ("failed to get cpus map from %s\n" , sched->map.cpus_str);return -1 ;
@@ -3217,7 +3217,7 @@ static int setup_color_cpus(struct perf_sched *sched)if (!sched->map.color_cpus_str)return 0 ; - map =cpu_map__new (sched->map.color_cpus_str); + map =perf_cpu_map__new (sched->map.color_cpus_str);if (!map) {pr_err ("failed to get thread map from %s\n" , sched->map.color_cpus_str);return -1 ;
tools/perf/lib/cpumap.c +184 -0
193 lines not on this page · raw message
tools/perf/lib/include/internal/cpumap.h +4 -0
@@ -10,4 +10,8 @@ struct perf_cpu_map { int map[]; }; +#ifndef MAX_NR_CPUS +#define MAX_NR_CPUS 2048 +#endif +#endif /* __LIBPERF_INTERNAL_CPUMAP_H */
tools/perf/lib/include/perf/cpumap.h +3 -0
@@ -3,10 +3,13 @@#define __LIBPERF_CPUMAP_H#include <perf/core.h> +#include <stdio.h> struct perf_cpu_map ; LIBPERF_API struct perf_cpu_map *perf_cpu_map__dummy_new(void); +LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); +LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file); LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
tools/perf/lib/libperf.map +2 -0
@@ -4,6 +4,8 @@ LIBPERF_0.0.1 { perf_cpu_map__dummy_new; perf_cpu_map__get; perf_cpu_map__put; + perf_cpu_map__new; + perf_cpu_map__read; perf_thread_map__new_dummy; perf_thread_map__set_pid; perf_thread_map__comm;
tools/perf/tests/bitmap.c +2 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/compiler.h> #include <linux/bitmap.h> +#include <perf/cpumap.h> #include "tests.h" #include "cpumap.h" #include "debug.h"
@@ -9,7 +10,7 @@static unsigned long *get_bitmap (const char *str,int nbits) { -struct perf_cpu_map *map =cpu_map__new (str); +struct perf_cpu_map *map =perf_cpu_map__new (str);unsigned long *bm =NULL ;int i;
tools/perf/tests/code-reading.c +3 -2
@@ -8,6 +8,7 @@#include <stdio.h> #include <string.h> #include <sys/param.h> +#include <perf/cpumap.h> #include "parse-events.h" #include "evlist.h"
@@ -613,9 +614,9 @@ static int do_test_code_reading(bool try_kcore) goto out_put; } - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (!cpus) { -pr_debug ("cpu_map__new failed\n" ); +pr_debug ("perf_cpu_map__new failed\n" ); goto out_put; }
tools/perf/tests/cpumap.c +4 -3
@@ -5,6 +5,7 @@#include "event.h" #include <string.h> #include <linux/bitops.h> +#include <perf/cpumap.h> #include "debug.h" struct machine ;
@@ -78,7 +79,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maystruct perf_cpu_map *cpus;/* This one is better stores in mask. */ - cpus =cpu_map__new ("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19" ); + cpus =perf_cpu_map__new ("0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19" );TEST_ASSERT_VAL ("failed to synthesize map" , !perf_event__synthesize_cpu_map (NULL , cpus, process_event_mask,NULL ));
@@ -86,7 +87,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __mayperf_cpu_map__put (cpus);/* This one is better stores in cpu values. */ - cpus =cpu_map__new ("1,256" ); + cpus =perf_cpu_map__new ("1,256" );TEST_ASSERT_VAL ("failed to synthesize map" , !perf_event__synthesize_cpu_map (NULL , cpus, process_event_cpus,NULL ));
@@ -97,7 +98,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __maystatic int cpu_map_print (const char *str) { -struct perf_cpu_map *map =cpu_map__new (str); +struct perf_cpu_map *map =perf_cpu_map__new (str);char buf[100 ];if (!map)
tools/perf/tests/event-times.c +5 -4
@@ -4,6 +4,7 @@#include <inttypes.h> #include <string.h> #include <sys/wait.h> +#include <perf/cpumap.h> #include "tests.h" #include "evlist.h" #include "evsel.h"
@@ -115,9 +116,9 @@ static int attach__cpu_disabled(struct evlist *evlist)pr_debug ("attaching to CPU 0 as enabled\n" ); - cpus =cpu_map__new ("0" ); + cpus =perf_cpu_map__new ("0" );if (cpus ==NULL ) { -pr_debug ("failed to call cpu_map__new\n" ); +pr_debug ("failed to call perf_cpu_map__new\n" );return -1 ; }
@@ -144,9 +145,9 @@ static int attach__cpu_enabled(struct evlist *evlist)pr_debug ("attaching to CPU 0 as enabled\n" ); - cpus =cpu_map__new ("0" ); + cpus =perf_cpu_map__new ("0" );if (cpus ==NULL ) { -pr_debug ("failed to call cpu_map__new\n" ); +pr_debug ("failed to call perf_cpu_map__new\n" );return -1 ; }
tools/perf/tests/event_update.c +2 -1
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/compiler.h> +#include <perf/cpumap.h> #include "evlist.h" #include "evsel.h" #include "machine.h"
@@ -108,7 +109,7 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("failed to synthesize attr update name" , !perf_event__synthesize_event_update_name (&tmp.tool, evsel, process_event_name)); - evsel->own_cpus =cpu_map__new ("1,2,3" ); + evsel->own_cpus =perf_cpu_map__new ("1,2,3" );TEST_ASSERT_VAL ("failed to synthesize attr update cpus" , !perf_event__synthesize_event_update_cpus (&tmp.tool, evsel, process_event_cpus));
tools/perf/tests/keep-tracking.c +2 -1
@@ -2,6 +2,7 @@#include <linux/types.h> #include <unistd.h> #include <sys/prctl.h> +#include <perf/cpumap.h> #include "parse-events.h" #include "evlist.h"
@@ -75,7 +76,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un threads =thread_map__new (-1 ,getpid (),UINT_MAX );CHECK_NOT_NULL__ (threads); - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );CHECK_NOT_NULL__ (cpus); evlist =evlist__new ();
tools/perf/tests/mem2node.c +2 -1
@@ -2,6 +2,7 @@#include <linux/compiler.h> #include <linux/bitmap.h> #include <linux/zalloc.h> +#include <perf/cpumap.h> #include "cpumap.h" #include "mem2node.h" #include "tests.h"
@@ -19,7 +20,7 @@ static struct node {static unsigned long *get_bitmap (const char *str,int nbits) { -struct perf_cpu_map *map =cpu_map__new (str); +struct perf_cpu_map *map =perf_cpu_map__new (str);unsigned long *bm =NULL ;int i;
tools/perf/tests/mmap-basic.c +2 -1
@@ -3,6 +3,7 @@#include <inttypes.h> /* For the CLR_() macros */ #include <pthread.h> +#include <perf/cpumap.h> #include "evlist.h" #include "evsel.h"
@@ -46,7 +47,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unusereturn -1 ; } - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (cpus ==NULL ) {pr_debug ("cpu_map__new\n" ); goto out_free_threads;
tools/perf/tests/openat-syscall-all-cpus.c +1 -1
@@ -33,7 +33,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, intreturn -1 ; } - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (cpus ==NULL ) {pr_debug ("cpu_map__new\n" ); goto out_thread_map_delete;
tools/perf/tests/switch-tracking.c +3 -2
@@ -5,6 +5,7 @@#include <time.h> #include <stdlib.h> #include <linux/zalloc.h> +#include <perf/cpumap.h> #include "parse-events.h" #include "evlist.h"
@@ -341,9 +342,9 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_ goto out_err; } - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (!cpus) { -pr_debug ("cpu_map__new failed!\n" ); +pr_debug ("perf_cpu_map__new failed!\n" ); goto out_err; }
tools/perf/tests/topology.c +2 -1
@@ -2,6 +2,7 @@#include <string.h> #include <stdlib.h> #include <stdio.h> +#include <perf/cpumap.h> #include "tests.h" #include "util.h" #include "session.h"
@@ -126,7 +127,7 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybeif (session_write_header (path)) goto free_path; - map =cpu_map__new (NULL ); + map =perf_cpu_map__new (NULL );if (map ==NULL ) {pr_debug ("failed to get system cpumap\n" ); goto free_path;
tools/perf/util/cpumap.c +1 -180
193 lines not on this page · raw message
tools/perf/util/cpumap.h +0 -2
@@ -11,10 +11,8 @@#include "perf.h" #include "util/debug.h" -struct perf_cpu_map *cpu_map__new (const char *cpu_list);struct perf_cpu_map *cpu_map__empty_new (int nr);struct perf_cpu_map *cpu_map__new_data (struct cpu_map_data *data); -struct perf_cpu_map *cpu_map__read (FILE *file);size_t cpu_map__snprint (struct perf_cpu_map *map,char *buf,size_t size);size_t cpu_map__snprint_mask (struct perf_cpu_map *map,char *buf,size_t size);size_t cpu_map__fprintf (struct perf_cpu_map *map,FILE *fp);
tools/perf/util/cputopo.c +3 -2
@@ -5,6 +5,7 @@#include <stdlib.h> #include <api/fs/fs.h> #include <linux/zalloc.h> +#include <perf/cpumap.h> #include "cputopo.h" #include "cpumap.h"
@@ -182,7 +183,7 @@ struct cpu_topology *cpu_topology__new(void) ncpus =cpu__max_present_cpu ();/* build online CPU map */ - map =cpu_map__new (NULL ); + map =perf_cpu_map__new (NULL );if (map ==NULL ) {pr_debug ("failed to get system cpumap\n" );return NULL ;
@@ -312,7 +313,7 @@ struct numa_topology *numa_topology__new(void)if (c) *c ='\0' ; - node_map =cpu_map__new (buf); + node_map =perf_cpu_map__new (buf);if (!node_map) goto out;
tools/perf/util/evlist.c +3 -2
@@ -34,6 +34,7 @@#include <linux/err.h> #include <linux/zalloc.h> #include <perf/evlist.h> +#include <perf/cpumap.h> #ifdef LACKS_SIGQUEUE_PROTOTYPE int sigqueue (pid_t pid,int sig,const union sigval value);
@@ -1089,7 +1090,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)if (target__uses_dummy_map (target)) cpus =perf_cpu_map__dummy_new ();else - cpus =cpu_map__new (target->cpu_list); + cpus =perf_cpu_map__new (target->cpu_list);if (!cpus) goto out_delete_threads;
@@ -1372,7 +1373,7 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)* error, and we may not want to do that fallback to a * default cpu identity map :-\ */ - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (!cpus) goto out;
tools/perf/util/header.c +2 -1
@@ -20,6 +20,7 @@#include <linux/time64.h> #include <dirent.h> #include <bpf/libbpf.h> +#include <perf/cpumap.h> #include "evlist.h" #include "evsel.h"
@@ -2348,7 +2349,7 @@ static int process_numa_topology(struct feat_fd *ff, void *data __maybe_unused)if (!str) goto error; - n->map =cpu_map__new (str); + n->map =perf_cpu_map__new (str);if (!n->map) goto error;
tools/perf/util/parse-events.c +2 -1
@@ -24,6 +24,7 @@#include "bpf-loader.h" #include "debug.h" #include <api/fs/tracing_path.h> +#include <perf/cpumap.h> #include "parse-events-bison.h" #define YY_EXTRA_TYPE int#include "parse-events-flex.h"
@@ -323,7 +324,7 @@ __add_event(struct list_head *list, int *idx, {struct evsel *evsel;struct perf_cpu_map *cpus = pmu ? pmu->cpus : - cpu_list ?cpu_map__new (cpu_list) :NULL ; + cpu_list ?perf_cpu_map__new (cpu_list) :NULL ;event_attr_init (attr);
tools/perf/util/pmu.c +2 -1
@@ -15,6 +15,7 @@#include <api/fs/fs.h> #include <locale.h> #include <regex.h> +#include <perf/cpumap.h> #include "pmu.h" #include "parse-events.h" #include "cpumap.h"
@@ -581,7 +582,7 @@ static struct perf_cpu_map *__pmu_cpumask(const char *path)if (!file)return NULL ; - cpus =cpu_map__read (file); + cpus =perf_cpu_map__read (file);fclose (file);return cpus; }
tools/perf/util/python.c +2 -1
@@ -4,6 +4,7 @@#include <inttypes.h> #include <poll.h> #include <linux/err.h> +#include <perf/cpumap.h> #include "evlist.h" #include "callchain.h" #include "evsel.h"
@@ -549,7 +550,7 @@ static int pyrf_cpu_map__init(struct pyrf_cpu_map *pcpus, kwlist, &cpustr))return -1 ; - pcpus->cpus =cpu_map__new (cpustr); + pcpus->cpus =perf_cpu_map__new (cpustr);if (pcpus->cpus ==NULL )return -1 ;return 0 ;
tools/perf/util/record.c +4 -3
@@ -6,6 +6,7 @@#include <errno.h> #include <api/fs/fs.h> #include <subcmd/parse-options.h> +#include <perf/cpumap.h> #include "util.h" #include "cloexec.h"
@@ -63,7 +64,7 @@ static bool perf_probe_api(setup_probe_fn_t fn)struct perf_cpu_map *cpus;int cpu, ret, i =0 ; - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (!cpus)return false; cpu = cpus->map[0 ];
@@ -118,7 +119,7 @@ bool perf_can_record_cpu_wide(void)struct perf_cpu_map *cpus;int cpu, fd; - cpus =cpu_map__new (NULL ); + cpus =perf_cpu_map__new (NULL );if (!cpus)return false; cpu = cpus->map[0 ];
@@ -275,7 +276,7 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) evsel =perf_evlist__last (temp_evlist);if (!evlist ||cpu_map__empty (evlist->cpus)) { -struct perf_cpu_map *cpus =cpu_map__new (NULL ); +struct perf_cpu_map *cpus =perf_cpu_map__new (NULL ); cpu = cpus ? cpus->map[0 ] :0 ;perf_cpu_map__put (cpus);
tools/perf/util/session.c +2 -1
@@ -10,6 +10,7 @@#include <unistd.h> #include <sys/types.h> #include <sys/mman.h> +#include <perf/cpumap.h> #include "evlist.h" #include "evsel.h"
@@ -2289,7 +2290,7 @@ int perf_session__cpu_bitmap(struct perf_session *session, } } - map =cpu_map__new (cpu_list); + map =perf_cpu_map__new (cpu_list);if (map ==NULL ) {pr_err ("Invalid cpu_list\n" );return -1 ;
tools/perf/util/svghelper.c +2 -1
@@ -16,6 +16,7 @@#include <linux/bitmap.h> #include <linux/time64.h> #include <linux/zalloc.h> +#include <perf/cpumap.h> #include "perf.h" #include "svghelper.h"
@@ -731,7 +732,7 @@ static int str_to_bitmap(char *s, cpumask_t *b)struct perf_cpu_map *m;int c; - m =cpu_map__new (s); + m =perf_cpu_map__new (s);if (!m)return -1 ;
Jiri Olsa
reviewerPATCH 44/79 libperf: Move zalloc.o into libperf
In reply to Jiri OlsaWe need it in both perf and libperf, thus moving
it to libperf.
--- tools/perf/lib/Build | 5 +++++ tools/perf/util/Build | 5 ----- tools/perf/util/python-ext-sources | 1 - 3 files changed, 5 insertions(+), 6 deletions(-)
tools/perf/lib/Build +5 -0
@@ -3,3 +3,8 @@ libperf-y += cpumap.o libperf-y += threadmap.o libperf-y += evsel.o libperf-y += evlist.o +libperf-y += zalloc.o + +$(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)
tools/perf/util/Build +0 -5
@@ -26,7 +26,6 @@ perf-y += rbtree.o perf-y += libstring.o perf-y += bitmap.o perf-y += hweight.o -perf-y += zalloc.o perf-y += smt.o perf-y += strbuf.o perf-y += string.o
@@ -243,7 +242,3 @@ $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) - -$(OUTPUT)util/zalloc.o: ../lib/zalloc.c FORCE - $(call rule_mkdir) - $(call if_changed_dep,cc_o_c)
tools/perf/util/python-ext-sources +0 -1
@@ -18,7 +18,6 @@ util/namespaces.c ../lib/hweight.c ../lib/string.c ../lib/vsprintf.c -../lib/zalloc.c util/thread_map.c util/util.c util/xyarray.c
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Move zalloc.o into libperf
libperf: Move zalloc.o into libperf
Commit-ID: 93bce7e5bfcd570e9250c974b5c2c91d6b8332ef Gitweb: https://git.kernel.org/tip/93bce7e5bfcd570e9250c974b5c2c91d6b8332ef Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:31 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Move zalloc.o into libperf
We need it in both perf and libperf, thus moving it to libperf.
--- tools/perf/lib/Build | 5 +++++ tools/perf/util/Build | 5 ----- tools/perf/util/python-ext-sources | 1 - 3 files changed, 5 insertions(+), 6 deletions(-)
tools/perf/lib/Build +5 -0
@@ -3,3 +3,8 @@ libperf-y += cpumap.o libperf-y += threadmap.o libperf-y += evsel.o libperf-y += evlist.o +libperf-y += zalloc.o + +$(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)
tools/perf/util/Build +0 -5
@@ -26,7 +26,6 @@ perf-y += rbtree.o perf-y += libstring.o perf-y += bitmap.o perf-y += hweight.o -perf-y += zalloc.o perf-y += smt.o perf-y += strbuf.o perf-y += string.o
@@ -243,7 +242,3 @@ $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) - -$(OUTPUT)util/zalloc.o: ../lib/zalloc.c FORCE - $(call rule_mkdir) - $(call if_changed_dep,cc_o_c)
tools/perf/util/python-ext-sources +0 -1
@@ -18,7 +18,6 @@ util/namespaces.c ../lib/hweight.c ../lib/string.c ../lib/vsprintf.c -../lib/zalloc.c util/thread_map.c util/util.c util/xyarray.c
Jiri Olsa
reviewerPATCH 45/79 libperf: Add perf_evlist__new function
In reply to Jiri OlsaAdding perf_evlist__new function to create and init perf_evlist struct dynamicaly.
--- tools/perf/lib/evlist.c | 11 +++++++++++ tools/perf/lib/include/perf/evlist.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 13 insertions(+)
tools/perf/lib/evlist.c +11 -0
@@ -3,6 +3,7 @@#include <linux/list.h> #include <internal/evlist.h> #include <internal/evsel.h> +#include <linux/zalloc.h> void perf_evlist__init (struct perf_evlist *evlist) {
@@ -23,3 +24,13 @@ void perf_evlist__remove(struct perf_evlist *evlist,list_del_init (&evsel->node); evlist->nr_entries -=1 ; } + +struct perf_evlist *perf_evlist__new (void ) +{ +struct perf_evlist *evlist =zalloc (sizeof (*evlist)); + +if (evlist !=NULL ) +perf_evlist__init (evlist); + +return evlist; +}
tools/perf/lib/include/perf/evlist.h +1 -0
@@ -12,5 +12,6 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *evsel); LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); +LIBPERF_API struct perf_evlist *perf_evlist__new(void);#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -12,6 +12,7 @@ LIBPERF_0.0.1 { perf_thread_map__get; perf_thread_map__put; perf_evsel__init; + perf_evlist__new; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evlist__new() function
libperf: Add perf_evlist__new() function
Commit-ID: 634912d61ccc6bfeebb87716c276fbea20f63bdc Gitweb: https://git.kernel.org/tip/634912d61ccc6bfeebb87716c276fbea20f63bdc Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:32 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evlist__new() function
Add perf_evlist__new() function to create and init a perf_evlist struct dynamicaly.
--- tools/perf/lib/evlist.c | 11 +++++++++++ tools/perf/lib/include/perf/evlist.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 13 insertions(+)
tools/perf/lib/evlist.c +11 -0
@@ -3,6 +3,7 @@#include <linux/list.h> #include <internal/evlist.h> #include <internal/evsel.h> +#include <linux/zalloc.h> void perf_evlist__init (struct perf_evlist *evlist) {
@@ -23,3 +24,13 @@ void perf_evlist__remove(struct perf_evlist *evlist,list_del_init (&evsel->node); evlist->nr_entries -=1 ; } + +struct perf_evlist *perf_evlist__new (void ) +{ +struct perf_evlist *evlist =zalloc (sizeof (*evlist)); + +if (evlist !=NULL ) +perf_evlist__init (evlist); + +return evlist; +}
tools/perf/lib/include/perf/evlist.h +1 -0
@@ -12,5 +12,6 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, struct perf_evsel *evsel); LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); +LIBPERF_API struct perf_evlist *perf_evlist__new(void);#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -12,6 +12,7 @@ LIBPERF_0.0.1 { perf_thread_map__get; perf_thread_map__put; perf_evsel__init; + perf_evlist__new; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Jiri Olsa
reviewerPATCH 46/79 libperf: Add perf_evsel__new function
In reply to Jiri OlsaAdding perf_evsel__new function to create and init perf_evsel struct dynamicaly.
--- tools/perf/lib/evsel.c | 11 +++++++++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 13 insertions(+)
tools/perf/lib/evsel.c +11 -0
@@ -2,9 +2,20 @@#include <perf/evsel.h> #include <linux/list.h> #include <internal/evsel.h> +#include <linux/zalloc.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {INIT_LIST_HEAD (&evsel->node); evsel->attr = *attr; } + +struct perf_evsel *perf_evsel__new (struct perf_event_attr *attr) +{ +struct perf_evsel *evsel =zalloc (sizeof (*evsel)); + +if (evsel !=NULL ) +perf_evsel__init (evsel, attr); + +return evsel; +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -9,5 +9,6 @@ struct perf_evsel; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); +LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -11,6 +11,7 @@ LIBPERF_0.0.1 { perf_thread_map__comm; perf_thread_map__get; perf_thread_map__put; + perf_evsel__new; perf_evsel__init; perf_evlist__new; perf_evlist__init;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evsel__new() function
libperf: Add perf_evsel__new() function
Commit-ID: 63bd5dfa69658c459d08a6ee6bfebbd4a91cf24d Gitweb: https://git.kernel.org/tip/63bd5dfa69658c459d08a6ee6bfebbd4a91cf24d Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:33 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evsel__new() function
Add a perf_evsel__new() function to create and init a perf_evsel struct dynamicaly.
--- tools/perf/lib/evsel.c | 11 +++++++++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 13 insertions(+)
tools/perf/lib/evsel.c +11 -0
@@ -2,9 +2,20 @@#include <perf/evsel.h> #include <linux/list.h> #include <internal/evsel.h> +#include <linux/zalloc.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {INIT_LIST_HEAD (&evsel->node); evsel->attr = *attr; } + +struct perf_evsel *perf_evsel__new (struct perf_event_attr *attr) +{ +struct perf_evsel *evsel =zalloc (sizeof (*evsel)); + +if (evsel !=NULL ) +perf_evsel__init (evsel, attr); + +return evsel; +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -9,5 +9,6 @@ struct perf_event_attr; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); +LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -11,6 +11,7 @@ LIBPERF_0.0.1 { perf_thread_map__comm; perf_thread_map__get; perf_thread_map__put; + perf_evsel__new; perf_evsel__init; perf_evlist__new; perf_evlist__init;
Jiri Olsa
reviewerPATCH 47/79 libperf: Add perf_evlist__for_each_evsel macro
In reply to Jiri OlsaAdding perf_evlist__for_each_evsel macro to iterate perf_evsel objects in evlist.
Adding perf_evlist__next function to do that.
--- tools/perf/lib/evlist.c | 20 ++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 7 +++++++ tools/perf/lib/libperf.map | 1 + 3 files changed, 28 insertions(+)
tools/perf/lib/evlist.c +20 -0
@@ -34,3 +34,23 @@ struct perf_evlist *perf_evlist__new(void)return evlist; } + +struct perf_evsel * +perf_evlist__next (struct perf_evlist *evlist,struct perf_evsel *prev) +{ +struct perf_evsel *next; + +if (!prev) { + next =list_first_entry (&evlist->entries, + struct perf_evsel, + node); + }else { + next =list_next_entry (prev, node); + } + +/* Empty list is noticed here so don't need checking on entry. */ +if (&next->node == &evlist->entries) +return NULL ; + +return next; +}
tools/perf/lib/include/perf/evlist.h +7 -0
@@ -13,5 +13,12 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); LIBPERF_API struct perf_evlist *perf_evlist__new(void); +LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, +struct perf_evsel *evsel); + +#define perf_evlist__for_each_evsel (evlist, pos) \ + for ((pos) = perf_evlist__next((evlist), NULL); \ + (pos) != NULL; \ + (pos) = perf_evlist__next((evlist), (pos)))#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -17,6 +17,7 @@ LIBPERF_0.0.1 { perf_evlist__init; perf_evlist__add; perf_evlist__remove; + perf_evlist__next; local: *; };
Signature · 1 line
2.21.0
Re: [PATCH 47/79] libperf: Add perf_evlist__for_each_evsel macro
Em Sun, Jul 21, 2019 at 01:24:34PM +0200, Jiri Olsa escreveu:
Quoted 4 lines
Adding
perf_evlist__for_each_evselmacro to iterateperf_evselobjects in evlist.Adding
perf_evlist__nextfunction to do that.
Replaced the above line in the cset commit log with:
Introduce the perf_evlist__next() function to do that without exposing 'struct perf_evlist' internals.
Quoted 67 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/lib/evlist.c | 20 ++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 7 +++++++ tools/perf/lib/libperf.map | 1 + 3 files changed, 28 insertions(+)tools/perf/lib/evlist.c +20
-0@@ -34,3 +34,23 @@ struct perf_evlist *perf_evlist__new(void)return evlist; } + +struct perf_evsel * +perf_evlist__next (struct perf_evlist *evlist,struct perf_evsel *prev) +{ +struct perf_evsel *next; + +if (!prev) { + next =list_first_entry (&evlist->entries, + struct perf_evsel, + node); + }else { + next =list_next_entry (prev, node); + } + +/* Empty list is noticed here so don't need checking on entry. */ +if (&next->node == &evlist->entries) +return NULL ; + +return next; +}tools/perf/lib/include/perf/evlist.h +7
-0@@ -13,5 +13,12 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); LIBPERF_API struct perf_evlist *perf_evlist__new(void); +LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, +struct perf_evsel *evsel); + +#define perf_evlist__for_each_evsel (evlist, pos) \ + for ((pos) = perf_evlist__next((evlist), NULL); \ + (pos) != NULL; \ + (pos) = perf_evlist__next((evlist), (pos)))#endif /* __LIBPERF_EVLIST_H */ tools/perf/lib/libperf.map +1
-0@@ -17,6 +17,7 @@ LIBPERF_0.0.1 { perf_evlist__init; perf_evlist__add; perf_evlist__remove; + perf_evlist__next; local: *; };Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evlist__for_each_evsel() iterator
In reply to Jiri Olsalibperf: Add perf_evlist__for_each_evsel() iterator
Commit-ID: 651bf38ce10a65ef8efb901fc33187127c023e97 Gitweb: https://git.kernel.org/tip/651bf38ce10a65ef8efb901fc33187127c023e97 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:34 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evlist__for_each_evsel() iterator
Add a perf_evlist__for_each_evsel() macro to iterate perf_evsel objects in evlist.
Introduce the perf_evlist__next() function to do that without exposing 'struct perf_evlist' internals.
--- tools/perf/lib/evlist.c | 20 ++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 7 +++++++ tools/perf/lib/libperf.map | 1 + 3 files changed, 28 insertions(+)
tools/perf/lib/evlist.c +20 -0
@@ -34,3 +34,23 @@ struct perf_evlist *perf_evlist__new(void)return evlist; } + +struct perf_evsel * +perf_evlist__next (struct perf_evlist *evlist,struct perf_evsel *prev) +{ +struct perf_evsel *next; + +if (!prev) { + next =list_first_entry (&evlist->entries, + struct perf_evsel, + node); + }else { + next =list_next_entry (prev, node); + } + +/* Empty list is noticed here so don't need checking on entry. */ +if (&next->node == &evlist->entries) +return NULL ; + +return next; +}
tools/perf/lib/include/perf/evlist.h +7 -0
@@ -13,5 +13,12 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); LIBPERF_API struct perf_evlist *perf_evlist__new(void); +LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, +struct perf_evsel *evsel); + +#define perf_evlist__for_each_evsel (evlist, pos) \ + for ((pos) = perf_evlist__next((evlist), NULL); \ + (pos) != NULL; \ + (pos) = perf_evlist__next((evlist), (pos)))#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -17,6 +17,7 @@ LIBPERF_0.0.1 { perf_evlist__init; perf_evlist__add; perf_evlist__remove; + perf_evlist__next; local: *; };
Jiri Olsa
reviewerPATCH 48/79 libperf: Add perf_evlist__delete function
In reply to Jiri OlsaAdding perf_evlist__delete function to deleteperf_evlist struct.
--- tools/perf/lib/evlist.c | 6 ++++++ tools/perf/lib/include/perf/evlist.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 8 insertions(+)
tools/perf/lib/evlist.c +6 -0
@@ -4,6 +4,7 @@#include <internal/evlist.h> #include <internal/evsel.h> #include <linux/zalloc.h> +#include <stdlib.h> void perf_evlist__init (struct perf_evlist *evlist) {
@@ -54,3 +55,8 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev)return next; } + +void perf_evlist__delete (struct perf_evlist *evlist) +{ +free (evlist); +}
tools/perf/lib/include/perf/evlist.h +1 -0
@@ -13,6 +13,7 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); LIBPERF_API struct perf_evlist *perf_evlist__new(void); +LIBPERF_API void perf_evlist__delete(struct perf_evlist *evlist); LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist,struct perf_evsel *evsel);
tools/perf/lib/libperf.map +1 -0
@@ -14,6 +14,7 @@ LIBPERF_0.0.1 { perf_evsel__new; perf_evsel__init; perf_evlist__new; + perf_evlist__delete; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evlist__delete() function
libperf: Add perf_evlist__delete() function
Commit-ID: 57f0c3b6e13ae822ba02dd37563c8e6956a47141 Gitweb: https://git.kernel.org/tip/57f0c3b6e13ae822ba02dd37563c8e6956a47141 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:35 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evlist__delete() function
Add the perf_evlist__delete() function to delete a perf_evlist instance.
--- tools/perf/lib/evlist.c | 6 ++++++ tools/perf/lib/include/perf/evlist.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 8 insertions(+)
tools/perf/lib/evlist.c +6 -0
@@ -4,6 +4,7 @@#include <internal/evlist.h> #include <internal/evsel.h> #include <linux/zalloc.h> +#include <stdlib.h> void perf_evlist__init (struct perf_evlist *evlist) {
@@ -54,3 +55,8 @@ perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *prev)return next; } + +void perf_evlist__delete (struct perf_evlist *evlist) +{ +free (evlist); +}
tools/perf/lib/include/perf/evlist.h +1 -0
@@ -13,6 +13,7 @@ LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist, LIBPERF_API void perf_evlist__remove(struct perf_evlist *evlist,struct perf_evsel *evsel); LIBPERF_API struct perf_evlist *perf_evlist__new(void); +LIBPERF_API void perf_evlist__delete(struct perf_evlist *evlist); LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist,struct perf_evsel *evsel);
tools/perf/lib/libperf.map +1 -0
@@ -14,6 +14,7 @@ LIBPERF_0.0.1 { perf_evsel__new; perf_evsel__init; perf_evlist__new; + perf_evlist__delete; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Jiri Olsa
reviewerPATCH 49/79 libperf: Add perf_evsel__delete function
In reply to Jiri OlsaAdding perf_evsel__delete function to deleteperf_evsel struct.
--- tools/perf/lib/evsel.c | 6 ++++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 8 insertions(+)
tools/perf/lib/evsel.c +6 -0
@@ -3,6 +3,7 @@#include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> +#include <stdlib.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -19,3 +20,8 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)return evsel; } + +void perf_evsel__delete (struct perf_evsel *evsel) +{ +free (evsel); +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -10,5 +10,6 @@ struct perf_evsel; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); +LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -12,6 +12,7 @@ LIBPERF_0.0.1 { perf_thread_map__get; perf_thread_map__put; perf_evsel__new; + perf_evsel__delete; perf_evsel__init; perf_evlist__new; perf_evlist__delete;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evsel__delete() function
libperf: Add perf_evsel__delete() function
Commit-ID: b9358ee95ec65fe7e2c4dc12e4d3da4aeee0d8fc Gitweb: https://git.kernel.org/tip/b9358ee95ec65fe7e2c4dc12e4d3da4aeee0d8fc Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:36 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evsel__delete() function
Add the perf_evsel__delete() function to delete a perf_evsel instance.
--- tools/perf/lib/evsel.c | 6 ++++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 8 insertions(+)
tools/perf/lib/evsel.c +6 -0
@@ -3,6 +3,7 @@#include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> +#include <stdlib.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -19,3 +20,8 @@ struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr)return evsel; } + +void perf_evsel__delete (struct perf_evsel *evsel) +{ +free (evsel); +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -10,5 +10,6 @@ struct perf_event_attr; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); +LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -12,6 +12,7 @@ LIBPERF_0.0.1 { perf_thread_map__get; perf_thread_map__put; perf_evsel__new; + perf_evsel__delete; perf_evsel__init; perf_evlist__new; perf_evlist__delete;
Jiri Olsa
reviewerPATCH 50/79 libperf: Add cpus to struct perf_evsel
In reply to Jiri OlsaMoving cpus from evsel into perf_evsel struct.
--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/lib/include/internal/evsel.h | 7 +++++-- tools/perf/util/evlist.c | 14 +++++++------- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 3 +-- tools/perf/util/parse-events.c | 2 +- .../util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-display.c | 2 +- 9 files changed, 20 insertions(+), 18 deletions(-)
tools/perf/builtin-record.c +1 -1
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)evlist__for_each_entry (evlist, pos) { try_again: -if (evsel__open (pos, pos->cpus, pos->threads) <0 ) { +if (evsel__open (pos, pos->core.cpus, pos->threads) <0 ) {if (perf_evsel__fallback (pos, errno, msg,sizeof (msg))) {if (verbose >0 )ui__warning ("%s\n" , msg);
tools/perf/builtin-script.c +1 -1
@@ -1920,7 +1920,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp) counts =perf_counts (counter->counts, cpu, thread); printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", - counter->cpus->map[cpu], + counter->core.cpus->map[cpu], thread_map__pid(counter->threads, thread), counts->val, counts->ena,
tools/perf/lib/include/internal/evsel.h +5 -2
@@ -5,9 +5,12 @@#include <linux/types.h> #include <linux/perf_event.h> +struct perf_cpu_map ; +struct perf_evsel { -struct list_head node; -struct perf_event_attr attr; +struct list_head node; +struct perf_event_attr attr; +struct perf_cpu_map *cpus; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evlist.c +7 -7
@@ -160,11 +160,11 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* keep it, if there's no target cpu list defined. */ if (!evsel->own_cpus || evlist->has_user_cpus) { -perf_cpu_map__put (evsel->cpus); - evsel->cpus =perf_cpu_map__get (evlist->cpus); - }else if (evsel->cpus != evsel->own_cpus) { -perf_cpu_map__put (evsel->cpus); - evsel->cpus =perf_cpu_map__get (evsel->own_cpus); +perf_cpu_map__put (evsel->core.cpus); + evsel->core.cpus =perf_cpu_map__get (evlist->cpus); + }else if (evsel->core.cpus != evsel->own_cpus) { +perf_cpu_map__put (evsel->core.cpus); + evsel->core.cpus =perf_cpu_map__get (evsel->own_cpus); }perf_thread_map__put (evsel->threads);
@@ -786,7 +786,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,if (evsel->system_wide && thread)continue ; - cpu =cpu_map__idx (evsel->cpus, evlist_cpu); + cpu =cpu_map__idx (evsel->core.cpus, evlist_cpu);if (cpu ==-1 )continue ;
@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)perf_evlist__update_id_pos (evlist);evlist__for_each_entry (evlist, evsel) { - err =evsel__open (evsel, evsel->cpus, evsel->threads); + err =evsel__open (evsel, evsel->core.cpus, evsel->threads);if (err <0 ) goto out_err; }
tools/perf/util/evsel.c +2 -2
@@ -1325,7 +1325,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_evsel__free_id (evsel);perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp); -perf_cpu_map__put (evsel->cpus); +perf_cpu_map__put (evsel->core.cpus);perf_cpu_map__put (evsel->own_cpus);perf_thread_map__put (evsel->threads);zfree (&evsel->group_name);
@@ -3064,7 +3064,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)int perf_evsel__store_ids (struct evsel *evsel,struct evlist *evlist) { -struct perf_cpu_map *cpus = evsel->cpus; +struct perf_cpu_map *cpus = evsel->core.cpus;struct perf_thread_map *threads = evsel->threads;if (perf_evsel__alloc_id (evsel, cpus->nr, threads->nr))
tools/perf/util/evsel.h +1 -2
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;unsigned int sample_size;
@@ -198,7 +197,7 @@ struct record_opts;static inline struct perf_cpu_map *evsel__cpus (struct evsel *evsel) { -return evsel->cpus; +return evsel->core.cpus; }static inline int perf_evsel__nr_cpus (struct evsel *evsel)
tools/perf/util/parse-events.c +1 -1
@@ -333,7 +333,7 @@ __add_event(struct list_head *list, int *idx,return NULL ; (*idx)++; - evsel->cpus =perf_cpu_map__get (cpus); + evsel->core.cpus =perf_cpu_map__get (cpus); evsel->own_cpus =perf_cpu_map__get (cpus); evsel->system_wide = pmu ? pmu->is_uncore : false; evsel->auto_merge_stats = auto_merge_stats;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -1393,7 +1393,7 @@ static void python_process_stat(struct perf_stat_config *config, struct evsel *counter, u64 tstamp) {struct perf_thread_map *threads = counter->threads; -struct perf_cpu_map *cpus = counter->cpus; +struct perf_cpu_map *cpus = counter->core.cpus;int cpu, thread;if (config->aggr_mode ==AGGR_GLOBAL ) {
tools/perf/util/stat-display.c +1 -1
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config, {FILE *output = config->output;int nthreads =thread_map__nr (counter->threads); -int ncpus =cpu_map__nr (counter->cpus); +int ncpus =cpu_map__nr (counter->core.cpus);int thread, sorted_threads, id;struct perf_aggr_thread_value *buf;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add cpus to struct perf_evsel
libperf: Add cpus to struct perf_evsel
Commit-ID: d400bd3abf2cc68df2df32047d3533faf690f404 Gitweb: https://git.kernel.org/tip/d400bd3abf2cc68df2df32047d3533faf690f404 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:37 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add cpus to struct perf_evsel
Mov the 'cpus' field from tools/perf's evsel to libperf's perf_evsel.
--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/lib/include/internal/evsel.h | 7 +++++-- tools/perf/util/evlist.c | 14 +++++++------- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 3 +-- tools/perf/util/parse-events.c | 2 +- tools/perf/util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-display.c | 2 +- 9 files changed, 20 insertions(+), 18 deletions(-)
tools/perf/builtin-record.c +1 -1
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)evlist__for_each_entry (evlist, pos) { try_again: -if (evsel__open (pos, pos->cpus, pos->threads) <0 ) { +if (evsel__open (pos, pos->core.cpus, pos->threads) <0 ) {if (perf_evsel__fallback (pos, errno, msg,sizeof (msg))) {if (verbose >0 )ui__warning ("%s\n" , msg);
tools/perf/builtin-script.c +1 -1
@@ -1920,7 +1920,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp) counts =perf_counts (counter->counts, cpu, thread); printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", - counter->cpus->map[cpu], + counter->core.cpus->map[cpu], thread_map__pid(counter->threads, thread), counts->val, counts->ena,
tools/perf/lib/include/internal/evsel.h +5 -2
@@ -5,9 +5,12 @@#include <linux/types.h> #include <linux/perf_event.h> +struct perf_cpu_map ; +struct perf_evsel { -struct list_head node; -struct perf_event_attr attr; +struct list_head node; +struct perf_event_attr attr; +struct perf_cpu_map *cpus; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evlist.c +7 -7
@@ -160,11 +160,11 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* keep it, if there's no target cpu list defined. */ if (!evsel->own_cpus || evlist->has_user_cpus) { -perf_cpu_map__put (evsel->cpus); - evsel->cpus =perf_cpu_map__get (evlist->cpus); - }else if (evsel->cpus != evsel->own_cpus) { -perf_cpu_map__put (evsel->cpus); - evsel->cpus =perf_cpu_map__get (evsel->own_cpus); +perf_cpu_map__put (evsel->core.cpus); + evsel->core.cpus =perf_cpu_map__get (evlist->cpus); + }else if (evsel->core.cpus != evsel->own_cpus) { +perf_cpu_map__put (evsel->core.cpus); + evsel->core.cpus =perf_cpu_map__get (evsel->own_cpus); }perf_thread_map__put (evsel->threads);
@@ -786,7 +786,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx,if (evsel->system_wide && thread)continue ; - cpu =cpu_map__idx (evsel->cpus, evlist_cpu); + cpu =cpu_map__idx (evsel->core.cpus, evlist_cpu);if (cpu ==-1 )continue ;
@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)perf_evlist__update_id_pos (evlist);evlist__for_each_entry (evlist, evsel) { - err =evsel__open (evsel, evsel->cpus, evsel->threads); + err =evsel__open (evsel, evsel->core.cpus, evsel->threads);if (err <0 ) goto out_err; }
tools/perf/util/evsel.c +2 -2
@@ -1325,7 +1325,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_evsel__free_id (evsel);perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp); -perf_cpu_map__put (evsel->cpus); +perf_cpu_map__put (evsel->core.cpus);perf_cpu_map__put (evsel->own_cpus);perf_thread_map__put (evsel->threads);zfree (&evsel->group_name);
@@ -3064,7 +3064,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)int perf_evsel__store_ids (struct evsel *evsel,struct evlist *evlist) { -struct perf_cpu_map *cpus = evsel->cpus; +struct perf_cpu_map *cpus = evsel->core.cpus;struct perf_thread_map *threads = evsel->threads;if (perf_evsel__alloc_id (evsel, cpus->nr, threads->nr))
tools/perf/util/evsel.h +1 -2
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;unsigned int sample_size;
@@ -198,7 +197,7 @@ struct record_opts;static inline struct perf_cpu_map *evsel__cpus (struct evsel *evsel) { -return evsel->cpus; +return evsel->core.cpus; }static inline int perf_evsel__nr_cpus (struct evsel *evsel)
tools/perf/util/parse-events.c +1 -1
@@ -333,7 +333,7 @@ __add_event(struct list_head *list, int *idx,return NULL ; (*idx)++; - evsel->cpus =perf_cpu_map__get (cpus); + evsel->core.cpus =perf_cpu_map__get (cpus); evsel->own_cpus =perf_cpu_map__get (cpus); evsel->system_wide = pmu ? pmu->is_uncore : false; evsel->auto_merge_stats = auto_merge_stats;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -1393,7 +1393,7 @@ static void python_process_stat(struct perf_stat_config *config, struct evsel *counter, u64 tstamp) {struct perf_thread_map *threads = counter->threads; -struct perf_cpu_map *cpus = counter->cpus; +struct perf_cpu_map *cpus = counter->core.cpus;int cpu, thread;if (config->aggr_mode ==AGGR_GLOBAL ) {
tools/perf/util/stat-display.c +1 -1
@@ -745,7 +745,7 @@ static void print_aggr_thread(struct perf_stat_config *config, {FILE *output = config->output;int nthreads =thread_map__nr (counter->threads); -int ncpus =cpu_map__nr (counter->cpus); +int ncpus =cpu_map__nr (counter->core.cpus);int thread, sorted_threads, id;struct perf_aggr_thread_value *buf;
Jiri Olsa
reviewerPATCH 51/79 libperf: Add own_cpus to struct perf_evsel
In reply to Jiri OlsaMoving own_cpus from evsel into perf_evsel struct.
--- tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/tests/event_update.c | 4 ++-- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 1 - tools/perf/util/header.c | 10 +++++----- tools/perf/util/parse-events.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -11,6 +11,7 @@ struct perf_evsel {struct list_head node;struct perf_event_attr attr;struct perf_cpu_map *cpus; + struct perf_cpu_map *own_cpus; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/tests/event_update.c +2 -2
@@ -109,11 +109,11 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("failed to synthesize attr update name" , !perf_event__synthesize_event_update_name (&tmp.tool, evsel, process_event_name)); - evsel->own_cpus =perf_cpu_map__new ("1,2,3" ); + evsel->core.own_cpus =perf_cpu_map__new ("1,2,3" );TEST_ASSERT_VAL ("failed to synthesize attr update cpus" , !perf_event__synthesize_event_update_cpus (&tmp.tool, evsel, process_event_cpus)); -perf_cpu_map__put (evsel->own_cpus); +perf_cpu_map__put (evsel->core.own_cpus);return 0 ; }
tools/perf/util/evlist.c +3 -3
@@ -159,12 +159,12 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* We already have cpus for evsel (via PMU sysfs) so * keep it, if there's no target cpu list defined. */ -if (!evsel->own_cpus || evlist->has_user_cpus) { +if (!evsel->core.own_cpus || evlist->has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evlist->cpus); - }else if (evsel->core.cpus != evsel->own_cpus) { + }else if (evsel->core.cpus != evsel->core.own_cpus) {perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evsel->own_cpus); + evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus); }perf_thread_map__put (evsel->threads);
tools/perf/util/evsel.c +2 -2
@@ -1125,7 +1125,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, attr->exclude_user =1 ; } -if (evsel->own_cpus || evsel->unit) +if (evsel->core.own_cpus || evsel->unit) evsel->core.attr.read_format |=PERF_FORMAT_ID ;/*
@@ -1326,7 +1326,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp);perf_cpu_map__put (evsel->core.cpus); -perf_cpu_map__put (evsel->own_cpus); +perf_cpu_map__put (evsel->core.own_cpus);perf_thread_map__put (evsel->threads);zfree (&evsel->group_name);zfree (&evsel->name);
tools/perf/util/evsel.h +0 -1
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;unsigned int sample_size;int id_pos;
tools/perf/util/header.c +5 -5
@@ -3854,10 +3854,10 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool,int max, err;u16 type; -if (!evsel->own_cpus) +if (!evsel->core.own_cpus)return 0 ; - ev =cpu_map_data__alloc (evsel->own_cpus, &size, &type, &max); + ev =cpu_map_data__alloc (evsel->core.own_cpus, &size, &type, &max);if (!ev)return -ENOMEM ;
@@ -3867,7 +3867,7 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool, ev->id = evsel->id[0 ];cpu_map_data__synthesize ((struct cpu_map_data *) ev->data, - evsel->own_cpus, + evsel->core.own_cpus, type, max); err =process (tool, (union perf_event *) ev,NULL ,NULL );
@@ -3978,7 +3978,7 @@ int perf_event__synthesize_extra_attr(struct perf_tool *tool, } } -if (counter->own_cpus) { +if (counter->core.own_cpus) { err =perf_event__synthesize_event_update_cpus (tool, counter, process);if (err <0 ) {pr_err ("Couldn't synthesize evsel cpus.\n" );
@@ -4075,7 +4075,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, map =cpu_map__new_data (&ev_cpus->cpus);if (map) - evsel->own_cpus = map; + evsel->core.own_cpus = map;else pr_err ("failed to get event_update cpus\n" );default :
tools/perf/util/parse-events.c +1 -1
@@ -334,7 +334,7 @@ __add_event(struct list_head *list, int *idx, (*idx)++; evsel->core.cpus =perf_cpu_map__get (cpus); - evsel->own_cpus =perf_cpu_map__get (cpus); + evsel->core.own_cpus =perf_cpu_map__get (cpus); evsel->system_wide = pmu ? pmu->is_uncore : false; evsel->auto_merge_stats = auto_merge_stats;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add own_cpus to struct perf_evsel
libperf: Add own_cpus to struct perf_evsel
Commit-ID: fe1f61b37ffada9fc7ec2c9d4ca5376b5a797dbc Gitweb: https://git.kernel.org/tip/fe1f61b37ffada9fc7ec2c9d4ca5376b5a797dbc Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:38 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add own_cpus to struct perf_evsel
Move own_cpus from tools/perf's evsel to libbpf's perf_evsel.
--- tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/tests/event_update.c | 4 ++-- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 1 - tools/perf/util/header.c | 10 +++++----- tools/perf/util/parse-events.c | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-)
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -11,6 +11,7 @@ struct perf_evsel {struct list_head node;struct perf_event_attr attr;struct perf_cpu_map *cpus; + struct perf_cpu_map *own_cpus; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/tests/event_update.c +2 -2
@@ -109,11 +109,11 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unuTEST_ASSERT_VAL ("failed to synthesize attr update name" , !perf_event__synthesize_event_update_name (&tmp.tool, evsel, process_event_name)); - evsel->own_cpus =perf_cpu_map__new ("1,2,3" ); + evsel->core.own_cpus =perf_cpu_map__new ("1,2,3" );TEST_ASSERT_VAL ("failed to synthesize attr update cpus" , !perf_event__synthesize_event_update_cpus (&tmp.tool, evsel, process_event_cpus)); -perf_cpu_map__put (evsel->own_cpus); +perf_cpu_map__put (evsel->core.own_cpus);return 0 ; }
tools/perf/util/evlist.c +3 -3
@@ -159,12 +159,12 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* We already have cpus for evsel (via PMU sysfs) so * keep it, if there's no target cpu list defined. */ -if (!evsel->own_cpus || evlist->has_user_cpus) { +if (!evsel->core.own_cpus || evlist->has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evlist->cpus); - }else if (evsel->core.cpus != evsel->own_cpus) { + }else if (evsel->core.cpus != evsel->core.own_cpus) {perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evsel->own_cpus); + evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus); }perf_thread_map__put (evsel->threads);
tools/perf/util/evsel.c +2 -2
@@ -1125,7 +1125,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts, attr->exclude_user =1 ; } -if (evsel->own_cpus || evsel->unit) +if (evsel->core.own_cpus || evsel->unit) evsel->core.attr.read_format |=PERF_FORMAT_ID ;/*
@@ -1326,7 +1326,7 @@ void perf_evsel__exit(struct evsel *evsel)perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp);perf_cpu_map__put (evsel->core.cpus); -perf_cpu_map__put (evsel->own_cpus); +perf_cpu_map__put (evsel->core.own_cpus);perf_thread_map__put (evsel->threads);zfree (&evsel->group_name);zfree (&evsel->name);
tools/perf/util/evsel.h +0 -1
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;unsigned int sample_size;int id_pos;
tools/perf/util/header.c +5 -5
@@ -3861,10 +3861,10 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool,int max, err;u16 type; -if (!evsel->own_cpus) +if (!evsel->core.own_cpus)return 0 ; - ev =cpu_map_data__alloc (evsel->own_cpus, &size, &type, &max); + ev =cpu_map_data__alloc (evsel->core.own_cpus, &size, &type, &max);if (!ev)return -ENOMEM ;
@@ -3874,7 +3874,7 @@ perf_event__synthesize_event_update_cpus(struct perf_tool *tool, ev->id = evsel->id[0 ];cpu_map_data__synthesize ((struct cpu_map_data *) ev->data, - evsel->own_cpus, + evsel->core.own_cpus, type, max); err =process (tool, (union perf_event *) ev,NULL ,NULL );
@@ -3985,7 +3985,7 @@ int perf_event__synthesize_extra_attr(struct perf_tool *tool, } } -if (counter->own_cpus) { +if (counter->core.own_cpus) { err =perf_event__synthesize_event_update_cpus (tool, counter, process);if (err <0 ) {pr_err ("Couldn't synthesize evsel cpus.\n" );
@@ -4082,7 +4082,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused, map =cpu_map__new_data (&ev_cpus->cpus);if (map) - evsel->own_cpus = map; + evsel->core.own_cpus = map;else pr_err ("failed to get event_update cpus\n" );default :
tools/perf/util/parse-events.c +1 -1
@@ -334,7 +334,7 @@ __add_event(struct list_head *list, int *idx, (*idx)++; evsel->core.cpus =perf_cpu_map__get (cpus); - evsel->own_cpus =perf_cpu_map__get (cpus); + evsel->core.own_cpus =perf_cpu_map__get (cpus); evsel->system_wide = pmu ? pmu->is_uncore : false; evsel->auto_merge_stats = auto_merge_stats;
Jiri Olsa
reviewerPATCH 52/79 libperf: Add threads to struct perf_evsel
In reply to Jiri OlsaMoving threads from evsel into perf_evsel struct.
--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-script.c | 4 ++-- tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 1 - tools/perf/util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-display.c | 6 +++--- tools/perf/util/stat.c | 6 +++--- 9 files changed, 17 insertions(+), 16 deletions(-)
tools/perf/builtin-record.c +1 -1
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)evlist__for_each_entry (evlist, pos) { try_again: -if (evsel__open (pos, pos->core.cpus, pos->threads) <0 ) { +if (evsel__open (pos, pos->core.cpus, pos->core.threads) <0 ) {if (perf_evsel__fallback (pos, errno, msg,sizeof (msg))) {if (verbose >0 )ui__warning ("%s\n" , msg);
tools/perf/builtin-script.c +2 -2
@@ -1899,7 +1899,7 @@ static struct scripting_ops *scripting_ops;static void __process_stat (struct evsel *counter,u64 tstamp) { -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =perf_evsel__nr_cpus (counter);int cpu, thread;static int header_printed;
@@ -1921,7 +1921,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp) printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", counter->core.cpus->map[cpu], - thread_map__pid(counter->threads, thread), + thread_map__pid(counter->core.threads, thread), counts->val, counts->ena, counts->run,
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -6,12 +6,14 @@#include <linux/perf_event.h> struct perf_cpu_map ; +struct perf_thread_map ;struct perf_evsel {struct list_head node;struct perf_event_attr attr;struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus; +struct perf_thread_map *threads; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evlist.c +3 -3
@@ -167,8 +167,8 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus); } -perf_thread_map__put (evsel->threads); - evsel->threads =perf_thread_map__get (evlist->threads); +perf_thread_map__put (evsel->core.threads); + evsel->core.threads =perf_thread_map__get (evlist->threads); }static void perf_evlist__propagate_maps (struct evlist *evlist)
@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)perf_evlist__update_id_pos (evlist);evlist__for_each_entry (evlist, evsel) { - err =evsel__open (evsel, evsel->core.cpus, evsel->threads); + err =evsel__open (evsel, evsel->core.cpus, evsel->core.threads);if (err <0 ) goto out_err; }
tools/perf/util/evsel.c +2 -2
@@ -1327,7 +1327,7 @@ void perf_evsel__exit(struct evsel *evsel)cgroup__put (evsel->cgrp);perf_cpu_map__put (evsel->core.cpus);perf_cpu_map__put (evsel->core.own_cpus); -perf_thread_map__put (evsel->threads); +perf_thread_map__put (evsel->core.threads);zfree (&evsel->group_name);zfree (&evsel->name); perf_evsel__object.fini (evsel);
@@ -3065,7 +3065,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)int perf_evsel__store_ids (struct evsel *evsel,struct evlist *evlist) {struct perf_cpu_map *cpus = evsel->core.cpus; -struct perf_thread_map *threads = evsel->threads; +struct perf_thread_map *threads = evsel->core.threads;if (perf_evsel__alloc_id (evsel, cpus->nr, threads->nr))return -ENOMEM ;
tools/perf/util/evsel.h +0 -1
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_thread_map *threads;unsigned int sample_size;int id_pos;int is_pos;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -1392,7 +1392,7 @@ process_stat(struct evsel *counter, int cpu, int thread, u64 tstamp,static void python_process_stat (struct perf_stat_config *config,struct evsel *counter,u64 tstamp) { -struct perf_thread_map *threads = counter->threads; +struct perf_thread_map *threads = counter->core.threads;struct perf_cpu_map *cpus = counter->core.cpus;int cpu, thread;
tools/perf/util/stat-display.c +3 -3
@@ -116,9 +116,9 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_THREAD :fprintf (config->output,"%*s-%*d%s" , config->csv_output ?0 :16 , -perf_thread_map__comm (evsel->threads, id), +perf_thread_map__comm (evsel->core.threads, id), config->csv_output ?0 :-8 , -thread_map__pid (evsel->threads, id), +thread_map__pid (evsel->core.threads, id), config->csv_sep);break ;case AGGR_GLOBAL :
@@ -744,7 +744,7 @@ static void print_aggr_thread(struct perf_stat_config *config, struct evsel *counter, char *prefix) { FILE *output = config->output; -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =cpu_map__nr (counter->core.cpus);int thread, sorted_threads, id;struct perf_aggr_thread_value *buf;
tools/perf/util/stat.c +3 -3
@@ -158,7 +158,7 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)static int perf_evsel__alloc_stats (struct evsel *evsel,bool alloc_raw) {int ncpus =perf_evsel__nr_cpus (evsel); -int nthreads =thread_map__nr (evsel->threads); +int nthreads =thread_map__nr (evsel->core.threads); if (perf_evsel__alloc_stat_priv(evsel) < 0 || perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
@@ -308,7 +308,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,static int process_counter_maps (struct perf_stat_config *config,struct evsel *counter) { -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =perf_evsel__nr_cpus (counter);int cpu, thread;
@@ -485,7 +485,7 @@ int create_perf_stat_counter(struct evsel *evsel,if (target__has_cpu (target) && !target__has_per_thread (target))return perf_evsel__open_per_cpu (evsel,evsel__cpus (evsel)); -return perf_evsel__open_per_thread (evsel, evsel->threads); +return perf_evsel__open_per_thread (evsel, evsel->core.threads); } int perf_stat_synthesize_config(struct perf_stat_config *config,
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add threads to struct perf_evsel
libperf: Add threads to struct perf_evsel
Commit-ID: af663bd01beaff8d9514199fcc1b239902a77de5 Gitweb: https://git.kernel.org/tip/af663bd01beaff8d9514199fcc1b239902a77de5 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:39 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add threads to struct perf_evsel
Move 'threads' from tools/perf's evsel to libperf's perf_evsel struct.
--- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-script.c | 4 ++-- tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 4 ++-- tools/perf/util/evsel.h | 1 - tools/perf/util/scripting-engines/trace-event-python.c | 2 +- tools/perf/util/stat-display.c | 6 +++--- tools/perf/util/stat.c | 6 +++--- 9 files changed, 17 insertions(+), 16 deletions(-)
tools/perf/builtin-record.c +1 -1
@@ -739,7 +739,7 @@ static int record__open(struct record *rec)evlist__for_each_entry (evlist, pos) { try_again: -if (evsel__open (pos, pos->core.cpus, pos->threads) <0 ) { +if (evsel__open (pos, pos->core.cpus, pos->core.threads) <0 ) {if (perf_evsel__fallback (pos, errno, msg,sizeof (msg))) {if (verbose >0 )ui__warning ("%s\n" , msg);
tools/perf/builtin-script.c +2 -2
@@ -1899,7 +1899,7 @@ static struct scripting_ops *scripting_ops;static void __process_stat (struct evsel *counter,u64 tstamp) { -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =perf_evsel__nr_cpus (counter);int cpu, thread;static int header_printed;
@@ -1921,7 +1921,7 @@ static void __process_stat(struct evsel *counter, u64 tstamp) printf("%3d %8d %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %15" PRIu64 " %s\n", counter->core.cpus->map[cpu], - thread_map__pid(counter->threads, thread), + thread_map__pid(counter->core.threads, thread), counts->val, counts->ena, counts->run,
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -6,12 +6,14 @@#include <linux/perf_event.h> struct perf_cpu_map ; +struct perf_thread_map ;struct perf_evsel {struct list_head node;struct perf_event_attr attr;struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus; +struct perf_thread_map *threads; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evlist.c +3 -3
@@ -167,8 +167,8 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus); } -perf_thread_map__put (evsel->threads); - evsel->threads =perf_thread_map__get (evlist->threads); +perf_thread_map__put (evsel->core.threads); + evsel->core.threads =perf_thread_map__get (evlist->threads); }static void perf_evlist__propagate_maps (struct evlist *evlist)
@@ -1407,7 +1407,7 @@ int evlist__open(struct evlist *evlist)perf_evlist__update_id_pos (evlist);evlist__for_each_entry (evlist, evsel) { - err =evsel__open (evsel, evsel->core.cpus, evsel->threads); + err =evsel__open (evsel, evsel->core.cpus, evsel->core.threads);if (err <0 ) goto out_err; }
tools/perf/util/evsel.c +2 -2
@@ -1327,7 +1327,7 @@ void perf_evsel__exit(struct evsel *evsel)cgroup__put (evsel->cgrp);perf_cpu_map__put (evsel->core.cpus);perf_cpu_map__put (evsel->core.own_cpus); -perf_thread_map__put (evsel->threads); +perf_thread_map__put (evsel->core.threads);zfree (&evsel->group_name);zfree (&evsel->name); perf_evsel__object.fini (evsel);
@@ -3065,7 +3065,7 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist)int perf_evsel__store_ids (struct evsel *evsel,struct evlist *evlist) {struct perf_cpu_map *cpus = evsel->core.cpus; -struct perf_thread_map *threads = evsel->threads; +struct perf_thread_map *threads = evsel->core.threads;if (perf_evsel__alloc_id (evsel, cpus->nr, threads->nr))return -ENOMEM ;
tools/perf/util/evsel.h +0 -1
@@ -123,7 +123,6 @@ struct evsel {u64 db_id;struct cgroup *cgrp;void *handler; -struct perf_thread_map *threads;unsigned int sample_size;int id_pos;int is_pos;
tools/perf/util/scripting-engines/trace-event-python.c +1 -1
@@ -1392,7 +1392,7 @@ process_stat(struct evsel *counter, int cpu, int thread, u64 tstamp,static void python_process_stat (struct perf_stat_config *config,struct evsel *counter,u64 tstamp) { -struct perf_thread_map *threads = counter->threads; +struct perf_thread_map *threads = counter->core.threads;struct perf_cpu_map *cpus = counter->core.cpus;int cpu, thread;
tools/perf/util/stat-display.c +3 -3
@@ -116,9 +116,9 @@ static void aggr_printout(struct perf_stat_config *config,case AGGR_THREAD :fprintf (config->output,"%*s-%*d%s" , config->csv_output ?0 :16 , -perf_thread_map__comm (evsel->threads, id), +perf_thread_map__comm (evsel->core.threads, id), config->csv_output ?0 :-8 , -thread_map__pid (evsel->threads, id), +thread_map__pid (evsel->core.threads, id), config->csv_sep);break ;case AGGR_GLOBAL :
@@ -744,7 +744,7 @@ static void print_aggr_thread(struct perf_stat_config *config, struct evsel *counter, char *prefix) { FILE *output = config->output; -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =cpu_map__nr (counter->core.cpus);int thread, sorted_threads, id;struct perf_aggr_thread_value *buf;
tools/perf/util/stat.c +3 -3
@@ -158,7 +158,7 @@ static void perf_evsel__free_prev_raw_counts(struct evsel *evsel)static int perf_evsel__alloc_stats (struct evsel *evsel,bool alloc_raw) {int ncpus =perf_evsel__nr_cpus (evsel); -int nthreads =thread_map__nr (evsel->threads); +int nthreads =thread_map__nr (evsel->core.threads); if (perf_evsel__alloc_stat_priv(evsel) < 0 || perf_evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
@@ -308,7 +308,7 @@ process_counter_values(struct perf_stat_config *config, struct evsel *evsel,static int process_counter_maps (struct perf_stat_config *config,struct evsel *counter) { -int nthreads =thread_map__nr (counter->threads); +int nthreads =thread_map__nr (counter->core.threads);int ncpus =perf_evsel__nr_cpus (counter);int cpu, thread;
@@ -485,7 +485,7 @@ int create_perf_stat_counter(struct evsel *evsel,if (target__has_cpu (target) && !target__has_per_thread (target))return perf_evsel__open_per_cpu (evsel,evsel__cpus (evsel)); -return perf_evsel__open_per_thread (evsel, evsel->threads); +return perf_evsel__open_per_thread (evsel, evsel->core.threads); } int perf_stat_synthesize_config(struct perf_stat_config *config,
Jiri Olsa
reviewerPATCH 53/79 libperf: Add has_user_cpus to struct perf_evlist
In reply to Jiri OlsaMoving has_user_cpus from evlist into perf_evlist struct.
--- tools/perf/lib/include/internal/evlist.h | 1 + tools/perf/util/evlist.c | 4 ++-- tools/perf/util/evlist.h | 1 - 3 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/lib/include/internal/evlist.h +1 -0
@@ -5,6 +5,7 @@struct perf_evlist {struct list_head entries;int nr_entries; +bool has_user_cpus; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/util/evlist.c +2 -2
@@ -159,7 +159,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* We already have cpus for evsel (via PMU sysfs) so * keep it, if there's no target cpu list defined. */ -if (!evsel->core.own_cpus || evlist->has_user_cpus) { +if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evlist->cpus); }else if (evsel->core.cpus != evsel->core.own_cpus) {
@@ -1095,7 +1095,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)if (!cpus) goto out_delete_threads; - evlist->has_user_cpus = !!target->cpu_list; + evlist->core.has_user_cpus = !!target->cpu_list;perf_evlist__set_maps (evlist, cpus, threads);
tools/perf/util/evlist.h +0 -1
@@ -31,7 +31,6 @@ struct evlist {int nr_groups;int nr_mmaps;bool enabled; -bool has_user_cpus;size_t mmap_len;int id_pos;int is_pos;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add has_user_cpus to struct perf_evlist
libperf: Add has_user_cpus to struct perf_evlist
Commit-ID: ec903f264f0184a0aba62b42d7717c61f1893450 Gitweb: https://git.kernel.org/tip/ec903f264f0184a0aba62b42d7717c61f1893450 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:40 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add has_user_cpus to struct perf_evlist
Move has_user_cpus from tools/perf's evlist to libbperf's perf_evlist struct.
--- tools/perf/lib/include/internal/evlist.h | 1 + tools/perf/util/evlist.c | 4 ++-- tools/perf/util/evlist.h | 1 - 3 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/lib/include/internal/evlist.h +1 -0
@@ -5,6 +5,7 @@struct perf_evlist {struct list_head entries;int nr_entries; +bool has_user_cpus; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/util/evlist.c +2 -2
@@ -159,7 +159,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,* We already have cpus for evsel (via PMU sysfs) so * keep it, if there's no target cpu list defined. */ -if (!evsel->core.own_cpus || evlist->has_user_cpus) { +if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evlist->cpus); }else if (evsel->core.cpus != evsel->core.own_cpus) {
@@ -1095,7 +1095,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)if (!cpus) goto out_delete_threads; - evlist->has_user_cpus = !!target->cpu_list; + evlist->core.has_user_cpus = !!target->cpu_list;perf_evlist__set_maps (evlist, cpus, threads);
tools/perf/util/evlist.h +0 -1
@@ -31,7 +31,6 @@ struct evlist {int nr_groups;int nr_mmaps;bool enabled; -bool has_user_cpus;size_t mmap_len;int id_pos;int is_pos;
Jiri Olsa
reviewerPATCH 54/79 libperf: Add cpus to struct perf_evlist
In reply to Jiri OlsaMoving cpus from evlist into perf_evlist struct.
--- tools/perf/arch/x86/util/intel-bts.c | 2 +- tools/perf/arch/x86/util/intel-pt.c | 4 +-- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 16 +++++------ tools/perf/builtin-top.c | 2 +- tools/perf/lib/include/internal/evlist.h | 9 ++++-- tools/perf/util/auxtrace.c | 2 +- tools/perf/util/evlist.c | 36 ++++++++++++------------ tools/perf/util/evlist.h | 1 - tools/perf/util/record.c | 6 ++-- tools/perf/util/stat-display.c | 6 ++-- tools/perf/util/stat.c | 2 +- tools/perf/util/top.c | 6 ++-- 14 files changed, 49 insertions(+), 47 deletions(-)
tools/perf/arch/x86/util/intel-bts.c +1 -1
@@ -106,7 +106,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, container_of(itr, struct intel_bts_recording, itr);struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu;struct evsel *evsel, *intel_bts_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ; btsr->evlist = evlist;
tools/perf/arch/x86/util/intel-pt.c +2 -2
@@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,ui__warning ("Intel Processor Trace: TSC not available\n" ); } - per_cpu_mmaps = !cpu_map__empty (session->evlist->cpus); + per_cpu_mmaps = !cpu_map__empty (session->evlist->core.cpus); auxtrace_info->type =PERF_AUXTRACE_INTEL_PT ; auxtrace_info->priv[INTEL_PT_PMU_TYPE ] = intel_pt_pmu->type;
@@ -557,7 +557,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;bool have_timing_info, need_immediate = false;struct evsel *evsel, *intel_pt_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ;u64 tsc_bit;int err;
tools/perf/builtin-ftrace.c +1 -1
@@ -192,7 +192,7 @@ static int set_tracing_cpumask(struct perf_cpu_map *cpumap)static int set_tracing_cpu (struct perf_ftrace *ftrace) { -struct perf_cpu_map *cpumap = ftrace->evlist->cpus; +struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus;if (!target__has_cpu (&ftrace->target))return 0 ;
tools/perf/builtin-record.c +1 -1
@@ -1283,7 +1283,7 @@ static int record__synthesize(struct record *rec, bool tail)return err; } - err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->cpus, + err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->core.cpus, process_synthesized_event,NULL );if (err <0 ) {pr_err ("Couldn't synthesize cpu map.\n" );
tools/perf/builtin-stat.c +8 -8
@@ -884,21 +884,21 @@ static int perf_stat_init_aggr_mode(void)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (cpu_map__build_socket_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_socket_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_cached;break ;case AGGR_DIE : -if (cpu_map__build_die_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_die_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_cached;break ;case AGGR_CORE : -if (cpu_map__build_core_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }
@@ -906,7 +906,7 @@ static int perf_stat_init_aggr_mode(void)break ;case AGGR_NONE :if (term_percore_set ()) { -if (cpu_map__build_core_map (evsel_list->cpus, +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ;
@@ -926,7 +926,7 @@ static int perf_stat_init_aggr_mode(void)* taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - nr =cpu_map__get_max (evsel_list->cpus); + nr =cpu_map__get_max (evsel_list->core.cpus); stat_config.cpus_aggr_map =cpu_map__empty_new (nr +1 );return stat_config.cpus_aggr_map ?0 : -ENOMEM ; }
@@ -1057,21 +1057,21 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (perf_env__build_socket_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_socket_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_file;break ;case AGGR_DIE : -if (perf_env__build_die_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_die_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_file;break ;case AGGR_CORE : -if (perf_env__build_core_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_core_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }
tools/perf/builtin-top.c +1 -1
@@ -989,7 +989,7 @@ static int perf_top__start_counters(struct perf_top *top)evlist__for_each_entry (evlist, counter) { try_again: -if (evsel__open (counter, top->evlist->cpus, +if (evsel__open (counter, top->evlist->core.cpus, top->evlist->threads) <0 ) {/*
tools/perf/lib/include/internal/evlist.h +6 -3
@@ -2,10 +2,13 @@#ifndef __LIBPERF_INTERNAL_EVLIST_H#define __LIBPERF_INTERNAL_EVLIST_H +struct perf_cpu_map ; +struct perf_evlist { -struct list_head entries; -int nr_entries; -bool has_user_cpus; +struct list_head entries; +int nr_entries; +bool has_user_cpus; +struct perf_cpu_map *cpus; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/util/auxtrace.c +1 -1
@@ -130,7 +130,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, mp->idx = idx;if (per_cpu) { - mp->cpu = evlist->cpus->map[idx]; + mp->cpu = evlist->core.cpus->map[idx];if (evlist->threads) mp->tid =thread_map__pid (evlist->threads,0 );else
tools/perf/util/evlist.c +18 -18
@@ -143,9 +143,9 @@ void evlist__delete(struct evlist *evlist)perf_evlist__munmap (evlist);evlist__close (evlist); -perf_cpu_map__put (evlist->cpus); +perf_cpu_map__put (evlist->core.cpus);perf_thread_map__put (evlist->threads); - evlist->cpus =NULL ; + evlist->core.cpus =NULL ; evlist->threads =NULL ;perf_evlist__purge (evlist);perf_evlist__exit (evlist);
@@ -161,7 +161,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,*/ if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evlist->cpus); + evsel->core.cpus =perf_cpu_map__get (evlist->core.cpus); }else if (evsel->core.cpus != evsel->core.own_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus);
@@ -398,7 +398,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int thread) {int cpu; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);if (!evsel->fd)return -EINVAL ;
@@ -414,7 +414,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,int perf_evlist__enable_event_idx (struct evlist *evlist,struct evsel *evsel,int idx) { -bool per_cpu_mmaps = !cpu_map__empty (evlist->cpus); +bool per_cpu_mmaps = !cpu_map__empty (evlist->core.cpus);if (per_cpu_mmaps)return perf_evlist__enable_event_cpu (evlist, evsel, idx);
@@ -424,7 +424,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,int perf_evlist__alloc_pollfd (struct evlist *evlist) { -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);int nfds =0 ;struct evsel *evsel;
@@ -552,8 +552,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, {struct perf_sample_id *sid =SID (evsel, cpu, thread); sid->idx = idx; -if (evlist->cpus && cpu >=0 ) - sid->cpu = evlist->cpus->map[cpu]; +if (evlist->core.cpus && cpu >=0 ) + sid->cpu = evlist->core.cpus->map[cpu];else sid->cpu =-1 ;if (!evsel->system_wide && evlist->threads && thread >=0 )
@@ -720,8 +720,8 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,int i;struct perf_mmap *map; - evlist->nr_mmaps =cpu_map__nr (evlist->cpus); -if (cpu_map__empty (evlist->cpus)) + evlist->nr_mmaps =cpu_map__nr (evlist->core.cpus); +if (cpu_map__empty (evlist->core.cpus)) evlist->nr_mmaps =thread_map__nr (evlist->threads); map =zalloc (evlist->nr_mmaps *sizeof (struct perf_mmap ));if (!map)
@@ -759,7 +759,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx, {struct evsel *evsel;int revent; -int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +int evlist_cpu =cpu_map__cpu (evlist->core.cpus, cpu_idx);evlist__for_each_entry (evlist, evsel) {struct perf_mmap *maps = evlist->mmap;
@@ -835,7 +835,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, struct mmap_params *mp) {int cpu, thread; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);pr_debug2 ("perf event ring buffer mmapped per cpu\n" );
@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, int comp_level) {struct evsel *evsel; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;const struct perf_thread_map *threads = evlist->threads;/* * Delay setting mp.prot: set it before calling perf_mmap__mmap.
@@ -1116,9 +1116,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus,* original reference count of 1. If that is not the case it is up to * the caller to increase the reference count. */ -if (cpus != evlist->cpus) { -perf_cpu_map__put (evlist->cpus); - evlist->cpus =perf_cpu_map__get (cpus); +if (cpus != evlist->core.cpus) { +perf_cpu_map__put (evlist->core.cpus); + evlist->core.cpus =perf_cpu_map__get (cpus); }if (threads != evlist->threads) {
@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)* Default: one fd per CPU, all threads, aka systemwide * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL */ -if (evlist->threads ==NULL && evlist->cpus ==NULL ) { +if (evlist->threads ==NULL && evlist->core.cpus ==NULL ) { err =perf_evlist__create_syswide_maps (evlist);if (err <0 ) goto out_err;
@@ -1920,7 +1920,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, goto out_delete_evlist;evlist__for_each_entry (evlist, counter) { -if (evsel__open (counter, evlist->cpus, +if (evsel__open (counter, evlist->core.cpus, evlist->threads) <0 ) goto out_delete_evlist; }
tools/perf/util/evlist.h +0 -1
@@ -44,7 +44,6 @@ struct evlist {struct perf_mmap *mmap;struct perf_mmap *overwrite_mmap;struct perf_thread_map *threads; -struct perf_cpu_map *cpus;struct evsel *selected;struct events_stats stats;struct perf_env *env;
tools/perf/util/record.c +3 -3
@@ -148,7 +148,7 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,if (opts->group)perf_evlist__set_leader (evlist); -if (evlist->cpus->map[0 ] <0 ) +if (evlist->core.cpus->map[0 ] <0 ) opts->no_inherit = true; use_comm_exec =perf_can_comm_exec ();
@@ -275,13 +275,13 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) evsel =perf_evlist__last (temp_evlist); -if (!evlist ||cpu_map__empty (evlist->cpus)) { +if (!evlist ||cpu_map__empty (evlist->core.cpus)) {struct perf_cpu_map *cpus =perf_cpu_map__new (NULL ); cpu = cpus ? cpus->map[0 ] :0 ;perf_cpu_map__put (cpus); }else { - cpu = evlist->cpus->map[0 ]; + cpu = evlist->core.cpus->map[0 ]; }while (1 ) {
tools/perf/util/stat-display.c +3 -3
@@ -327,7 +327,7 @@ static int first_shadow_cpu(struct perf_stat_config *config,for (i =0 ; i <perf_evsel__nr_cpus (evsel); i++) {int cpu2 =evsel__cpus (evsel)->map[i]; -if (config->aggr_get_id (config, evlist->cpus, cpu2) == id) +if (config->aggr_get_id (config, evlist->core.cpus, cpu2) == id)return cpu2; }return 0 ;
@@ -500,7 +500,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,evlist__for_each_entry (evlist, counter) { val =0 ;for (cpu =0 ; cpu <perf_evsel__nr_cpus (counter); cpu++) { - s2 = config->aggr_get_id (config, evlist->cpus, cpu); + s2 = config->aggr_get_id (config, evlist->core.cpus, cpu);if (s2 != id)continue ; val +=perf_counts (counter->counts, cpu,0 )->val;
@@ -868,7 +868,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,u64 ena, run, val;double uval; - nrcpus = evlist->cpus->nr; + nrcpus = evlist->core.cpus->nr;for (cpu =0 ; cpu < nrcpus; cpu++) {bool first = true;
tools/perf/util/stat.c +1 -1
@@ -514,7 +514,7 @@ int perf_stat_synthesize_config(struct perf_stat_config *config,return err; } - err =perf_event__synthesize_cpu_map (tool, evlist->cpus, + err =perf_event__synthesize_cpu_map (tool, evlist->core.cpus, process,NULL );if (err <0 ) {pr_err ("Couldn't synthesize thread map.\n" );
tools/perf/util/top.c +3 -3
@@ -95,15 +95,15 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)if (target->cpu_list) ret +=SNPRINTF (bf + ret, size - ret,", CPU%s: %s)" , - top->evlist->cpus->nr >1 ?"s" :"" , + top->evlist->core.cpus->nr >1 ?"s" :"" , target->cpu_list);else {if (target->tid) ret +=SNPRINTF (bf + ret, size - ret,")" );else ret +=SNPRINTF (bf + ret, size - ret,", %d CPU%s)" , - top->evlist->cpus->nr, - top->evlist->cpus->nr >1 ?"s" :"" ); + top->evlist->core.cpus->nr, + top->evlist->core.cpus->nr >1 ?"s" :"" ); }perf_top__reset_sample_counters (top);
Signature · 1 line
2.21.0
Re: [PATCH 54/79] libperf: Add cpus to struct perf_evlist
Em Sun, Jul 21, 2019 at 01:24:41PM +0200, Jiri Olsa escreveu:
Quoted 1 line
Moving cpus from evlist into
perf_evliststruct.
Fixed up this one:
tools/perf/arch/arm/util/cs-etm.c
Quoted 441 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/arch/x86/util/intel-bts.c | 2 +- tools/perf/arch/x86/util/intel-pt.c | 4 +-- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 16 +++++------ tools/perf/builtin-top.c | 2 +- tools/perf/lib/include/internal/evlist.h | 9 ++++-- tools/perf/util/auxtrace.c | 2 +- tools/perf/util/evlist.c | 36 ++++++++++++------------ tools/perf/util/evlist.h | 1 - tools/perf/util/record.c | 6 ++-- tools/perf/util/stat-display.c | 6 ++-- tools/perf/util/stat.c | 2 +- tools/perf/util/top.c | 6 ++-- 14 files changed, 49 insertions(+), 47 deletions(-)tools/perf/arch/x86/util/intel-bts.c +1
-1@@ -106,7 +106,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, container_of(itr, struct intel_bts_recording, itr);struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu;struct evsel *evsel, *intel_bts_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ; btsr->evlist = evlist;tools/perf/arch/x86/util/intel-pt.c +2
-2@@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,ui__warning ("Intel Processor Trace: TSC not available\n" ); } - per_cpu_mmaps = !cpu_map__empty (session->evlist->cpus); + per_cpu_mmaps = !cpu_map__empty (session->evlist->core.cpus); auxtrace_info->type =PERF_AUXTRACE_INTEL_PT ; auxtrace_info->priv[INTEL_PT_PMU_TYPE ] = intel_pt_pmu->type;@@ -557,7 +557,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;bool have_timing_info, need_immediate = false;struct evsel *evsel, *intel_pt_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ;u64 tsc_bit;int err;tools/perf/builtin-ftrace.c +1
-1@@ -192,7 +192,7 @@ static int set_tracing_cpumask(struct perf_cpu_map *cpumap)static int set_tracing_cpu (struct perf_ftrace *ftrace) { -struct perf_cpu_map *cpumap = ftrace->evlist->cpus; +struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus;if (!target__has_cpu (&ftrace->target))return 0 ;tools/perf/builtin-record.c +1
-1@@ -1283,7 +1283,7 @@ static int record__synthesize(struct record *rec, bool tail)return err; } - err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->cpus, + err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->core.cpus, process_synthesized_event,NULL );if (err <0 ) {pr_err ("Couldn't synthesize cpu map.\n" );tools/perf/builtin-stat.c +8
-8@@ -884,21 +884,21 @@ static int perf_stat_init_aggr_mode(void)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (cpu_map__build_socket_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_socket_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_cached;break ;case AGGR_DIE : -if (cpu_map__build_die_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_die_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_cached;break ;case AGGR_CORE : -if (cpu_map__build_core_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }@@ -906,7 +906,7 @@ static int perf_stat_init_aggr_mode(void)break ;case AGGR_NONE :if (term_percore_set ()) { -if (cpu_map__build_core_map (evsel_list->cpus, +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ;@@ -926,7 +926,7 @@ static int perf_stat_init_aggr_mode(void)* taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - nr =cpu_map__get_max (evsel_list->cpus); + nr =cpu_map__get_max (evsel_list->core.cpus); stat_config.cpus_aggr_map =cpu_map__empty_new (nr +1 );return stat_config.cpus_aggr_map ?0 : -ENOMEM ; }@@ -1057,21 +1057,21 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (perf_env__build_socket_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_socket_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_file;break ;case AGGR_DIE : -if (perf_env__build_die_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_die_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_file;break ;case AGGR_CORE : -if (perf_env__build_core_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_core_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }tools/perf/builtin-top.c +1
-1@@ -989,7 +989,7 @@ static int perf_top__start_counters(struct perf_top *top)evlist__for_each_entry (evlist, counter) { try_again: -if (evsel__open (counter, top->evlist->cpus, +if (evsel__open (counter, top->evlist->core.cpus, top->evlist->threads) <0 ) {/* tools/perf/lib/include/internal/evlist.h +6
-3@@ -2,10 +2,13 @@#ifndef __LIBPERF_INTERNAL_EVLIST_H#define __LIBPERF_INTERNAL_EVLIST_H +struct perf_cpu_map ; +struct perf_evlist { -struct list_head entries; -int nr_entries; -bool has_user_cpus; +struct list_head entries; +int nr_entries; +bool has_user_cpus; +struct perf_cpu_map *cpus; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */ tools/perf/util/auxtrace.c +1
-1@@ -130,7 +130,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, mp->idx = idx;if (per_cpu) { - mp->cpu = evlist->cpus->map[idx]; + mp->cpu = evlist->core.cpus->map[idx];if (evlist->threads) mp->tid =thread_map__pid (evlist->threads,0 );else tools/perf/util/evlist.c +18
-18@@ -143,9 +143,9 @@ void evlist__delete(struct evlist *evlist)perf_evlist__munmap (evlist);evlist__close (evlist); -perf_cpu_map__put (evlist->cpus); +perf_cpu_map__put (evlist->core.cpus);perf_thread_map__put (evlist->threads); - evlist->cpus =NULL ; + evlist->core.cpus =NULL ; evlist->threads =NULL ;perf_evlist__purge (evlist);perf_evlist__exit (evlist);@@ -161,7 +161,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,*/ if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evlist->cpus); + evsel->core.cpus =perf_cpu_map__get (evlist->core.cpus); }else if (evsel->core.cpus != evsel->core.own_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus);@@ -398,7 +398,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int thread) {int cpu; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);if (!evsel->fd)return -EINVAL ;@@ -414,7 +414,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,int perf_evlist__enable_event_idx (struct evlist *evlist,struct evsel *evsel,int idx) { -bool per_cpu_mmaps = !cpu_map__empty (evlist->cpus); +bool per_cpu_mmaps = !cpu_map__empty (evlist->core.cpus);if (per_cpu_mmaps)return perf_evlist__enable_event_cpu (evlist, evsel, idx);@@ -424,7 +424,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,int perf_evlist__alloc_pollfd (struct evlist *evlist) { -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);int nfds =0 ;struct evsel *evsel;@@ -552,8 +552,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, {struct perf_sample_id *sid =SID (evsel, cpu, thread); sid->idx = idx; -if (evlist->cpus && cpu >=0 ) - sid->cpu = evlist->cpus->map[cpu]; +if (evlist->core.cpus && cpu >=0 ) + sid->cpu = evlist->core.cpus->map[cpu];else sid->cpu =-1 ;if (!evsel->system_wide && evlist->threads && thread >=0 )@@ -720,8 +720,8 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,int i;struct perf_mmap *map; - evlist->nr_mmaps =cpu_map__nr (evlist->cpus); -if (cpu_map__empty (evlist->cpus)) + evlist->nr_mmaps =cpu_map__nr (evlist->core.cpus); +if (cpu_map__empty (evlist->core.cpus)) evlist->nr_mmaps =thread_map__nr (evlist->threads); map =zalloc (evlist->nr_mmaps *sizeof (struct perf_mmap ));if (!map)@@ -759,7 +759,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx, {struct evsel *evsel;int revent; -int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +int evlist_cpu =cpu_map__cpu (evlist->core.cpus, cpu_idx);evlist__for_each_entry (evlist, evsel) {struct perf_mmap *maps = evlist->mmap;@@ -835,7 +835,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, struct mmap_params *mp) {int cpu, thread; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);pr_debug2 ("perf event ring buffer mmapped per cpu\n" );@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, int comp_level) {struct evsel *evsel; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;const struct perf_thread_map *threads = evlist->threads;/* * Delay setting mp.prot: set it before calling perf_mmap__mmap. @@ -1116,9 +1116,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus,* original reference count of 1. If that is not the case it is up to * the caller to increase the reference count. */ -if (cpus != evlist->cpus) { -perf_cpu_map__put (evlist->cpus); - evlist->cpus =perf_cpu_map__get (cpus); +if (cpus != evlist->core.cpus) { +perf_cpu_map__put (evlist->core.cpus); + evlist->core.cpus =perf_cpu_map__get (cpus); }if (threads != evlist->threads) {@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)* Default: one fd per CPU, all threads, aka systemwide * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL */ -if (evlist->threads ==NULL && evlist->cpus ==NULL ) { +if (evlist->threads ==NULL && evlist->core.cpus ==NULL ) { err =perf_evlist__create_syswide_maps (evlist);if (err <0 ) goto out_err;@@ -1920,7 +1920,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, goto out_delete_evlist;evlist__for_each_entry (evlist, counter) { -if (evsel__open (counter, evlist->cpus, +if (evsel__open (counter, evlist->core.cpus, evlist->threads) <0 ) goto out_delete_evlist; }tools/perf/util/evlist.h +0
-1@@ -44,7 +44,6 @@ struct evlist {struct perf_mmap *mmap;struct perf_mmap *overwrite_mmap;struct perf_thread_map *threads; -struct perf_cpu_map *cpus;struct evsel *selected;struct events_stats stats;struct perf_env *env;tools/perf/util/record.c +3
-3@@ -148,7 +148,7 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,if (opts->group)perf_evlist__set_leader (evlist); -if (evlist->cpus->map[0 ] <0 ) +if (evlist->core.cpus->map[0 ] <0 ) opts->no_inherit = true; use_comm_exec =perf_can_comm_exec ();@@ -275,13 +275,13 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) evsel =perf_evlist__last (temp_evlist); -if (!evlist ||cpu_map__empty (evlist->cpus)) { +if (!evlist ||cpu_map__empty (evlist->core.cpus)) {struct perf_cpu_map *cpus =perf_cpu_map__new (NULL ); cpu = cpus ? cpus->map[0 ] :0 ;perf_cpu_map__put (cpus); }else { - cpu = evlist->cpus->map[0 ]; + cpu = evlist->core.cpus->map[0 ]; }while (1 ) {tools/perf/util/stat-display.c +3
-3@@ -327,7 +327,7 @@ static int first_shadow_cpu(struct perf_stat_config *config,for (i =0 ; i <perf_evsel__nr_cpus (evsel); i++) {int cpu2 =evsel__cpus (evsel)->map[i]; -if (config->aggr_get_id (config, evlist->cpus, cpu2) == id) +if (config->aggr_get_id (config, evlist->core.cpus, cpu2) == id)return cpu2; }return 0 ;@@ -500,7 +500,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,evlist__for_each_entry (evlist, counter) { val =0 ;for (cpu =0 ; cpu <perf_evsel__nr_cpus (counter); cpu++) { - s2 = config->aggr_get_id (config, evlist->cpus, cpu); + s2 = config->aggr_get_id (config, evlist->core.cpus, cpu);if (s2 != id)continue ; val +=perf_counts (counter->counts, cpu,0 )->val;@@ -868,7 +868,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,u64 ena, run, val;double uval; - nrcpus = evlist->cpus->nr; + nrcpus = evlist->core.cpus->nr;for (cpu =0 ; cpu < nrcpus; cpu++) {bool first = true;tools/perf/util/stat.c +1
-1@@ -514,7 +514,7 @@ int perf_stat_synthesize_config(struct perf_stat_config *config,return err; } - err =perf_event__synthesize_cpu_map (tool, evlist->cpus, + err =perf_event__synthesize_cpu_map (tool, evlist->core.cpus, process,NULL );if (err <0 ) {pr_err ("Couldn't synthesize thread map.\n" );tools/perf/util/top.c +3
-3@@ -95,15 +95,15 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)if (target->cpu_list) ret +=SNPRINTF (bf + ret, size - ret,", CPU%s: %s)" , - top->evlist->cpus->nr >1 ?"s" :"" , + top->evlist->core.cpus->nr >1 ?"s" :"" , target->cpu_list);else {if (target->tid) ret +=SNPRINTF (bf + ret, size - ret,")" );else ret +=SNPRINTF (bf + ret, size - ret,", %d CPU%s)" , - top->evlist->cpus->nr, - top->evlist->cpus->nr >1 ?"s" :"" ); + top->evlist->core.cpus->nr, + top->evlist->core.cpus->nr >1 ?"s" :"" ); }perf_top__reset_sample_counters (top);Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add cpus to struct perf_evlist
In reply to Jiri Olsalibperf: Add cpus to struct perf_evlist
Commit-ID: f72f901d90b00aaf2a6c1335b41311687b3f2dec Gitweb: https://git.kernel.org/tip/f72f901d90b00aaf2a6c1335b41311687b3f2dec Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:41 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add cpus to struct perf_evlist
Move cpus from tools/perf's evlist to libperf's perf_evlist struct.
Committer notes:
Fixed up this one:
tools/perf/arch/arm/util/cs-etm.c
--- tools/perf/arch/arm/util/cs-etm.c | 8 +++---- tools/perf/arch/x86/util/intel-bts.c | 2 +- tools/perf/arch/x86/util/intel-pt.c | 4 ++-- tools/perf/builtin-ftrace.c | 2 +- tools/perf/builtin-record.c | 2 +- tools/perf/builtin-stat.c | 16 +++++++------- tools/perf/builtin-top.c | 2 +- tools/perf/lib/include/internal/evlist.h | 9 +++++--- tools/perf/util/auxtrace.c | 2 +- tools/perf/util/evlist.c | 36 ++++++++++++++++---------------- tools/perf/util/evlist.h | 1 - tools/perf/util/record.c | 6 +++--- tools/perf/util/stat-display.c | 6 +++--- tools/perf/util/stat.c | 2 +- tools/perf/util/top.c | 6 +++--- 15 files changed, 53 insertions(+), 51 deletions(-)
tools/perf/arch/arm/util/cs-etm.c +4 -4
@@ -155,7 +155,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr, struct evsel *evsel, u32 option) { int i, err = -EINVAL; -struct perf_cpu_map *event_cpus = evsel->evlist->cpus; +struct perf_cpu_map *event_cpus = evsel->evlist->core.cpus;struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );/* Set option of each CPU we have */
@@ -253,7 +253,7 @@ static int cs_etm_recording_options(struct auxtrace_record *itr, container_of(itr, struct cs_etm_recording, itr);struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu;struct evsel *evsel, *cs_etm_evsel =NULL ; -struct perf_cpu_map *cpus = evlist->cpus; +struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged = (geteuid () ==0 ||perf_event_paranoid () <0 );int err =0 ;
@@ -489,7 +489,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused, {int i;int etmv3 =0 , etmv4 =0 ; -struct perf_cpu_map *event_cpus = evlist->cpus; +struct perf_cpu_map *event_cpus = evlist->core.cpus;struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );/* cpu map is not empty, we have specific CPUs to work with */
@@ -636,7 +636,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,u32 offset;u64 nr_cpu, type;struct perf_cpu_map *cpu_map; -struct perf_cpu_map *event_cpus = session->evlist->cpus; +struct perf_cpu_map *event_cpus = session->evlist->core.cpus;struct perf_cpu_map *online_cpus =perf_cpu_map__new (NULL );struct cs_etm_recording *ptr = container_of(itr, struct cs_etm_recording, itr);
tools/perf/arch/x86/util/intel-bts.c +1 -1
@@ -106,7 +106,7 @@ static int intel_bts_recording_options(struct auxtrace_record *itr, container_of(itr, struct intel_bts_recording, itr);struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu;struct evsel *evsel, *intel_bts_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ; btsr->evlist = evlist;
tools/perf/arch/x86/util/intel-pt.c +2 -2
@@ -365,7 +365,7 @@ static int intel_pt_info_fill(struct auxtrace_record *itr,ui__warning ("Intel Processor Trace: TSC not available\n" ); } - per_cpu_mmaps = !cpu_map__empty (session->evlist->cpus); + per_cpu_mmaps = !cpu_map__empty (session->evlist->core.cpus); auxtrace_info->type =PERF_AUXTRACE_INTEL_PT ; auxtrace_info->priv[INTEL_PT_PMU_TYPE ] = intel_pt_pmu->type;
@@ -557,7 +557,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;bool have_timing_info, need_immediate = false;struct evsel *evsel, *intel_pt_evsel =NULL ; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;bool privileged =geteuid () ==0 ||perf_event_paranoid () <0 ;u64 tsc_bit;int err;
tools/perf/builtin-ftrace.c +1 -1
@@ -192,7 +192,7 @@ static int set_tracing_cpumask(struct perf_cpu_map *cpumap)static int set_tracing_cpu (struct perf_ftrace *ftrace) { -struct perf_cpu_map *cpumap = ftrace->evlist->cpus; +struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus;if (!target__has_cpu (&ftrace->target))return 0 ;
tools/perf/builtin-record.c +1 -1
@@ -1283,7 +1283,7 @@ static int record__synthesize(struct record *rec, bool tail)return err; } - err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->cpus, + err =perf_event__synthesize_cpu_map (&rec->tool, rec->evlist->core.cpus, process_synthesized_event,NULL );if (err <0 ) {pr_err ("Couldn't synthesize cpu map.\n" );
tools/perf/builtin-stat.c +8 -8
@@ -884,21 +884,21 @@ static int perf_stat_init_aggr_mode(void)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (cpu_map__build_socket_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_socket_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_cached;break ;case AGGR_DIE : -if (cpu_map__build_die_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_die_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_cached;break ;case AGGR_CORE : -if (cpu_map__build_core_map (evsel_list->cpus, &stat_config.aggr_map)) { +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }
@@ -906,7 +906,7 @@ static int perf_stat_init_aggr_mode(void)break ;case AGGR_NONE :if (term_percore_set ()) { -if (cpu_map__build_core_map (evsel_list->cpus, +if (cpu_map__build_core_map (evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ;
@@ -926,7 +926,7 @@ static int perf_stat_init_aggr_mode(void)* taking the highest cpu number to be the size of * the aggregation translate cpumap. */ - nr =cpu_map__get_max (evsel_list->cpus); + nr =cpu_map__get_max (evsel_list->core.cpus); stat_config.cpus_aggr_map =cpu_map__empty_new (nr +1 );return stat_config.cpus_aggr_map ?0 : -ENOMEM ; }
@@ -1057,21 +1057,21 @@ static int perf_stat_init_aggr_mode_file(struct perf_stat *st)switch (stat_config.aggr_mode) {case AGGR_SOCKET : -if (perf_env__build_socket_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_socket_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build socket map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_socket_file;break ;case AGGR_DIE : -if (perf_env__build_die_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_die_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build die map" );return -1 ; } stat_config.aggr_get_id = perf_stat__get_die_file;break ;case AGGR_CORE : -if (perf_env__build_core_map (env, evsel_list->cpus, &stat_config.aggr_map)) { +if (perf_env__build_core_map (env, evsel_list->core.cpus, &stat_config.aggr_map)) {perror ("cannot build core map" );return -1 ; }
tools/perf/builtin-top.c +1 -1
@@ -989,7 +989,7 @@ static int perf_top__start_counters(struct perf_top *top)evlist__for_each_entry (evlist, counter) { try_again: -if (evsel__open (counter, top->evlist->cpus, +if (evsel__open (counter, top->evlist->core.cpus, top->evlist->threads) <0 ) {/*
tools/perf/lib/include/internal/evlist.h +6 -3
@@ -2,10 +2,13 @@#ifndef __LIBPERF_INTERNAL_EVLIST_H#define __LIBPERF_INTERNAL_EVLIST_H +struct perf_cpu_map ; +struct perf_evlist { -struct list_head entries; -int nr_entries; -bool has_user_cpus; +struct list_head entries; +int nr_entries; +bool has_user_cpus; +struct perf_cpu_map *cpus; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/util/auxtrace.c +1 -1
@@ -130,7 +130,7 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp, mp->idx = idx;if (per_cpu) { - mp->cpu = evlist->cpus->map[idx]; + mp->cpu = evlist->core.cpus->map[idx];if (evlist->threads) mp->tid =thread_map__pid (evlist->threads,0 );else
tools/perf/util/evlist.c +18 -18
@@ -143,9 +143,9 @@ void evlist__delete(struct evlist *evlist)perf_evlist__munmap (evlist);evlist__close (evlist); -perf_cpu_map__put (evlist->cpus); +perf_cpu_map__put (evlist->core.cpus);perf_thread_map__put (evlist->threads); - evlist->cpus =NULL ; + evlist->core.cpus =NULL ; evlist->threads =NULL ;perf_evlist__purge (evlist);perf_evlist__exit (evlist);
@@ -161,7 +161,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist,*/ if (!evsel->core.own_cpus || evlist->core.has_user_cpus) {perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evlist->cpus); + evsel->core.cpus =perf_cpu_map__get (evlist->core.cpus); }else if (evsel->core.cpus != evsel->core.own_cpus) {perf_cpu_map__put (evsel->core.cpus); evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus);
@@ -398,7 +398,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist, int thread) {int cpu; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);if (!evsel->fd)return -EINVAL ;
@@ -414,7 +414,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,int perf_evlist__enable_event_idx (struct evlist *evlist,struct evsel *evsel,int idx) { -bool per_cpu_mmaps = !cpu_map__empty (evlist->cpus); +bool per_cpu_mmaps = !cpu_map__empty (evlist->core.cpus);if (per_cpu_mmaps)return perf_evlist__enable_event_cpu (evlist, evsel, idx);
@@ -424,7 +424,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,int perf_evlist__alloc_pollfd (struct evlist *evlist) { -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);int nfds =0 ;struct evsel *evsel;
@@ -552,8 +552,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, {struct perf_sample_id *sid =SID (evsel, cpu, thread); sid->idx = idx; -if (evlist->cpus && cpu >=0 ) - sid->cpu = evlist->cpus->map[cpu]; +if (evlist->core.cpus && cpu >=0 ) + sid->cpu = evlist->core.cpus->map[cpu];else sid->cpu =-1 ;if (!evsel->system_wide && evlist->threads && thread >=0 )
@@ -720,8 +720,8 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist,int i;struct perf_mmap *map; - evlist->nr_mmaps =cpu_map__nr (evlist->cpus); -if (cpu_map__empty (evlist->cpus)) + evlist->nr_mmaps =cpu_map__nr (evlist->core.cpus); +if (cpu_map__empty (evlist->core.cpus)) evlist->nr_mmaps =thread_map__nr (evlist->threads); map =zalloc (evlist->nr_mmaps *sizeof (struct perf_mmap ));if (!map)
@@ -759,7 +759,7 @@ static int perf_evlist__mmap_per_evsel(struct evlist *evlist, int idx, {struct evsel *evsel;int revent; -int evlist_cpu =cpu_map__cpu (evlist->cpus, cpu_idx); +int evlist_cpu =cpu_map__cpu (evlist->core.cpus, cpu_idx);evlist__for_each_entry (evlist, evsel) {struct perf_mmap *maps = evlist->mmap;
@@ -835,7 +835,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, struct mmap_params *mp) {int cpu, thread; -int nr_cpus =cpu_map__nr (evlist->cpus); +int nr_cpus =cpu_map__nr (evlist->core.cpus);int nr_threads =thread_map__nr (evlist->threads);pr_debug2 ("perf event ring buffer mmapped per cpu\n" );
@@ -1014,7 +1014,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, int comp_level) {struct evsel *evsel; -const struct perf_cpu_map *cpus = evlist->cpus; +const struct perf_cpu_map *cpus = evlist->core.cpus;const struct perf_thread_map *threads = evlist->threads;/* * Delay setting mp.prot: set it before calling perf_mmap__mmap.
@@ -1116,9 +1116,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus,* original reference count of 1. If that is not the case it is up to * the caller to increase the reference count. */ -if (cpus != evlist->cpus) { -perf_cpu_map__put (evlist->cpus); - evlist->cpus =perf_cpu_map__get (cpus); +if (cpus != evlist->core.cpus) { +perf_cpu_map__put (evlist->core.cpus); + evlist->core.cpus =perf_cpu_map__get (cpus); }if (threads != evlist->threads) {
@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)* Default: one fd per CPU, all threads, aka systemwide * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL */ -if (evlist->threads ==NULL && evlist->cpus ==NULL ) { +if (evlist->threads ==NULL && evlist->core.cpus ==NULL ) { err =perf_evlist__create_syswide_maps (evlist);if (err <0 ) goto out_err;
@@ -1920,7 +1920,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist, goto out_delete_evlist;evlist__for_each_entry (evlist, counter) { -if (evsel__open (counter, evlist->cpus, +if (evsel__open (counter, evlist->core.cpus, evlist->threads) <0 ) goto out_delete_evlist; }
tools/perf/util/evlist.h +0 -1
@@ -44,7 +44,6 @@ struct evlist {struct perf_mmap *mmap;struct perf_mmap *overwrite_mmap;struct perf_thread_map *threads; -struct perf_cpu_map *cpus;struct evsel *selected;struct events_stats stats;struct perf_env *env;
tools/perf/util/record.c +3 -3
@@ -148,7 +148,7 @@ void perf_evlist__config(struct evlist *evlist, struct record_opts *opts,if (opts->group)perf_evlist__set_leader (evlist); -if (evlist->cpus->map[0 ] <0 ) +if (evlist->core.cpus->map[0 ] <0 ) opts->no_inherit = true; use_comm_exec =perf_can_comm_exec ();
@@ -275,13 +275,13 @@ bool perf_evlist__can_select_event(struct evlist *evlist, const char *str) evsel =perf_evlist__last (temp_evlist); -if (!evlist ||cpu_map__empty (evlist->cpus)) { +if (!evlist ||cpu_map__empty (evlist->core.cpus)) {struct perf_cpu_map *cpus =perf_cpu_map__new (NULL ); cpu = cpus ? cpus->map[0 ] :0 ;perf_cpu_map__put (cpus); }else { - cpu = evlist->cpus->map[0 ]; + cpu = evlist->core.cpus->map[0 ]; }while (1 ) {
tools/perf/util/stat-display.c +3 -3
@@ -327,7 +327,7 @@ static int first_shadow_cpu(struct perf_stat_config *config,for (i =0 ; i <perf_evsel__nr_cpus (evsel); i++) {int cpu2 =evsel__cpus (evsel)->map[i]; -if (config->aggr_get_id (config, evlist->cpus, cpu2) == id) +if (config->aggr_get_id (config, evlist->core.cpus, cpu2) == id)return cpu2; }return 0 ;
@@ -500,7 +500,7 @@ static void aggr_update_shadow(struct perf_stat_config *config,evlist__for_each_entry (evlist, counter) { val =0 ;for (cpu =0 ; cpu <perf_evsel__nr_cpus (counter); cpu++) { - s2 = config->aggr_get_id (config, evlist->cpus, cpu); + s2 = config->aggr_get_id (config, evlist->core.cpus, cpu);if (s2 != id)continue ; val +=perf_counts (counter->counts, cpu,0 )->val;
@@ -868,7 +868,7 @@ static void print_no_aggr_metric(struct perf_stat_config *config,u64 ena, run, val;double uval; - nrcpus = evlist->cpus->nr; + nrcpus = evlist->core.cpus->nr;for (cpu =0 ; cpu < nrcpus; cpu++) {bool first = true;
tools/perf/util/stat.c +1 -1
@@ -514,7 +514,7 @@ int perf_stat_synthesize_config(struct perf_stat_config *config,return err; } - err =perf_event__synthesize_cpu_map (tool, evlist->cpus, + err =perf_event__synthesize_cpu_map (tool, evlist->core.cpus, process,NULL );if (err <0 ) {pr_err ("Couldn't synthesize thread map.\n" );
tools/perf/util/top.c +3 -3
@@ -95,15 +95,15 @@ size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size)if (target->cpu_list) ret +=SNPRINTF (bf + ret, size - ret,", CPU%s: %s)" , - top->evlist->cpus->nr >1 ?"s" :"" , + top->evlist->core.cpus->nr >1 ?"s" :"" , target->cpu_list);else {if (target->tid) ret +=SNPRINTF (bf + ret, size - ret,")" );else ret +=SNPRINTF (bf + ret, size - ret,", %d CPU%s)" , - top->evlist->cpus->nr, - top->evlist->cpus->nr >1 ?"s" :"" ); + top->evlist->core.cpus->nr, + top->evlist->core.cpus->nr >1 ?"s" :"" ); }perf_top__reset_sample_counters (top);
Jiri Olsa
reviewerPATCH 55/79 libperf: Add threads to struct perf_evlist
In reply to Jiri OlsaMoving threads from evlist into perf_evlist struct.
--- tools/perf/builtin-ftrace.c | 4 +-- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-record.c | 4 +-- tools/perf/builtin-stat.c | 18 +++++------ tools/perf/builtin-top.c | 4 +-- tools/perf/builtin-trace.c | 8 ++--- tools/perf/lib/include/internal/evlist.h | 2 ++ tools/perf/tests/openat-syscall-tp-fields.c | 2 +- tools/perf/util/auxtrace.c | 6 ++-- tools/perf/util/evlist.c | 36 ++++++++++----------- tools/perf/util/evlist.h | 1 - tools/perf/util/stat.c | 2 +- 12 files changed, 45 insertions(+), 44 deletions(-)
tools/perf/builtin-ftrace.c +2 -2
@@ -156,9 +156,9 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)if (target__has_cpu (&ftrace->target))return 0 ; -for (i =0 ; i <thread_map__nr (ftrace->evlist->threads); i++) { +for (i =0 ; i <thread_map__nr (ftrace->evlist->core.threads); i++) {scnprintf (buf,sizeof (buf),"%d" , - ftrace->evlist->threads->map[i]); + ftrace->evlist->core.threads->map[i]);if (append_tracing_file ("set_ftrace_pid" , buf) <0 )return -1 ; }
tools/perf/builtin-kvm.c +1 -1
@@ -1450,7 +1450,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,perf_session__set_id_hdr_size (kvm->session);ordered_events__set_copy_on_queue (&kvm->session->ordered_events, true);machine__synthesize_threads (&kvm->session->machines.host, &kvm->opts.target, - kvm->evlist->threads, false,1 ); + kvm->evlist->core.threads, false,1 ); err =kvm_live_open_events (kvm);if (err) goto out;
tools/perf/builtin-record.c +2 -2
@@ -1275,7 +1275,7 @@ static int record__synthesize(struct record *rec, bool tail)if (err) goto out; - err =perf_event__synthesize_thread_map2 (&rec->tool, rec->evlist->threads, + err =perf_event__synthesize_thread_map2 (&rec->tool, rec->evlist->core.threads, process_synthesized_event,NULL );if (err <0 ) {
@@ -1295,7 +1295,7 @@ static int record__synthesize(struct record *rec, bool tail)if (err <0 )pr_warning ("Couldn't synthesize bpf events.\n" ); - err =__machine__synthesize_threads (machine, tool, &opts->target, rec->evlist->threads, + err =__machine__synthesize_threads (machine, tool, &opts->target, rec->evlist->core.threads, process_synthesized_event, opts->sample_address,1 ); out:
tools/perf/builtin-stat.c +9 -9
@@ -263,7 +263,7 @@ static int read_single_counter(struct evsel *counter, int cpu,*/ static int read_counter (struct evsel *counter,struct timespec *rs) { -int nthreads =thread_map__nr (evsel_list->threads); +int nthreads =thread_map__nr (evsel_list->core.threads);int ncpus, cpu, thread;if (target__has_cpu (&target) && !target__has_per_thread (&target))
@@ -485,15 +485,15 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)ui__warning ("%s\n" , msg); goto try_again; }else if (target__has_per_thread (&target) && - evsel_list->threads && - evsel_list->threads->err_thread !=-1 ) { + evsel_list->core.threads && + evsel_list->core.threads->err_thread !=-1 ) {/* * For global --per-thread case, skip current * error thread. */ -if (!thread_map__remove (evsel_list->threads, - evsel_list->threads->err_thread)) { - evsel_list->threads->err_thread =-1 ; +if (!thread_map__remove (evsel_list->core.threads, + evsel_list->core.threads->err_thread)) { + evsel_list->core.threads->err_thread =-1 ; goto try_again; } }
@@ -579,7 +579,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)enable_counters ();while (!done) {nanosleep (&ts,NULL ); -if (!is_target_alive (&target, evsel_list->threads)) +if (!is_target_alive (&target, evsel_list->core.threads))break ;if (timeout)break ;
@@ -1889,10 +1889,10 @@ int cmd_stat(int argc, const char **argv)* so we could print it out on output. */ if (stat_config.aggr_mode ==AGGR_THREAD ) { -thread_map__read_comms (evsel_list->threads); +thread_map__read_comms (evsel_list->core.threads);if (target.system_wide) {if (runtime_stat_new (&stat_config, -thread_map__nr (evsel_list->threads))) { +thread_map__nr (evsel_list->core.threads))) { goto out; } }
tools/perf/builtin-top.c +2 -2
@@ -990,7 +990,7 @@ static int perf_top__start_counters(struct perf_top *top)evlist__for_each_entry (evlist, counter) { try_again:if (evsel__open (counter, top->evlist->core.cpus, - top->evlist->threads) <0 ) { + top->evlist->core.threads) <0 ) {/* * Specially handle overwrite fall back.
@@ -1222,7 +1222,7 @@ static int __cmd_top(struct perf_top *top)pr_debug ("Couldn't synthesize BPF events: Pre-existing BPF programs won't have symbols resolved.\n" );machine__synthesize_threads (&top->session->machines.host, &opts->target, - top->evlist->threads, false, + top->evlist->core.threads, false, top->nr_threads_synthesize);if (top->nr_threads_synthesize >1 )
tools/perf/builtin-trace.c +4 -4
@@ -1405,7 +1405,7 @@ static int trace__symbols_init(struct trace *trace, struct evlist *evlist) goto out; err =__machine__synthesize_threads (trace->host, &trace->tool, &trace->opts.target, - evlist->threads, trace__tool_process, false, + evlist->core.threads, trace__tool_process, false,1 ); out:if (err)
@@ -3182,7 +3182,7 @@ static int trace__set_filter_pids(struct trace *trace) err =bpf_map__set_filter_pids (trace->filter_pids.map, trace->filter_pids.nr, trace->filter_pids.entries); } - }else if (thread_map__pid (trace->evlist->threads,0 ) ==-1 ) { + }else if (thread_map__pid (trace->evlist->core.threads,0 ) ==-1 ) { err =trace__set_filter_loop_pids (trace); }
@@ -3411,8 +3411,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv)evlist__enable (evlist); } - trace->multiple_threads =thread_map__pid (evlist->threads,0 ) ==-1 || - evlist->threads->nr >1 || + trace->multiple_threads =thread_map__pid (evlist->core.threads,0 ) ==-1 || + evlist->core.threads->nr >1 ||perf_evlist__first (evlist)->core.attr.inherit;/*
tools/perf/lib/include/internal/evlist.h +2 -0
@@ -3,12 +3,14 @@#define __LIBPERF_INTERNAL_EVLIST_Hstruct perf_cpu_map ; +struct perf_thread_map ;struct perf_evlist {struct list_head entries;int nr_entries;bool has_user_cpus;struct perf_cpu_map *cpus; +struct perf_thread_map *threads; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/tests/openat-syscall-tp-fields.c +1 -1
@@ -58,7 +58,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtestperf_evsel__config (evsel, &opts,NULL ); -perf_thread_map__set_pid (evlist->threads,0 ,getpid ()); +perf_thread_map__set_pid (evlist->core.threads,0 ,getpid ()); err =evlist__open (evlist);if (err <0 ) {
tools/perf/util/auxtrace.c +3 -3
@@ -131,13 +131,13 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu = evlist->core.cpus->map[idx]; -if (evlist->threads) - mp->tid =thread_map__pid (evlist->threads,0 ); +if (evlist->core.threads) + mp->tid =thread_map__pid (evlist->core.threads,0 );else mp->tid =-1 ; }else { mp->cpu =-1 ; - mp->tid =thread_map__pid (evlist->threads, idx); + mp->tid =thread_map__pid (evlist->core.threads, idx); } }
tools/perf/util/evlist.c +18 -18
@@ -144,9 +144,9 @@ void evlist__delete(struct evlist *evlist)perf_evlist__munmap (evlist);evlist__close (evlist);perf_cpu_map__put (evlist->core.cpus); -perf_thread_map__put (evlist->threads); +perf_thread_map__put (evlist->core.threads); evlist->core.cpus =NULL ; - evlist->threads =NULL ; + evlist->core.threads =NULL ;perf_evlist__purge (evlist);perf_evlist__exit (evlist);free (evlist);
@@ -168,7 +168,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, }perf_thread_map__put (evsel->core.threads); - evsel->core.threads =perf_thread_map__get (evlist->threads); + evsel->core.threads =perf_thread_map__get (evlist->core.threads); }static void perf_evlist__propagate_maps (struct evlist *evlist)
@@ -342,7 +342,7 @@ static int perf_evlist__nr_threads(struct evlist *evlist,if (evsel->system_wide)return 1 ;else -return thread_map__nr (evlist->threads); +return thread_map__nr (evlist->core.threads); }void evlist__disable (struct evlist *evlist)
@@ -425,7 +425,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,int perf_evlist__alloc_pollfd (struct evlist *evlist) {int nr_cpus =cpu_map__nr (evlist->core.cpus); -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);int nfds =0 ;struct evsel *evsel;
@@ -556,8 +556,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, sid->cpu = evlist->core.cpus->map[cpu]; else sid->cpu = -1; -if (!evsel->system_wide && evlist->threads && thread >=0 ) - sid->tid =thread_map__pid (evlist->threads, thread); +if (!evsel->system_wide && evlist->core.threads && thread >=0 ) + sid->tid =thread_map__pid (evlist->core.threads, thread);else sid->tid =-1 ; }
@@ -722,7 +722,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist, evlist->nr_mmaps =cpu_map__nr (evlist->core.cpus);if (cpu_map__empty (evlist->core.cpus)) - evlist->nr_mmaps =thread_map__nr (evlist->threads); + evlist->nr_mmaps =thread_map__nr (evlist->core.threads); map =zalloc (evlist->nr_mmaps *sizeof (struct perf_mmap ));if (!map)return NULL ;
@@ -836,7 +836,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, {int cpu, thread;int nr_cpus =cpu_map__nr (evlist->core.cpus); -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);pr_debug2 ("perf event ring buffer mmapped per cpu\n" );for (cpu =0 ; cpu < nr_cpus; cpu++) {
@@ -864,7 +864,7 @@ static int perf_evlist__mmap_per_thread(struct evlist *evlist, struct mmap_params *mp) {int thread; -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);pr_debug2 ("perf event ring buffer mmapped per thread\n" );for (thread =0 ; thread < nr_threads; thread++) {
@@ -1015,7 +1015,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, {struct evsel *evsel;const struct perf_cpu_map *cpus = evlist->core.cpus; -const struct perf_thread_map *threads = evlist->threads; +const struct perf_thread_map *threads = evlist->core.threads;/* * Delay setting mp.prot: set it before calling perf_mmap__mmap. * Its value is decided by evsel's write_backward.
@@ -1121,9 +1121,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus, evlist->core.cpus =perf_cpu_map__get (cpus); } -if (threads != evlist->threads) { -perf_thread_map__put (evlist->threads); - evlist->threads =perf_thread_map__get (threads); +if (threads != evlist->core.threads) { +perf_thread_map__put (evlist->core.threads); + evlist->core.threads =perf_thread_map__get (threads); }perf_evlist__propagate_maps (evlist);
@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)* Default: one fd per CPU, all threads, aka systemwide * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL */ -if (evlist->threads ==NULL && evlist->core.cpus ==NULL ) { +if (evlist->core.threads ==NULL && evlist->core.cpus ==NULL ) { err =perf_evlist__create_syswide_maps (evlist);if (err <0 ) goto out_err;
@@ -1501,12 +1501,12 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target, }if (target__none (target)) { -if (evlist->threads ==NULL ) { +if (evlist->core.threads ==NULL ) {fprintf (stderr,"FATAL: evlist->threads need to be set at this point (%s:%d).\n" , __func__, __LINE__); goto out_close_pipes; } -perf_thread_map__set_pid (evlist->threads,0 , evlist->workload.pid); +perf_thread_map__set_pid (evlist->core.threads,0 , evlist->workload.pid); }close (child_ready_pipe[1 ]);
@@ -1921,7 +1921,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist,evlist__for_each_entry (evlist, counter) {if (evsel__open (counter, evlist->core.cpus, - evlist->threads) <0 ) + evlist->core.threads) <0 ) goto out_delete_evlist; }
tools/perf/util/evlist.h +0 -1
@@ -43,7 +43,6 @@ struct evlist {struct fdarray pollfd;struct perf_mmap *mmap;struct perf_mmap *overwrite_mmap; -struct perf_thread_map *threads;struct evsel *selected;struct events_stats stats;struct perf_env *env;
tools/perf/util/stat.c +1 -1
@@ -507,7 +507,7 @@ int perf_stat_synthesize_config(struct perf_stat_config *config, err =perf_event__synthesize_extra_attr (tool, evlist, process, attrs); - err =perf_event__synthesize_thread_map2 (tool, evlist->threads, + err =perf_event__synthesize_thread_map2 (tool, evlist->core.threads, process,NULL );if (err <0 ) {pr_err ("Couldn't synthesize thread map.\n" );
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add threads to struct perf_evlist
libperf: Add threads to struct perf_evlist
Commit-ID: 03617c22e31f32cbf0e4797e216db898fb898d90 Gitweb: https://git.kernel.org/tip/03617c22e31f32cbf0e4797e216db898fb898d90 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:42 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add threads to struct perf_evlist
Move threads from tools/perf's evlist to libperf's perf_evlist struct.
--- tools/perf/builtin-ftrace.c | 4 ++-- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-record.c | 4 ++-- tools/perf/builtin-stat.c | 18 +++++++-------- tools/perf/builtin-top.c | 4 ++-- tools/perf/builtin-trace.c | 8 +++---- tools/perf/lib/include/internal/evlist.h | 2 ++ tools/perf/tests/openat-syscall-tp-fields.c | 2 +- tools/perf/util/auxtrace.c | 6 ++--- tools/perf/util/evlist.c | 36 ++++++++++++++--------------- tools/perf/util/evlist.h | 1 - tools/perf/util/stat.c | 2 +- 12 files changed, 45 insertions(+), 44 deletions(-)
tools/perf/builtin-ftrace.c +2 -2
@@ -156,9 +156,9 @@ static int set_tracing_pid(struct perf_ftrace *ftrace)if (target__has_cpu (&ftrace->target))return 0 ; -for (i =0 ; i <thread_map__nr (ftrace->evlist->threads); i++) { +for (i =0 ; i <thread_map__nr (ftrace->evlist->core.threads); i++) {scnprintf (buf,sizeof (buf),"%d" , - ftrace->evlist->threads->map[i]); + ftrace->evlist->core.threads->map[i]);if (append_tracing_file ("set_ftrace_pid" , buf) <0 )return -1 ; }
tools/perf/builtin-kvm.c +1 -1
@@ -1450,7 +1450,7 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,perf_session__set_id_hdr_size (kvm->session);ordered_events__set_copy_on_queue (&kvm->session->ordered_events, true);machine__synthesize_threads (&kvm->session->machines.host, &kvm->opts.target, - kvm->evlist->threads, false,1 ); + kvm->evlist->core.threads, false,1 ); err =kvm_live_open_events (kvm);if (err) goto out;
tools/perf/builtin-record.c +2 -2
@@ -1275,7 +1275,7 @@ static int record__synthesize(struct record *rec, bool tail)if (err) goto out; - err =perf_event__synthesize_thread_map2 (&rec->tool, rec->evlist->threads, + err =perf_event__synthesize_thread_map2 (&rec->tool, rec->evlist->core.threads, process_synthesized_event,NULL );if (err <0 ) {
@@ -1295,7 +1295,7 @@ static int record__synthesize(struct record *rec, bool tail)if (err <0 )pr_warning ("Couldn't synthesize bpf events.\n" ); - err =__machine__synthesize_threads (machine, tool, &opts->target, rec->evlist->threads, + err =__machine__synthesize_threads (machine, tool, &opts->target, rec->evlist->core.threads, process_synthesized_event, opts->sample_address,1 ); out:
tools/perf/builtin-stat.c +9 -9
@@ -263,7 +263,7 @@ static int read_single_counter(struct evsel *counter, int cpu,*/ static int read_counter (struct evsel *counter,struct timespec *rs) { -int nthreads =thread_map__nr (evsel_list->threads); +int nthreads =thread_map__nr (evsel_list->core.threads);int ncpus, cpu, thread;if (target__has_cpu (&target) && !target__has_per_thread (&target))
@@ -485,15 +485,15 @@ try_again:ui__warning ("%s\n" , msg); goto try_again; }else if (target__has_per_thread (&target) && - evsel_list->threads && - evsel_list->threads->err_thread !=-1 ) { + evsel_list->core.threads && + evsel_list->core.threads->err_thread !=-1 ) {/* * For global --per-thread case, skip current * error thread. */ -if (!thread_map__remove (evsel_list->threads, - evsel_list->threads->err_thread)) { - evsel_list->threads->err_thread =-1 ; +if (!thread_map__remove (evsel_list->core.threads, + evsel_list->core.threads->err_thread)) { + evsel_list->core.threads->err_thread =-1 ; goto try_again; } }
@@ -579,7 +579,7 @@ try_again:enable_counters ();while (!done) {nanosleep (&ts,NULL ); -if (!is_target_alive (&target, evsel_list->threads)) +if (!is_target_alive (&target, evsel_list->core.threads))break ;if (timeout)break ;
@@ -1889,10 +1889,10 @@ int cmd_stat(int argc, const char **argv)* so we could print it out on output. */ if (stat_config.aggr_mode ==AGGR_THREAD ) { -thread_map__read_comms (evsel_list->threads); +thread_map__read_comms (evsel_list->core.threads);if (target.system_wide) {if (runtime_stat_new (&stat_config, -thread_map__nr (evsel_list->threads))) { +thread_map__nr (evsel_list->core.threads))) { goto out; } }
tools/perf/builtin-top.c +2 -2
@@ -990,7 +990,7 @@ static int perf_top__start_counters(struct perf_top *top)evlist__for_each_entry (evlist, counter) { try_again:if (evsel__open (counter, top->evlist->core.cpus, - top->evlist->threads) <0 ) { + top->evlist->core.threads) <0 ) {/* * Specially handle overwrite fall back.
@@ -1222,7 +1222,7 @@ static int __cmd_top(struct perf_top *top)pr_debug ("Couldn't synthesize BPF events: Pre-existing BPF programs won't have symbols resolved.\n" );machine__synthesize_threads (&top->session->machines.host, &opts->target, - top->evlist->threads, false, + top->evlist->core.threads, false, top->nr_threads_synthesize);if (top->nr_threads_synthesize >1 )
tools/perf/builtin-trace.c +4 -4
@@ -1404,7 +1404,7 @@ static int trace__symbols_init(struct trace *trace, struct evlist *evlist) goto out; err =__machine__synthesize_threads (trace->host, &trace->tool, &trace->opts.target, - evlist->threads, trace__tool_process, false, + evlist->core.threads, trace__tool_process, false,1 ); out:if (err)
@@ -3183,7 +3183,7 @@ static int trace__set_filter_pids(struct trace *trace) err =bpf_map__set_filter_pids (trace->filter_pids.map, trace->filter_pids.nr, trace->filter_pids.entries); } - }else if (thread_map__pid (trace->evlist->threads,0 ) ==-1 ) { + }else if (thread_map__pid (trace->evlist->core.threads,0 ) ==-1 ) { err =trace__set_filter_loop_pids (trace); }
@@ -3412,8 +3412,8 @@ static int trace__run(struct trace *trace, int argc, const char **argv)evlist__enable (evlist); } - trace->multiple_threads =thread_map__pid (evlist->threads,0 ) ==-1 || - evlist->threads->nr >1 || + trace->multiple_threads =thread_map__pid (evlist->core.threads,0 ) ==-1 || + evlist->core.threads->nr >1 ||perf_evlist__first (evlist)->core.attr.inherit;/*
tools/perf/lib/include/internal/evlist.h +2 -0
@@ -3,12 +3,14 @@#define __LIBPERF_INTERNAL_EVLIST_Hstruct perf_cpu_map ; +struct perf_thread_map ;struct perf_evlist {struct list_head entries;int nr_entries;bool has_user_cpus;struct perf_cpu_map *cpus; +struct perf_thread_map *threads; };#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/tests/openat-syscall-tp-fields.c +1 -1
@@ -58,7 +58,7 @@ int test__syscall_openat_tp_fields(struct test *test __maybe_unused, int subtestperf_evsel__config (evsel, &opts,NULL ); -perf_thread_map__set_pid (evlist->threads,0 ,getpid ()); +perf_thread_map__set_pid (evlist->core.threads,0 ,getpid ()); err =evlist__open (evlist);if (err <0 ) {
tools/perf/util/auxtrace.c +3 -3
@@ -131,13 +131,13 @@ void auxtrace_mmap_params__set_idx(struct auxtrace_mmap_params *mp,if (per_cpu) { mp->cpu = evlist->core.cpus->map[idx]; -if (evlist->threads) - mp->tid =thread_map__pid (evlist->threads,0 ); +if (evlist->core.threads) + mp->tid =thread_map__pid (evlist->core.threads,0 );else mp->tid =-1 ; }else { mp->cpu =-1 ; - mp->tid =thread_map__pid (evlist->threads, idx); + mp->tid =thread_map__pid (evlist->core.threads, idx); } }
tools/perf/util/evlist.c +18 -18
@@ -144,9 +144,9 @@ void evlist__delete(struct evlist *evlist)perf_evlist__munmap (evlist);evlist__close (evlist);perf_cpu_map__put (evlist->core.cpus); -perf_thread_map__put (evlist->threads); +perf_thread_map__put (evlist->core.threads); evlist->core.cpus =NULL ; - evlist->threads =NULL ; + evlist->core.threads =NULL ;perf_evlist__purge (evlist);perf_evlist__exit (evlist);free (evlist);
@@ -168,7 +168,7 @@ static void __perf_evlist__propagate_maps(struct evlist *evlist, }perf_thread_map__put (evsel->core.threads); - evsel->core.threads =perf_thread_map__get (evlist->threads); + evsel->core.threads =perf_thread_map__get (evlist->core.threads); }static void perf_evlist__propagate_maps (struct evlist *evlist)
@@ -342,7 +342,7 @@ static int perf_evlist__nr_threads(struct evlist *evlist,if (evsel->system_wide)return 1 ;else -return thread_map__nr (evlist->threads); +return thread_map__nr (evlist->core.threads); }void evlist__disable (struct evlist *evlist)
@@ -425,7 +425,7 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,int perf_evlist__alloc_pollfd (struct evlist *evlist) {int nr_cpus =cpu_map__nr (evlist->core.cpus); -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);int nfds =0 ;struct evsel *evsel;
@@ -556,8 +556,8 @@ static void perf_evlist__set_sid_idx(struct evlist *evlist, sid->cpu = evlist->core.cpus->map[cpu]; else sid->cpu = -1; -if (!evsel->system_wide && evlist->threads && thread >=0 ) - sid->tid =thread_map__pid (evlist->threads, thread); +if (!evsel->system_wide && evlist->core.threads && thread >=0 ) + sid->tid =thread_map__pid (evlist->core.threads, thread);else sid->tid =-1 ; }
@@ -722,7 +722,7 @@ static struct perf_mmap *perf_evlist__alloc_mmap(struct evlist *evlist, evlist->nr_mmaps =cpu_map__nr (evlist->core.cpus);if (cpu_map__empty (evlist->core.cpus)) - evlist->nr_mmaps =thread_map__nr (evlist->threads); + evlist->nr_mmaps =thread_map__nr (evlist->core.threads); map =zalloc (evlist->nr_mmaps *sizeof (struct perf_mmap ));if (!map)return NULL ;
@@ -836,7 +836,7 @@ static int perf_evlist__mmap_per_cpu(struct evlist *evlist, {int cpu, thread;int nr_cpus =cpu_map__nr (evlist->core.cpus); -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);pr_debug2 ("perf event ring buffer mmapped per cpu\n" );for (cpu =0 ; cpu < nr_cpus; cpu++) {
@@ -864,7 +864,7 @@ static int perf_evlist__mmap_per_thread(struct evlist *evlist, struct mmap_params *mp) {int thread; -int nr_threads =thread_map__nr (evlist->threads); +int nr_threads =thread_map__nr (evlist->core.threads);pr_debug2 ("perf event ring buffer mmapped per thread\n" );for (thread =0 ; thread < nr_threads; thread++) {
@@ -1015,7 +1015,7 @@ int perf_evlist__mmap_ex(struct evlist *evlist, unsigned int pages, {struct evsel *evsel;const struct perf_cpu_map *cpus = evlist->core.cpus; -const struct perf_thread_map *threads = evlist->threads; +const struct perf_thread_map *threads = evlist->core.threads;/* * Delay setting mp.prot: set it before calling perf_mmap__mmap. * Its value is decided by evsel's write_backward.
@@ -1121,9 +1121,9 @@ void perf_evlist__set_maps(struct evlist *evlist, struct perf_cpu_map *cpus, evlist->core.cpus =perf_cpu_map__get (cpus); } -if (threads != evlist->threads) { -perf_thread_map__put (evlist->threads); - evlist->threads =perf_thread_map__get (threads); +if (threads != evlist->core.threads) { +perf_thread_map__put (evlist->core.threads); + evlist->core.threads =perf_thread_map__get (threads); }perf_evlist__propagate_maps (evlist);
@@ -1398,7 +1398,7 @@ int evlist__open(struct evlist *evlist)* Default: one fd per CPU, all threads, aka systemwide * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL */ -if (evlist->threads ==NULL && evlist->core.cpus ==NULL ) { +if (evlist->core.threads ==NULL && evlist->core.cpus ==NULL ) { err =perf_evlist__create_syswide_maps (evlist);if (err <0 ) goto out_err;
@@ -1501,12 +1501,12 @@ int perf_evlist__prepare_workload(struct evlist *evlist, struct target *target, }if (target__none (target)) { -if (evlist->threads ==NULL ) { +if (evlist->core.threads ==NULL ) {fprintf (stderr,"FATAL: evlist->threads need to be set at this point (%s:%d).\n" , __func__, __LINE__); goto out_close_pipes; } -perf_thread_map__set_pid (evlist->threads,0 , evlist->workload.pid); +perf_thread_map__set_pid (evlist->core.threads,0 , evlist->workload.pid); }close (child_ready_pipe[1 ]);
@@ -1921,7 +1921,7 @@ int perf_evlist__start_sb_thread(struct evlist *evlist,evlist__for_each_entry (evlist, counter) {if (evsel__open (counter, evlist->core.cpus, - evlist->threads) <0 ) + evlist->core.threads) <0 ) goto out_delete_evlist; }
tools/perf/util/evlist.h +0 -1
@@ -43,7 +43,6 @@ struct evlist {struct fdarray pollfd;struct perf_mmap *mmap;struct perf_mmap *overwrite_mmap; -struct perf_thread_map *threads;struct evsel *selected;struct events_stats stats;struct perf_env *env;
tools/perf/util/stat.c +1 -1
@@ -507,7 +507,7 @@ int perf_stat_synthesize_config(struct perf_stat_config *config, err =perf_event__synthesize_extra_attr (tool, evlist, process, attrs); - err =perf_event__synthesize_thread_map2 (tool, evlist->threads, + err =perf_event__synthesize_thread_map2 (tool, evlist->core.threads, process,NULL );if (err <0 ) {pr_err ("Couldn't synthesize thread map.\n" );
Jiri Olsa
reviewerPATCH 56/79 libperf: Add perf_evlist__set_maps function
In reply to Jiri OlsaMoving evlist__set_maps function under libperf.
--- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 3 +- tools/perf/builtin-script.c | 3 +- tools/perf/builtin-stat.c | 3 +- tools/perf/lib/evlist.c | 54 ++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 6 ++ tools/perf/lib/libperf.map | 1 + tools/perf/tests/code-reading.c | 5 +- tools/perf/tests/keep-tracking.c | 3 +- tools/perf/tests/mmap-basic.c | 3 +- tools/perf/tests/sw-clock.c | 3 +- tools/perf/tests/switch-tracking.c | 3 +- tools/perf/tests/task-exit.c | 3 +- tools/perf/util/evlist.c | 58 +------------------- tools/perf/util/evlist.h | 2 - 14 files changed, 83 insertions(+), 67 deletions(-)
tools/perf/arch/x86/tests/perf-time-to-tsc.c +2 -1
@@ -6,6 +6,7 @@#include <linux/types.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -72,7 +73,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));
tools/perf/builtin-script.c +2 -1
@@ -48,6 +48,7 @@#include <fcntl.h> #include <unistd.h> #include <subcmd/pager.h> +#include <perf/evlist.h> #include <linux/ctype.h>
@@ -3264,7 +3265,7 @@ static int set_maps(struct perf_script *script)if (WARN_ONCE (script->allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evlist, script->cpus, script->threads); +perf_evlist__set_maps (&evlist->core, script->cpus, script->threads);if (perf_evlist__alloc_stats (evlist, true))return -ENOMEM ;
tools/perf/builtin-stat.c +2 -1
@@ -83,6 +83,7 @@#include <sys/resource.h> #include <linux/ctype.h> +#include <perf/evlist.h> #define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
@@ -1517,7 +1518,7 @@ static int set_maps(struct perf_stat *st)if (WARN_ONCE (st->maps_allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evsel_list, st->cpus, st->threads); +perf_evlist__set_maps (&evsel_list->core, st->cpus, st->threads);if (perf_evlist__alloc_stats (evsel_list, true))return -ENOMEM ;
tools/perf/lib/evlist.c +54 -0
74 lines not on this page · raw message
tools/perf/lib/include/perf/evlist.h +6 -0
@@ -6,6 +6,8 @@struct perf_evlist ;struct perf_evsel ; +struct perf_cpu_map ; +struct perf_thread_map ; LIBPERF_API void perf_evlist__init(struct perf_evlist *evlist); LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist,
@@ -22,4 +24,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, (pos) !=NULL ; \ (pos) = perf_evlist__next((evlist), (pos))) +LIBPERF_API void perf_evlist__set_maps(struct perf_evlist *evlist, +struct perf_cpu_map *cpus, +struct perf_thread_map *threads); +#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -20,6 +20,7 @@ LIBPERF_0.0.1 { perf_evlist__add; perf_evlist__remove; perf_evlist__next; + perf_evlist__set_maps; local: *; };
tools/perf/tests/code-reading.c +3 -2
@@ -9,6 +9,7 @@#include <string.h> #include <sys/param.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -629,7 +630,7 @@ static int do_test_code_reading(bool try_kcore) goto out_put; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); str =do_determine_event (excl_kernel);pr_debug ("Parsing event '%s'\n" , str);
@@ -658,7 +659,7 @@ static int do_test_code_reading(bool try_kcore)*/ perf_cpu_map__get (cpus);perf_thread_map__get (threads); -perf_evlist__set_maps (evlist,NULL ,NULL ); +perf_evlist__set_maps (&evlist->core,NULL ,NULL );evlist__delete (evlist); evlist =NULL ;continue ;
tools/perf/tests/keep-tracking.c +2 -1
@@ -3,6 +3,7 @@#include <unistd.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -82,7 +83,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"dummy:u" ,NULL ));CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));
tools/perf/tests/mmap-basic.c +2 -1
@@ -12,6 +12,7 @@#include "tests.h" #include <linux/err.h> #include <linux/kernel.h> +#include <perf/evlist.h> /* * This test will generate random numbers of calls to some getpid syscalls,
@@ -68,7 +69,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse goto out_free_cpus; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);for (i =0 ; i < nsyscalls; ++i) {char name[64 ];
tools/perf/tests/sw-clock.c +2 -1
@@ -11,6 +11,7 @@#include "util/evlist.h" #include "util/cpumap.h" #include "util/thread_map.h" +#include <perf/evlist.h> #define NR_LOOPS 10000000
@@ -64,7 +65,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;
tools/perf/tests/switch-tracking.c +2 -1
@@ -6,6 +6,7 @@#include <stdlib.h> #include <linux/zalloc.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -354,7 +355,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_ goto out_err; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);/* First event */ err =parse_events (evlist,"cpu-clock:u" ,NULL );
tools/perf/tests/task-exit.c +2 -1
@@ -7,6 +7,7 @@#include <errno.h> #include <signal.h> +#include <perf/evlist.h> static int exited;static int nr_exit;
@@ -71,7 +72,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;
tools/perf/util/evlist.c +3 -55
94 lines not on this page · raw message
tools/perf/util/evlist.h +0 -2
@@ -191,8 +191,6 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,void perf_evlist__set_selected (struct evlist *evlist,struct evsel *evsel); -void perf_evlist__set_maps (struct evlist *evlist,struct perf_cpu_map *cpus, -struct perf_thread_map *threads);int perf_evlist__create_maps (struct evlist *evlist,struct target *target);int perf_evlist__apply_filters (struct evlist *evlist,struct evsel **err_evsel);
Signature · 1 line
2.21.0
Re: [PATCH 56/79] libperf: Add perf_evlist__set_maps function
Em Sun, Jul 21, 2019 at 01:24:43PM +0200, Jiri Olsa escreveu:
Quoted 1 line
Moving
evlist__set_mapsfunction under libperf.
Fixed up conflict due to the fix in the call order with perf_evlist__init() in a previous patch, pushed out to acme/perf/core, will continue later.
- Arnaldo
Quoted 451 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 3 +- tools/perf/builtin-script.c | 3 +- tools/perf/builtin-stat.c | 3 +- tools/perf/lib/evlist.c | 54 ++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 6 ++ tools/perf/lib/libperf.map | 1 + tools/perf/tests/code-reading.c | 5 +- tools/perf/tests/keep-tracking.c | 3 +- tools/perf/tests/mmap-basic.c | 3 +- tools/perf/tests/sw-clock.c | 3 +- tools/perf/tests/switch-tracking.c | 3 +- tools/perf/tests/task-exit.c | 3 +- tools/perf/util/evlist.c | 58 +------------------- tools/perf/util/evlist.h | 2 - 14 files changed, 83 insertions(+), 67 deletions(-)tools/perf/arch/x86/tests/perf-time-to-tsc.c +2
-1@@ -6,6 +6,7 @@#include <linux/types.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h" @@ -72,7 +73,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));tools/perf/builtin-script.c +2
-1@@ -48,6 +48,7 @@#include <fcntl.h> #include <unistd.h> #include <subcmd/pager.h> +#include <perf/evlist.h> #include <linux/ctype.h> @@ -3264,7 +3265,7 @@ static int set_maps(struct perf_script *script)if (WARN_ONCE (script->allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evlist, script->cpus, script->threads); +perf_evlist__set_maps (&evlist->core, script->cpus, script->threads);if (perf_evlist__alloc_stats (evlist, true))return -ENOMEM ;tools/perf/builtin-stat.c +2
-1@@ -83,6 +83,7 @@#include <sys/resource.h> #include <linux/ctype.h> +#include <perf/evlist.h> #define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"@@ -1517,7 +1518,7 @@ static int set_maps(struct perf_stat *st)if (WARN_ONCE (st->maps_allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evsel_list, st->cpus, st->threads); +perf_evlist__set_maps (&evsel_list->core, st->cpus, st->threads);if (perf_evlist__alloc_stats (evsel_list, true))return -ENOMEM ;tools/perf/lib/evlist.c +54
-0@@ -5,6 +5,8 @@#include <internal/evsel.h> #include <linux/zalloc.h> #include <stdlib.h> +#include <perf/cpumap.h> +#include <perf/threadmap.h> void perf_evlist__init (struct perf_evlist *evlist) {@@ -12,11 +14,39 @@ void perf_evlist__init(struct perf_evlist *evlist) evlist->nr_entries =0 ; } +static void __perf_evlist__propagate_maps (struct perf_evlist *evlist, +struct perf_evsel *evsel) +{ +/* +* We already have cpus for evsel (via PMU sysfs) so +* keep it, if there's no target cpu list defined. +*/ +if (!evsel->own_cpus || evlist->has_user_cpus) { +perf_cpu_map__put (evsel->cpus); + evsel->cpus =perf_cpu_map__get (evlist->cpus); + }else if (evsel->cpus != evsel->own_cpus) { +perf_cpu_map__put (evsel->cpus); + evsel->cpus =perf_cpu_map__get (evsel->own_cpus); + } + +perf_thread_map__put (evsel->threads); + evsel->threads =perf_thread_map__get (evlist->threads); +} + +static void perf_evlist__propagate_maps (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_evsel (evlist, evsel) +__perf_evlist__propagate_maps (evlist, evsel); +} +void perf_evlist__add (struct perf_evlist *evlist,struct perf_evsel *evsel) {list_add_tail (&evsel->node, &evlist->entries); evlist->nr_entries +=1 ; +__perf_evlist__propagate_maps (evlist, evsel); } void perf_evlist__remove(struct perf_evlist *evlist,@@ -60,3 +90,27 @@ void perf_evlist__delete(struct perf_evlist *evlist) {free (evlist); } + +void perf_evlist__set_maps (struct perf_evlist *evlist, +struct perf_cpu_map *cpus, +struct perf_thread_map *threads) +{ +/* +* Allow for the possibility that one or another of the maps isn't being +* changed i.e. don't put it. Note we are assuming the maps that are +* being applied are brand new and evlist is taking ownership of the +* original reference count of 1. If that is not the case it is up to +* the caller to increase the reference count. +*/ +if (cpus != evlist->cpus) { +perf_cpu_map__put (evlist->cpus); + evlist->cpus =perf_cpu_map__get (cpus); + } + +if (threads != evlist->threads) { +perf_thread_map__put (evlist->threads); + evlist->threads =perf_thread_map__get (threads); + } + +perf_evlist__propagate_maps (evlist); +}tools/perf/lib/include/perf/evlist.h +6
-0@@ -6,6 +6,8 @@struct perf_evlist ;struct perf_evsel ; +struct perf_cpu_map ; +struct perf_thread_map ; LIBPERF_API void perf_evlist__init(struct perf_evlist *evlist); LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist,@@ -22,4 +24,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, (pos) !=NULL ; \ (pos) = perf_evlist__next((evlist), (pos))) +LIBPERF_API void perf_evlist__set_maps(struct perf_evlist *evlist, +struct perf_cpu_map *cpus, +struct perf_thread_map *threads); +#endif /* __LIBPERF_EVLIST_H */ tools/perf/lib/libperf.map +1
-0@@ -20,6 +20,7 @@ LIBPERF_0.0.1 { perf_evlist__add; perf_evlist__remove; perf_evlist__next; + perf_evlist__set_maps; local: *; };tools/perf/tests/code-reading.c +3
-2@@ -9,6 +9,7 @@#include <string.h> #include <sys/param.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h" @@ -629,7 +630,7 @@ static int do_test_code_reading(bool try_kcore) goto out_put; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); str =do_determine_event (excl_kernel);pr_debug ("Parsing event '%s'\n" , str);@@ -658,7 +659,7 @@ static int do_test_code_reading(bool try_kcore)*/ perf_cpu_map__get (cpus);perf_thread_map__get (threads); -perf_evlist__set_maps (evlist,NULL ,NULL ); +perf_evlist__set_maps (&evlist->core,NULL ,NULL );evlist__delete (evlist); evlist =NULL ;continue ;tools/perf/tests/keep-tracking.c +2
-1@@ -3,6 +3,7 @@#include <unistd.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h" @@ -82,7 +83,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"dummy:u" ,NULL ));CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));tools/perf/tests/mmap-basic.c +2
-1@@ -12,6 +12,7 @@#include "tests.h" #include <linux/err.h> #include <linux/kernel.h> +#include <perf/evlist.h> /* * This test will generate random numbers of calls to some getpid syscalls, @@ -68,7 +69,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse goto out_free_cpus; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);for (i =0 ; i < nsyscalls; ++i) {char name[64 ];tools/perf/tests/sw-clock.c +2
-1@@ -11,6 +11,7 @@#include "util/evlist.h" #include "util/cpumap.h" #include "util/thread_map.h" +#include <perf/evlist.h> #define NR_LOOPS 10000000@@ -64,7 +65,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;tools/perf/tests/switch-tracking.c +2
-1@@ -6,6 +6,7 @@#include <stdlib.h> #include <linux/zalloc.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h" @@ -354,7 +355,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_ goto out_err; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);/* First event */ err =parse_events (evlist,"cpu-clock:u" ,NULL );tools/perf/tests/task-exit.c +2
-1@@ -7,6 +7,7 @@#include <errno.h> #include <signal.h> +#include <perf/evlist.h> static int exited;static int nr_exit;@@ -71,7 +72,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;tools/perf/util/evlist.c +3
-55@@ -50,7 +50,7 @@ void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,for (i =0 ; i <PERF_EVLIST__HLIST_SIZE ; ++i)INIT_HLIST_HEAD (&evlist->heads[i]); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);fdarray__init (&evlist->pollfd,64 ); evlist->workload.pid =-1 ; evlist->bkw_mmap_state =BKW_MMAP_NOTREADY ;@@ -152,33 +152,6 @@ void evlist__delete(struct evlist *evlist)free (evlist); } -static void __perf_evlist__propagate_maps (struct evlist *evlist, -struct evsel *evsel) -{ -/* -* We already have cpus for evsel (via PMU sysfs) so -* keep it, if there's no target cpu list defined. -*/ -if (!evsel->core.own_cpus || evlist->core.has_user_cpus) { -perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evlist->core.cpus); - }else if (evsel->core.cpus != evsel->core.own_cpus) { -perf_cpu_map__put (evsel->core.cpus); - evsel->core.cpus =perf_cpu_map__get (evsel->core.own_cpus); - } - -perf_thread_map__put (evsel->core.threads); - evsel->core.threads =perf_thread_map__get (evlist->core.threads); -} - -static void perf_evlist__propagate_maps (struct evlist *evlist) -{ -struct evsel *evsel; - -evlist__for_each_entry (evlist, evsel) -__perf_evlist__propagate_maps (evlist, evsel); -} -void evlist__add (struct evlist *evlist,struct evsel *entry) { entry->evlist = evlist;@@ -189,8 +162,6 @@ void evlist__add(struct evlist *evlist, struct evsel *entry)if (evlist->core.nr_entries ==1 )perf_evlist__set_id_pos (evlist); - -__perf_evlist__propagate_maps (evlist, entry); }void evlist__remove (struct evlist *evlist,struct evsel *evsel)@@ -1097,7 +1068,7 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target) evlist->core.has_user_cpus = !!target->cpu_list; -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);return 0 ;@@ -1106,29 +1077,6 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)return -1 ; } -void perf_evlist__set_maps (struct evlist *evlist,struct perf_cpu_map *cpus, -struct perf_thread_map *threads) -{ -/* -* Allow for the possibility that one or another of the maps isn't being -* changed i.e. don't put it. Note we are assuming the maps that are -* being applied are brand new and evlist is taking ownership of the -* original reference count of 1. If that is not the case it is up to -* the caller to increase the reference count. -*/ -if (cpus != evlist->core.cpus) { -perf_cpu_map__put (evlist->core.cpus); - evlist->core.cpus =perf_cpu_map__get (cpus); - } - -if (threads != evlist->core.threads) { -perf_thread_map__put (evlist->core.threads); - evlist->core.threads =perf_thread_map__get (threads); - } - -perf_evlist__propagate_maps (evlist); -} -void __perf_evlist__set_sample_bit (struct evlist *evlist,enum perf_event_sample_format bit) {@@ -1381,7 +1329,7 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)if (!threads) goto out_put; -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); out:return err; out_put:tools/perf/util/evlist.h +0
-2@@ -191,8 +191,6 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,void perf_evlist__set_selected (struct evlist *evlist,struct evsel *evsel); -void perf_evlist__set_maps (struct evlist *evlist,struct perf_cpu_map *cpus, -struct perf_thread_map *threads);int perf_evlist__create_maps (struct evlist *evlist,struct target *target);int perf_evlist__apply_filters (struct evlist *evlist,struct evsel **err_evsel);Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evlist__set_maps() function
In reply to Jiri Olsalibperf: Add perf_evlist__set_maps() function
Commit-ID: 453fa03090a64c0e0a561f10dfd5e8747796949c Gitweb: https://git.kernel.org/tip/453fa03090a64c0e0a561f10dfd5e8747796949c Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:43 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Add perf_evlist__set_maps() function
Move the evlist__set_maps() function from tools/perf to libperf.
Committer notes:
Fix up reject due to earlier inversion in calling perf_evlist__init().
--- tools/perf/arch/x86/tests/perf-time-to-tsc.c | 3 +- tools/perf/builtin-script.c | 3 +- tools/perf/builtin-stat.c | 3 +- tools/perf/lib/evlist.c | 54 ++++++++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 6 +++ tools/perf/lib/libperf.map | 1 + tools/perf/tests/code-reading.c | 5 ++- tools/perf/tests/keep-tracking.c | 3 +- tools/perf/tests/mmap-basic.c | 3 +- tools/perf/tests/sw-clock.c | 3 +- tools/perf/tests/switch-tracking.c | 3 +- tools/perf/tests/task-exit.c | 3 +- tools/perf/util/evlist.c | 58 ++-------------------------- tools/perf/util/evlist.h | 2 - 14 files changed, 83 insertions(+), 67 deletions(-)
tools/perf/arch/x86/tests/perf-time-to-tsc.c +2 -1
@@ -6,6 +6,7 @@#include <linux/types.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -72,7 +73,7 @@ int test__perf_time_to_tsc(struct test *test __maybe_unused, int subtest __maybe evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));
tools/perf/builtin-script.c +2 -1
@@ -48,6 +48,7 @@#include <fcntl.h> #include <unistd.h> #include <subcmd/pager.h> +#include <perf/evlist.h> #include <linux/ctype.h>
@@ -3264,7 +3265,7 @@ static int set_maps(struct perf_script *script)if (WARN_ONCE (script->allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evlist, script->cpus, script->threads); +perf_evlist__set_maps (&evlist->core, script->cpus, script->threads);if (perf_evlist__alloc_stats (evlist, true))return -ENOMEM ;
tools/perf/builtin-stat.c +2 -1
@@ -83,6 +83,7 @@#include <sys/resource.h> #include <linux/ctype.h> +#include <perf/evlist.h> #define DEFAULT_SEPARATOR " "#define FREEZE_ON_SMI_PATH "devices/cpu/freeze_on_smi"
@@ -1517,7 +1518,7 @@ static int set_maps(struct perf_stat *st)if (WARN_ONCE (st->maps_allocated,"stats double allocation\n" ))return -EINVAL ; -perf_evlist__set_maps (evsel_list, st->cpus, st->threads); +perf_evlist__set_maps (&evsel_list->core, st->cpus, st->threads);if (perf_evlist__alloc_stats (evsel_list, true))return -ENOMEM ;
tools/perf/lib/evlist.c +54 -0
74 lines not on this page · raw message
tools/perf/lib/include/perf/evlist.h +6 -0
@@ -6,6 +6,8 @@struct perf_evlist ;struct perf_evsel ; +struct perf_cpu_map ; +struct perf_thread_map ; LIBPERF_API void perf_evlist__init(struct perf_evlist *evlist); LIBPERF_API void perf_evlist__add(struct perf_evlist *evlist,
@@ -22,4 +24,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, (pos) !=NULL ; \ (pos) = perf_evlist__next((evlist), (pos))) +LIBPERF_API void perf_evlist__set_maps(struct perf_evlist *evlist, +struct perf_cpu_map *cpus, +struct perf_thread_map *threads); +#endif /* __LIBPERF_EVLIST_H */
tools/perf/lib/libperf.map +1 -0
@@ -20,6 +20,7 @@ LIBPERF_0.0.1 { perf_evlist__add; perf_evlist__remove; perf_evlist__next; + perf_evlist__set_maps; local: *; };
tools/perf/tests/code-reading.c +3 -2
@@ -9,6 +9,7 @@#include <string.h> #include <sys/param.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -629,7 +630,7 @@ static int do_test_code_reading(bool try_kcore) goto out_put; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); str =do_determine_event (excl_kernel);pr_debug ("Parsing event '%s'\n" , str);
@@ -658,7 +659,7 @@ static int do_test_code_reading(bool try_kcore)*/ perf_cpu_map__get (cpus);perf_thread_map__get (threads); -perf_evlist__set_maps (evlist,NULL ,NULL ); +perf_evlist__set_maps (&evlist->core,NULL ,NULL );evlist__delete (evlist); evlist =NULL ;continue ;
tools/perf/tests/keep-tracking.c +2 -1
@@ -3,6 +3,7 @@#include <unistd.h> #include <sys/prctl.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -82,7 +83,7 @@ int test__keep_tracking(struct test *test __maybe_unused, int subtest __maybe_un evlist =evlist__new ();CHECK_NOT_NULL__ (evlist); -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);CHECK__ (parse_events (evlist,"dummy:u" ,NULL ));CHECK__ (parse_events (evlist,"cycles:u" ,NULL ));
tools/perf/tests/mmap-basic.c +2 -1
@@ -12,6 +12,7 @@#include "tests.h" #include <linux/err.h> #include <linux/kernel.h> +#include <perf/evlist.h> /* * This test will generate random numbers of calls to some getpid syscalls,
@@ -68,7 +69,7 @@ int test__basic_mmap(struct test *test __maybe_unused, int subtest __maybe_unuse goto out_free_cpus; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);for (i =0 ; i < nsyscalls; ++i) {char name[64 ];
tools/perf/tests/sw-clock.c +2 -1
@@ -11,6 +11,7 @@#include "util/evlist.h" #include "util/cpumap.h" #include "util/thread_map.h" +#include <perf/evlist.h> #define NR_LOOPS 10000000
@@ -64,7 +65,7 @@ static int __test__sw_clock_freq(enum perf_sw_ids clock_id) goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;
tools/perf/tests/switch-tracking.c +2 -1
@@ -6,6 +6,7 @@#include <stdlib.h> #include <linux/zalloc.h> #include <perf/cpumap.h> +#include <perf/evlist.h> #include "parse-events.h" #include "evlist.h"
@@ -354,7 +355,7 @@ int test__switch_tracking(struct test *test __maybe_unused, int subtest __maybe_ goto out_err; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads);/* First event */ err =parse_events (evlist,"cpu-clock:u" ,NULL );
tools/perf/tests/task-exit.c +2 -1
@@ -7,6 +7,7 @@#include <errno.h> #include <signal.h> +#include <perf/evlist.h> static int exited;static int nr_exit;
@@ -71,7 +72,7 @@ int test__task_exit(struct test *test __maybe_unused, int subtest __maybe_unused goto out_free_maps; } -perf_evlist__set_maps (evlist, cpus, threads); +perf_evlist__set_maps (&evlist->core, cpus, threads); cpus =NULL ; threads =NULL ;
tools/perf/util/evlist.c +3 -55
94 lines not on this page · raw message
tools/perf/util/evlist.h +0 -2
@@ -191,8 +191,6 @@ int perf_evlist__enable_event_idx(struct evlist *evlist,void perf_evlist__set_selected (struct evlist *evlist,struct evsel *evsel); -void perf_evlist__set_maps (struct evlist *evlist,struct perf_cpu_map *cpus, -struct perf_thread_map *threads);int perf_evlist__create_maps (struct evlist *evlist,struct target *target);int perf_evlist__apply_filters (struct evlist *evlist,struct evsel **err_evsel);
Jiri Olsa
reviewerPATCH 57/79 libperf: Add xyarray object
In reply to Jiri OlsaMoving xyarray object from perf to libperf,
because it's going to be used in both.
--- tools/perf/builtin-top.c | 1 - tools/perf/lib/Build | 1 + tools/perf/lib/include/internal/xyarray.h | 35 +++++++++++++++++++++++ tools/perf/lib/xyarray.c | 33 +++++++++++++++++++++ tools/perf/util/Build | 1 - tools/perf/util/counts.h | 2 +- tools/perf/util/evsel.h | 2 +- tools/perf/util/python-ext-sources | 1 - tools/perf/util/stat.h | 1 - tools/perf/util/xyarray.h | 35 ----------------------- 10 files changed, 71 insertions(+), 41 deletions(-) create mode 100644 tools/perf/lib/include/internal/xyarray.h create mode 100644 tools/perf/lib/xyarray.c delete mode 100644 tools/perf/util/xyarray.h
tools/perf/builtin-top.c +0 -1
@@ -38,7 +38,6 @@#include <subcmd/parse-options.h> #include "util/parse-events.h" #include "util/cpumap.h" -#include "util/xyarray.h" #include "util/sort.h" #include "util/string2.h" #include "util/term.h"
tools/perf/lib/Build +1 -0
@@ -4,6 +4,7 @@ libperf-y += threadmap.o libperf-y += evsel.o libperf-y += evlist.o libperf-y += zalloc.o +libperf-y += xyarray.o $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE $(call rule_mkdir)
tools/perf/lib/include/internal/xyarray.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_INTERNAL_XYARRAY_H +#define __LIBPERF_INTERNAL_XYARRAY_H + +#include <sys/types.h> + +struct xyarray { +size_t row_size; +size_t entry_size; +size_t entries; +size_t max_x; +size_t max_y; +char contents[]; +}; + +struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size); +void xyarray__delete (struct xyarray *xy); +void xyarray__reset (struct xyarray *xy); + +static inline void *xyarray__entry (struct xyarray *xy,int x,int y) +{ +return &xy->contents[x * xy->row_size + y * xy->entry_size]; +} + +static inline int xyarray__max_y (struct xyarray *xy) +{ +return xy->max_y; +} + +static inline int xyarray__max_x (struct xyarray *xy) +{ +return xy->max_x; +} + +#endif /* __LIBPERF_INTERNAL_XYARRAY_H */
tools/perf/lib/xyarray.c new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <internal/xyarray.h> +#include <linux/zalloc.h> +#include <stdlib.h> +#include <string.h> + +struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size) +{ +size_t row_size = ylen * entry_size; +struct xyarray *xy =zalloc (sizeof (*xy) + xlen * row_size); + +if (xy !=NULL ) { + xy->entry_size = entry_size; + xy->row_size = row_size; + xy->entries = xlen * ylen; + xy->max_x = xlen; + xy->max_y = ylen; + } + +return xy; +} + +void xyarray__reset (struct xyarray *xy) +{ +size_t n = xy->entries * xy->entry_size; + +memset (xy->contents,0 , n); +} + +void xyarray__delete (struct xyarray *xy) +{ +free (xy); +}
tools/perf/util/Build +0 -1
@@ -69,7 +69,6 @@ perf-y += svghelper.o perf-y += sort.o perf-y += hist.o perf-y += util.o -perf-y += xyarray.o perf-y += cpumap.o perf-y += cputopo.o perf-y += cgroup.o
tools/perf/util/counts.h +1 -1
@@ -2,7 +2,7 @@ #ifndef __PERF_COUNTS_H #define __PERF_COUNTS_H -#include "xyarray.h" +#include <internal/xyarray.h> struct perf_counts_values { union {
tools/perf/util/evsel.h +1 -1
@@ -8,7 +8,7 @@#include <linux/perf_event.h> #include <linux/types.h> #include <internal/evsel.h> -#include "xyarray.h" +#include <internal/xyarray.h> #include "symbol_conf.h" #include "cpumap.h" #include "counts.h"
tools/perf/util/python-ext-sources +0 -1
@@ -20,7 +20,6 @@ util/namespaces.c ../lib/vsprintf.c util/thread_map.c util/util.c -util/xyarray.c util/cgroup.c util/parse-branch-options.c util/rblist.c
tools/perf/util/stat.h +0 -1
@@ -8,7 +8,6 @@#include <sys/time.h> #include <sys/resource.h> #include <sys/wait.h> -#include "xyarray.h" #include "rblist.h" #include "perf.h" #include "event.h"
tools/perf/util/xyarray.h deleted +0 -35
@@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _PERF_XYARRAY_H_ -#define _PERF_XYARRAY_H_ 1 - -#include <sys/types.h> - -struct xyarray { -size_t row_size; -size_t entry_size; -size_t entries; -size_t max_x; -size_t max_y; -char contents[]; -}; - -struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size); -void xyarray__delete (struct xyarray *xy); -void xyarray__reset (struct xyarray *xy); - -static inline void *xyarray__entry (struct xyarray *xy,int x,int y) -{ -return &xy->contents[x * xy->row_size + y * xy->entry_size]; -} - -static inline int xyarray__max_y (struct xyarray *xy) -{ -return xy->max_y; -} - -static inline int xyarray__max_x (struct xyarray *xy) -{ -return xy->max_x; -} - -#endif /* _PERF_XYARRAY_H_ */
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt xyarray class from perf
libperf: Adopt xyarray class from perf
Commit-ID: 4b247fa7314ce48282f3da400a9ffb7f3fd3f863 Gitweb: https://git.kernel.org/tip/4b247fa7314ce48282f3da400a9ffb7f3fd3f863 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:44 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:45 -0300
libperf: Adopt xyarray class from perf
Move the xyarray class from perf to libperf, because it's going to be used in both.
---
tools/perf/builtin-top.c | 1 -
tools/perf/lib/Build | 1 +
tools/perf/{util => lib/include/internal}/xyarray.h | 6 +++---
tools/perf/{util => lib}/xyarray.c | 4 ++--
tools/perf/util/Build | 1 -
tools/perf/util/counts.h | 2 +-
tools/perf/util/evsel.h | 2 +-
tools/perf/util/python-ext-sources | 1 -
tools/perf/util/stat.h | 1 -
9 files changed, 8 insertions(+), 11 deletions(-)tools/perf/builtin-top.c +0 -1
@@ -38,7 +38,6 @@#include <subcmd/parse-options.h> #include "util/parse-events.h" #include "util/cpumap.h" -#include "util/xyarray.h" #include "util/sort.h" #include "util/string2.h" #include "util/term.h"
tools/perf/lib/Build +1 -0
@@ -4,6 +4,7 @@ libperf-y += threadmap.o libperf-y += evsel.o libperf-y += evlist.o libperf-y += zalloc.o +libperf-y += xyarray.o $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE $(call rule_mkdir)
tools/perf/lib/include/internal/xyarray.h renamed from tools/perf/util/xyarray.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _PERF_XYARRAY_H_ -#define _PERF_XYARRAY_H_ 1 +#ifndef __LIBPERF_INTERNAL_XYARRAY_H +#define __LIBPERF_INTERNAL_XYARRAY_H#include <sys/types.h>
@@ -32,4 +32,4 @@ static inline int xyarray__max_x(struct xyarray *xy) return xy->max_x; } -#endif /* _PERF_XYARRAY_H_ */ +#endif /* __LIBPERF_INTERNAL_XYARRAY_H */
tools/perf/lib/xyarray.c renamed from tools/perf/util/xyarray.c +2 -2
@@ -1,8 +1,8 @@// SPDX-License-Identifier: GPL-2.0 -#include "xyarray.h" +#include <internal/xyarray.h> +#include <linux/zalloc.h> #include <stdlib.h> #include <string.h> -#include <linux/zalloc.h> struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size) {
tools/perf/util/Build +0 -1
@@ -69,7 +69,6 @@ perf-y += svghelper.o perf-y += sort.o perf-y += hist.o perf-y += util.o -perf-y += xyarray.o perf-y += cpumap.o perf-y += cputopo.o perf-y += cgroup.o
tools/perf/util/counts.h +1 -1
@@ -2,7 +2,7 @@ #ifndef __PERF_COUNTS_H #define __PERF_COUNTS_H -#include "xyarray.h" +#include <internal/xyarray.h> struct perf_counts_values { union {
tools/perf/util/evsel.h +1 -1
@@ -8,7 +8,7 @@#include <linux/perf_event.h> #include <linux/types.h> #include <internal/evsel.h> -#include "xyarray.h" +#include <internal/xyarray.h> #include "symbol_conf.h" #include "cpumap.h" #include "counts.h"
tools/perf/util/python-ext-sources +0 -1
@@ -20,7 +20,6 @@ util/namespaces.c ../lib/vsprintf.c util/thread_map.c util/util.c -util/xyarray.c util/cgroup.c util/parse-branch-options.c util/rblist.c
tools/perf/util/stat.h +0 -1
@@ -8,7 +8,6 @@#include <sys/time.h> #include <sys/resource.h> #include <sys/wait.h> -#include "xyarray.h" #include "rblist.h" #include "perf.h" #include "event.h"
Jiri Olsa
reviewerPATCH 58/79 libperf: Add fd array to struct perf_evsel
In reply to Jiri OlsaMoving fd array from evsel into perf_evsel struct.
--- tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/util/bpf-loader.c | 2 +- tools/perf/util/evlist.c | 10 ++++----- tools/perf/util/evsel.c | 30 ++++++++++++------------- tools/perf/util/evsel.h | 1 - 5 files changed, 22 insertions(+), 22 deletions(-)
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -14,6 +14,7 @@ struct perf_evsel {struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus;struct perf_thread_map *threads; + struct xyarray *fd; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/bpf-loader.c +1 -1
@@ -1403,7 +1403,7 @@ static int apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, struct evsel *evsel) { - struct xyarray *xy = evsel->fd; + struct xyarray *xy = evsel->core.fd;struct perf_event_attr *attr;unsigned int key, events;bool check_pass = false;
tools/perf/util/evlist.c +5 -5
@@ -40,7 +40,7 @@int sigqueue (pid_t pid,int sig,const union sigval value);#endif -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD (e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
@@ -321,7 +321,7 @@ void evlist__disable(struct evlist *evlist)struct evsel *pos;evlist__for_each_entry (evlist, pos) { -if (pos->disabled || !perf_evsel__is_group_leader (pos) || !pos->fd) +if (pos->disabled || !perf_evsel__is_group_leader (pos) || !pos->core.fd)continue ;evsel__disable (pos); }
@@ -334,7 +334,7 @@ void evlist__enable(struct evlist *evlist)struct evsel *pos;evlist__for_each_entry (evlist, pos) { -if (!perf_evsel__is_group_leader (pos) || !pos->fd) +if (!perf_evsel__is_group_leader (pos) || !pos->core.fd)continue ;evsel__enable (pos); }
@@ -353,7 +353,7 @@ static int perf_evlist__enable_event_cpu(struct evlist *evlist,int thread;int nr_threads =perf_evlist__nr_threads (evlist, evsel); -if (!evsel->fd) +if (!evsel->core.fd)return -EINVAL ;for (thread =0 ; thread < nr_threads; thread++) {
@@ -371,7 +371,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,int cpu;int nr_cpus =cpu_map__nr (evlist->core.cpus); -if (!evsel->fd) +if (!evsel->core.fd)return -EINVAL ;for (cpu =0 ; cpu < nr_cpus; cpu++) {
tools/perf/util/evsel.c +15 -15
@@ -90,7 +90,7 @@ int perf_evsel__object_config(size_t object_size,return 0 ; } -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD (e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))int __perf_evsel__sample_size (u64 sample_type) {
@@ -1155,9 +1155,9 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,static int perf_evsel__alloc_fd (struct evsel *evsel,int ncpus,int nthreads) { - evsel->fd =xyarray__new (ncpus, nthreads,sizeof (int )); + evsel->core.fd =xyarray__new (ncpus, nthreads,sizeof (int )); -if (evsel->fd) { +if (evsel->core.fd) {int cpu, thread;for (cpu =0 ; cpu < ncpus; cpu++) {for (thread =0 ; thread < nthreads; thread++) {
@@ -1166,7 +1166,7 @@ static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) } } -return evsel->fd !=NULL ?0 : -ENOMEM ; +return evsel->core.fd !=NULL ?0 : -ENOMEM ; } static int perf_evsel__run_ioctl(struct evsel *evsel,
@@ -1174,8 +1174,8 @@ static int perf_evsel__run_ioctl(struct evsel *evsel, {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->fd); thread++) { +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) {int fd =FD (evsel, cpu, thread), err =ioctl (fd, ioc, arg);
@@ -1283,8 +1283,8 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads)static void perf_evsel__free_fd (struct evsel *evsel) { -xyarray__delete (evsel->fd); - evsel->fd =NULL ; +xyarray__delete (evsel->core.fd); + evsel->core.fd =NULL ; }static void perf_evsel__free_id (struct evsel *evsel)
@@ -1309,8 +1309,8 @@ void perf_evsel__close_fd(struct evsel *evsel) {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) -for (thread =0 ; thread <xyarray__max_y (evsel->fd); ++thread) { +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); ++thread) {close (FD (evsel, cpu, thread));FD (evsel, cpu, thread) =-1 ; }
@@ -1555,7 +1555,7 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread)* Leader must be already processed/open, * if not it's a bug. */ -BUG_ON (!leader->fd); +BUG_ON (!leader->core.fd); fd =FD (leader, cpu, thread);BUG_ON (fd ==-1 );
@@ -1865,7 +1865,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,else nthreads = threads->nr; -if (evsel->fd ==NULL && +if (evsel->core.fd ==NULL &&perf_evsel__alloc_fd (evsel, cpus->nr, nthreads) <0 )return -ENOMEM ;
@@ -2075,7 +2075,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,void perf_evsel__close (struct evsel *evsel) { -if (evsel->fd ==NULL ) +if (evsel->core.fd ==NULL )return ;perf_evsel__close_fd (evsel);
@@ -3048,8 +3048,8 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist) {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->fd); +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) {int fd =FD (evsel, cpu, thread);
tools/perf/util/evsel.h +0 -1
@@ -104,7 +104,6 @@ struct evsel {struct perf_evsel core;struct evlist *evlist;char *filter; -struct xyarray *fd;struct xyarray *sample_id;u64 *id;struct perf_counts *counts;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Move fd array from perf's evsel to lobperf's perf_evsel class
libperf: Move fd array from perf's evsel to lobperf's perf_evsel class
Commit-ID: 9dfcb7599084382884fec6d0fd9ca33945fa7578 Gitweb: https://git.kernel.org/tip/9dfcb7599084382884fec6d0fd9ca33945fa7578 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:45 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Move fd array from perf's evsel to lobperf's perf_evsel class
Move the fd array from perf's evsel to libperf's perf_evsel class.
--- tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/util/bpf-loader.c | 2 +- tools/perf/util/evlist.c | 10 +++++----- tools/perf/util/evsel.c | 30 +++++++++++++++--------------- tools/perf/util/evsel.h | 1 - 5 files changed, 22 insertions(+), 22 deletions(-)
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -14,6 +14,7 @@ struct perf_evsel {struct perf_cpu_map *cpus;struct perf_cpu_map *own_cpus;struct perf_thread_map *threads; + struct xyarray *fd; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/bpf-loader.c +1 -1
@@ -1403,7 +1403,7 @@ static int apply_config_evsel_for_key(const char *name, int map_fd, void *pkey, struct evsel *evsel) { - struct xyarray *xy = evsel->fd; + struct xyarray *xy = evsel->core.fd;struct perf_event_attr *attr;unsigned int key, events;bool check_pass = false;
tools/perf/util/evlist.c +5 -5
@@ -40,7 +40,7 @@int sigqueue (pid_t pid,int sig,const union sigval value);#endif -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD (e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))#define SID (e, x, y) xyarray__entry(e->sample_id, x, y) void evlist__init(struct evlist *evlist, struct perf_cpu_map *cpus,
@@ -321,7 +321,7 @@ void evlist__disable(struct evlist *evlist)struct evsel *pos;evlist__for_each_entry (evlist, pos) { -if (pos->disabled || !perf_evsel__is_group_leader (pos) || !pos->fd) +if (pos->disabled || !perf_evsel__is_group_leader (pos) || !pos->core.fd)continue ;evsel__disable (pos); }
@@ -334,7 +334,7 @@ void evlist__enable(struct evlist *evlist)struct evsel *pos;evlist__for_each_entry (evlist, pos) { -if (!perf_evsel__is_group_leader (pos) || !pos->fd) +if (!perf_evsel__is_group_leader (pos) || !pos->core.fd)continue ;evsel__enable (pos); }
@@ -353,7 +353,7 @@ static int perf_evlist__enable_event_cpu(struct evlist *evlist,int thread;int nr_threads =perf_evlist__nr_threads (evlist, evsel); -if (!evsel->fd) +if (!evsel->core.fd)return -EINVAL ;for (thread =0 ; thread < nr_threads; thread++) {
@@ -371,7 +371,7 @@ static int perf_evlist__enable_event_thread(struct evlist *evlist,int cpu;int nr_cpus =cpu_map__nr (evlist->core.cpus); -if (!evsel->fd) +if (!evsel->core.fd)return -EINVAL ;for (cpu =0 ; cpu < nr_cpus; cpu++) {
tools/perf/util/evsel.c +15 -15
@@ -90,7 +90,7 @@ set_methods:return 0 ; } -#define FD (e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) +#define FD (e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y))int __perf_evsel__sample_size (u64 sample_type) {
@@ -1155,9 +1155,9 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,static int perf_evsel__alloc_fd (struct evsel *evsel,int ncpus,int nthreads) { - evsel->fd =xyarray__new (ncpus, nthreads,sizeof (int )); + evsel->core.fd =xyarray__new (ncpus, nthreads,sizeof (int )); -if (evsel->fd) { +if (evsel->core.fd) {int cpu, thread;for (cpu =0 ; cpu < ncpus; cpu++) {for (thread =0 ; thread < nthreads; thread++) {
@@ -1166,7 +1166,7 @@ static int perf_evsel__alloc_fd(struct evsel *evsel, int ncpus, int nthreads) } } -return evsel->fd !=NULL ?0 : -ENOMEM ; +return evsel->core.fd !=NULL ?0 : -ENOMEM ; } static int perf_evsel__run_ioctl(struct evsel *evsel,
@@ -1174,8 +1174,8 @@ static int perf_evsel__run_ioctl(struct evsel *evsel, {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->fd); thread++) { +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) {int fd =FD (evsel, cpu, thread), err =ioctl (fd, ioc, arg);
@@ -1283,8 +1283,8 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads)static void perf_evsel__free_fd (struct evsel *evsel) { -xyarray__delete (evsel->fd); - evsel->fd =NULL ; +xyarray__delete (evsel->core.fd); + evsel->core.fd =NULL ; }static void perf_evsel__free_id (struct evsel *evsel)
@@ -1309,8 +1309,8 @@ void perf_evsel__close_fd(struct evsel *evsel) {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) -for (thread =0 ; thread <xyarray__max_y (evsel->fd); ++thread) { +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); ++thread) {close (FD (evsel, cpu, thread));FD (evsel, cpu, thread) =-1 ; }
@@ -1555,7 +1555,7 @@ static int get_group_fd(struct evsel *evsel, int cpu, int thread)* Leader must be already processed/open, * if not it's a bug. */ -BUG_ON (!leader->fd); +BUG_ON (!leader->core.fd); fd =FD (leader, cpu, thread);BUG_ON (fd ==-1 );
@@ -1865,7 +1865,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,else nthreads = threads->nr; -if (evsel->fd ==NULL && +if (evsel->core.fd ==NULL &&perf_evsel__alloc_fd (evsel, cpus->nr, nthreads) <0 )return -ENOMEM ;
@@ -2075,7 +2075,7 @@ out_close:void perf_evsel__close (struct evsel *evsel) { -if (evsel->fd ==NULL ) +if (evsel->core.fd ==NULL )return ;perf_evsel__close_fd (evsel);
@@ -3048,8 +3048,8 @@ static int store_evsel_ids(struct evsel *evsel, struct evlist *evlist) {int cpu, thread; -for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->fd); +for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) {int fd =FD (evsel, cpu, thread);
tools/perf/util/evsel.h +0 -1
@@ -104,7 +104,6 @@ struct evsel {struct perf_evsel core;struct evlist *evlist;char *filter; -struct xyarray *fd;struct xyarray *sample_id;u64 *id;struct perf_counts *counts;
Jiri Olsa
reviewerPATCH 59/79 libperf: Add nr_members to struct perf_evsel
In reply to Jiri OlsaMoving nr_members from evsel into perf_evsel struct.
--- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/lib/include/internal/evsel.h | 3 +++ tools/perf/tests/parse-events.c | 22 +++++++++++----------- tools/perf/ui/gtk/annotate.c | 2 +- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 6 +++--- tools/perf/util/annotate.c | 8 ++++---- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 6 +++--- tools/perf/util/evsel.h | 3 +-- tools/perf/util/evsel_fprintf.c | 4 ++-- tools/perf/util/header.c | 12 ++++++------ tools/perf/util/hist.c | 2 +- tools/perf/util/parse-events.c | 2 +- tools/perf/util/stat-display.c | 2 +- tools/perf/util/stat.c | 2 +- 18 files changed, 45 insertions(+), 43 deletions(-)
tools/perf/builtin-report.c +1 -1
@@ -436,7 +436,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report ret =fprintf (fp,"# Samples: %lu%c" , nr_samples, unit);if (evname !=NULL ) { ret +=fprintf (fp," of event%s '%s'" , - evsel->nr_members >1 ?"s" :"" , evname); + evsel->core.nr_members >1 ?"s" :"" , evname); }if (rep->time_str)
tools/perf/builtin-script.c +1 -1
@@ -1734,7 +1734,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, sample->cpu, &rt_stat);evsel_script (evsel)->val = val; -if (evsel_script (evsel->leader)->gnum == evsel->leader->nr_members) { +if (evsel_script (evsel->leader)->gnum == evsel->leader->core.nr_members) { for_each_group_member (ev2, evsel->leader) { perf_stat__print_shadow_stats(&stat_config, ev2, evsel_script(ev2)->val,
tools/perf/builtin-stat.c +1 -1
@@ -479,7 +479,7 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) counter->supported = false;if ((counter->leader != counter) || - !(counter->leader->nr_members >1 )) + !(counter->leader->core.nr_members >1 ))continue ; }else if (perf_evsel__fallback (counter, errno, msg,sizeof (msg))) {if (verbose >0 )
tools/perf/lib/include/internal/evsel.h +3 -0
@@ -15,6 +15,9 @@ struct perf_evsel {struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;struct xyarray *fd; + +/* parse modifier helper */ + int nr_members; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/tests/parse-events.c +11 -11
@@ -653,7 +653,7 @@ static int test__group1(struct evlist *evlist)TEST_ASSERT_VAL ("wrong exclude host" , !evsel->core.attr.exclude_host);TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -695,7 +695,7 @@ static int test__group2(struct evlist *evlist)TEST_ASSERT_VAL ("wrong exclude host" , !evsel->core.attr.exclude_host);TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -753,7 +753,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel));TEST_ASSERT_VAL ("wrong group name" , !strcmp (leader->group_name,"group1" )); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -788,7 +788,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel));TEST_ASSERT_VAL ("wrong group name" , !strcmp (leader->group_name,"group2" )); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -844,7 +844,7 @@ static int test__group4(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , evsel->core.attr.precise_ip ==1 );TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -887,7 +887,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -919,7 +919,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -973,7 +973,7 @@ static int test__group_gh1(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:G + :H group modifier */
@@ -1013,7 +1013,7 @@ static int test__group_gh2(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :G group modifier */
@@ -1053,7 +1053,7 @@ static int test__group_gh3(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :u group modifier */
@@ -1093,7 +1093,7 @@ static int test__group_gh4(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :uG group modifier */
tools/perf/ui/gtk/annotate.c +1 -1
@@ -129,7 +129,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,gtk_list_store_append (store, &iter);if (perf_evsel__is_group_event (evsel)) { -for (i =0 ; i < evsel->nr_members; i++) { +for (i =0 ; i < evsel->core.nr_members; i++) { ret += perf_gtk__get_percent(s + ret, sizeof(s) - ret, sym, pos,
tools/perf/ui/gtk/hists.c +1 -1
@@ -645,7 +645,7 @@ int perf_evlist__gtk_browse_hists(struct evlist *evlist,if (!perf_evsel__is_group_leader (pos))continue ; -if (pos->nr_members >1 ) { +if (pos->core.nr_members >1 ) {perf_evsel__group_desc (pos, buf, size); evname = buf; }
tools/perf/ui/hist.c +3 -3
@@ -43,7 +43,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta;struct hist_entry *pair; -int nr_members = evsel->nr_members; +int nr_members = evsel->core.nr_members; prev_idx =perf_evsel__group_idx (evsel);
@@ -165,7 +165,7 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,if (!perf_evsel__is_group_event (evsel))return ret; - nr_members = evsel->nr_members; + nr_members = evsel->core.nr_members; fields_a =calloc (nr_members,sizeof (*fields_a)); fields_b =calloc (nr_members,sizeof (*fields_b));
@@ -226,7 +226,7 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt,struct evsel *evsel =hists_to_evsel (hists);if (symbol_conf.event_group) - len =max (len, evsel->nr_members * fmt->len); + len =max (len, evsel->core.nr_members * fmt->len);if (len < (int )strlen (fmt->name)) len =strlen (fmt->name);
tools/perf/util/annotate.c +4 -4
@@ -1170,7 +1170,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize)int nr =1 ;if (perf_evsel__is_group_event (evsel)) - nr = evsel->nr_members; + nr = evsel->core.nr_members; size +=sizeof (al->data[0 ]) * nr;
@@ -1448,7 +1448,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 startreturn -1 ;if (perf_evsel__is_group_event (evsel)) - width *= evsel->nr_members; + width *= evsel->core.nr_members;if (!*al->line)printf (" %*s:\n" , width," " );
@@ -2272,7 +2272,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, len =symbol__size (sym);if (perf_evsel__is_group_event (evsel)) { - width *= evsel->nr_members; + width *= evsel->core.nr_members;perf_evsel__group_desc (evsel, buf,sizeof (buf)); evsel_name = buf; }
@@ -2968,7 +2968,7 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct evsel *evsel,return -1 ;if (perf_evsel__is_group_event (evsel)) - nr_pcnt = evsel->nr_members; + nr_pcnt = evsel->core.nr_members; err =symbol__annotate (sym, map, evsel,0 , options, parch);if (err)
tools/perf/util/evlist.c +3 -3
@@ -188,7 +188,7 @@ void __perf_evlist__set_leader(struct list_head *list) leader = list_entry(list->next, struct evsel, core.node); evsel = list_entry(list->prev, struct evsel, core.node); - leader->nr_members = evsel->idx - leader->idx +1 ; + leader->core.nr_members = evsel->idx - leader->idx +1 ;__evlist__for_each_entry (list, evsel) { evsel->leader = leader;
@@ -1761,7 +1761,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, leader = evsel->leader;pr_debug ("Weak group for %s/%d failed\n" , - leader->name, leader->nr_members); + leader->name, leader->core.nr_members);/* * for_each_group_member doesn't work here because it doesn't
@@ -1774,7 +1774,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,if (is_open)perf_evsel__close (c2); c2->leader = c2; - c2->nr_members =0 ; + c2->core.nr_members =0 ; } }return leader;
tools/perf/util/evsel.c +3 -3
@@ -948,7 +948,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,* Apply group format only if we belong to group * with more than one members. */ -if (leader->nr_members >1 ) { +if (leader->core.nr_members >1 ) { attr->read_format |=PERF_FORMAT_GROUP ; attr->inherit =0 ; }
@@ -1396,7 +1396,7 @@ static int perf_evsel__read_size(struct evsel *evsel) entry +=sizeof (u64);if (read_format &PERF_FORMAT_GROUP ) { - nr = evsel->nr_members; + nr = evsel->core.nr_members; size +=sizeof (u64); }
@@ -1453,7 +1453,7 @@ perf_evsel__process_group_data(struct evsel *leader, nr = *data++; -if (nr != (u64 ) leader->nr_members) +if (nr != (u64 ) leader->core.nr_members)return -EINVAL ;if (read_format &PERF_FORMAT_TOTAL_TIME_ENABLED )
tools/perf/util/evsel.h +1 -2
@@ -142,7 +142,6 @@ struct evsel {bool use_uncore_alias;/* parse modifier helper */ int exclude_GH; -int nr_members;int sample_read;unsigned long *per_pkg_mask;struct evsel *leader;
@@ -414,7 +413,7 @@ static inline bool perf_evsel__is_group_event(struct evsel *evsel)if (!symbol_conf.event_group)return false; -return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; +return perf_evsel__is_group_leader (evsel) && evsel->core.nr_members >1 ; }bool perf_evsel__is_function_event (struct evsel *evsel);
tools/perf/util/evsel_fprintf.c +2 -2
@@ -45,14 +45,14 @@ int perf_evsel__fprintf(struct evsel *evsel,if (!perf_evsel__is_group_leader (evsel))return 0 ; -if (evsel->nr_members >1 ) +if (evsel->core.nr_members >1 ) printed +=fprintf (fp,"%s{" , evsel->group_name ?:"" ); printed +=fprintf (fp,"%s" ,perf_evsel__name (evsel));for_each_group_member (pos, evsel) printed +=fprintf (fp,",%s" ,perf_evsel__name (pos)); -if (evsel->nr_members >1 ) +if (evsel->core.nr_members >1 ) printed +=fprintf (fp,"}" ); goto out; }
tools/perf/util/header.c +6 -6
@@ -772,10 +772,10 @@ static int write_group_desc(struct feat_fd *ff,evlist__for_each_entry (evlist, evsel) {if (perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { + evsel->core.nr_members >1 ) {const char *name = evsel->group_name ?:"{anon_group}" ;u32 leader_idx = evsel->idx; -u32 nr_members = evsel->nr_members; +u32 nr_members = evsel->core.nr_members; ret =do_write_string (ff, name);if (ret <0 )
@@ -1812,11 +1812,11 @@ static void print_group_desc(struct feat_fd *ff, FILE *fp)evlist__for_each_entry (session->evlist, evsel) {if (perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { + evsel->core.nr_members >1 ) {fprintf (fp,"# group: %s{%s" , evsel->group_name ?:"" ,perf_evsel__name (evsel)); - nr = evsel->nr_members -1 ; + nr = evsel->core.nr_members -1 ; }else if (nr) {fprintf (fp,",%s" ,perf_evsel__name (evsel));
@@ -2463,7 +2463,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) evsel->group_name = desc[i].name; desc[i].name =NULL ; } - evsel->nr_members = desc[i].nr_members; + evsel->core.nr_members = desc[i].nr_members;if (i >= nr_groups || nr >0 ) {pr_debug ("invalid group desc\n" );
@@ -2471,7 +2471,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) } leader = evsel; - nr = evsel->nr_members -1 ; + nr = evsel->core.nr_members -1 ; i++; }else if (nr) {/* This is a group member */
tools/perf/util/hist.c +1 -1
@@ -2643,7 +2643,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool sh nr_samples =convert_unit (nr_samples, &unit); printed =scnprintf (bf, size,"Samples: %lu%c of event%s '%s',%s%sEvent count (approx.): %" PRIu64, - nr_samples, unit, evsel->nr_members >1 ?"s" :"" , + nr_samples, unit, evsel->core.nr_members >1 ?"s" :"" , ev_name, sample_freq_str, enable_ref ? ref :" " , nr_events);
tools/perf/util/parse-events.c +1 -1
@@ -1528,7 +1528,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,/* The number of members and group name are same for each group */ for (i =0 ; i < nr_pmu; i++) { evsel = (struct evsel *) leaders[i]; - evsel->nr_members = total_members / nr_pmu; + evsel->core.nr_members = total_members / nr_pmu; evsel->group_name = name ?strdup (name) :NULL ; }
tools/perf/util/stat-display.c +1 -1
@@ -369,7 +369,7 @@ static bool is_mixed_hw_group(struct evsel *counter)u32 pmu_type = counter->core.attr.type;struct evsel *pos; -if (counter->nr_members <2 ) +if (counter->core.nr_members <2 )return false;evlist__for_each_entry (evlist, pos) {
tools/perf/util/stat.c +1 -1
@@ -452,7 +452,7 @@ int create_perf_stat_counter(struct evsel *evsel,* the group read (for leader) and ID retrieval for all * members. */ -if (leader->nr_members >1 ) +if (leader->core.nr_members >1 ) attr->read_format |=PERF_FORMAT_ID |PERF_FORMAT_GROUP ; attr->inherit = !config->no_inherit;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Move nr_members from perf's evsel to libperf's perf_evsel
libperf: Move nr_members from perf's evsel to libperf's perf_evsel
Commit-ID: 5643b1a59e581ac3f66d36caba8124313cc446c0 Gitweb: https://git.kernel.org/tip/5643b1a59e581ac3f66d36caba8124313cc446c0 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:46 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Move nr_members from perf's evsel to libperf's perf_evsel
Move the nr_members member from perf's evsel to libperf's perf_evsel.
--- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/lib/include/internal/evsel.h | 3 +++ tools/perf/tests/parse-events.c | 22 +++++++++++----------- tools/perf/ui/gtk/annotate.c | 2 +- tools/perf/ui/gtk/hists.c | 2 +- tools/perf/ui/hist.c | 6 +++--- tools/perf/util/annotate.c | 8 ++++---- tools/perf/util/evlist.c | 6 +++--- tools/perf/util/evsel.c | 6 +++--- tools/perf/util/evsel.h | 3 +-- tools/perf/util/evsel_fprintf.c | 4 ++-- tools/perf/util/header.c | 12 ++++++------ tools/perf/util/hist.c | 2 +- tools/perf/util/parse-events.c | 2 +- tools/perf/util/stat-display.c | 2 +- tools/perf/util/stat.c | 2 +- 18 files changed, 45 insertions(+), 43 deletions(-)
tools/perf/builtin-report.c +1 -1
@@ -436,7 +436,7 @@ static size_t hists__fprintf_nr_sample_events(struct hists *hists, struct report ret =fprintf (fp,"# Samples: %lu%c" , nr_samples, unit);if (evname !=NULL ) { ret +=fprintf (fp," of event%s '%s'" , - evsel->nr_members >1 ?"s" :"" , evname); + evsel->core.nr_members >1 ?"s" :"" , evname); }if (rep->time_str)
tools/perf/builtin-script.c +1 -1
@@ -1734,7 +1734,7 @@ static void perf_sample__fprint_metric(struct perf_script *script, sample->cpu, &rt_stat);evsel_script (evsel)->val = val; -if (evsel_script (evsel->leader)->gnum == evsel->leader->nr_members) { +if (evsel_script (evsel->leader)->gnum == evsel->leader->core.nr_members) { for_each_group_member (ev2, evsel->leader) { perf_stat__print_shadow_stats(&stat_config, ev2, evsel_script(ev2)->val,
tools/perf/builtin-stat.c +1 -1
@@ -479,7 +479,7 @@ try_again: counter->supported = false;if ((counter->leader != counter) || - !(counter->leader->nr_members >1 )) + !(counter->leader->core.nr_members >1 ))continue ; }else if (perf_evsel__fallback (counter, errno, msg,sizeof (msg))) {if (verbose >0 )
tools/perf/lib/include/internal/evsel.h +3 -0
@@ -15,6 +15,9 @@ struct perf_evsel {struct perf_cpu_map *own_cpus;struct perf_thread_map *threads;struct xyarray *fd; + +/* parse modifier helper */ + int nr_members; };#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/tests/parse-events.c +11 -11
@@ -653,7 +653,7 @@ static int test__group1(struct evlist *evlist)TEST_ASSERT_VAL ("wrong exclude host" , !evsel->core.attr.exclude_host);TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -695,7 +695,7 @@ static int test__group2(struct evlist *evlist)TEST_ASSERT_VAL ("wrong exclude host" , !evsel->core.attr.exclude_host);TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -753,7 +753,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel));TEST_ASSERT_VAL ("wrong group name" , !strcmp (leader->group_name,"group1" )); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -788,7 +788,7 @@ static int test__group3(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel));TEST_ASSERT_VAL ("wrong group name" , !strcmp (leader->group_name,"group2" )); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -844,7 +844,7 @@ static int test__group4(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , evsel->core.attr.precise_ip ==1 );TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -887,7 +887,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -919,7 +919,7 @@ static int test__group5(struct evlist *evlist __maybe_unused)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );TEST_ASSERT_VAL ("wrong sample_read" , !evsel->sample_read);
@@ -973,7 +973,7 @@ static int test__group_gh1(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:G + :H group modifier */
@@ -1013,7 +1013,7 @@ static int test__group_gh2(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :G group modifier */
@@ -1053,7 +1053,7 @@ static int test__group_gh3(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :u group modifier */
@@ -1093,7 +1093,7 @@ static int test__group_gh4(struct evlist *evlist)TEST_ASSERT_VAL ("wrong precise_ip" , !evsel->core.attr.precise_ip);TEST_ASSERT_VAL ("wrong group name" , !evsel->group_name);TEST_ASSERT_VAL ("wrong leader" ,perf_evsel__is_group_leader (evsel)); -TEST_ASSERT_VAL ("wrong nr_members" , evsel->nr_members ==2 ); +TEST_ASSERT_VAL ("wrong core.nr_members" , evsel->core.nr_members ==2 );TEST_ASSERT_VAL ("wrong group_idx" ,perf_evsel__group_idx (evsel) ==0 );/* cache-misses:H + :uG group modifier */
tools/perf/ui/gtk/annotate.c +1 -1
@@ -129,7 +129,7 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct symbol *sym,gtk_list_store_append (store, &iter);if (perf_evsel__is_group_event (evsel)) { -for (i =0 ; i < evsel->nr_members; i++) { +for (i =0 ; i < evsel->core.nr_members; i++) { ret += perf_gtk__get_percent(s + ret, sizeof(s) - ret, sym, pos,
tools/perf/ui/gtk/hists.c +1 -1
@@ -645,7 +645,7 @@ int perf_evlist__gtk_browse_hists(struct evlist *evlist,if (!perf_evsel__is_group_leader (pos))continue ; -if (pos->nr_members >1 ) { +if (pos->core.nr_members >1 ) {perf_evsel__group_desc (pos, buf, size); evname = buf; }
tools/perf/ui/hist.c +3 -3
@@ -43,7 +43,7 @@ static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,if (perf_evsel__is_group_event (evsel)) {int prev_idx, idx_delta;struct hist_entry *pair; -int nr_members = evsel->nr_members; +int nr_members = evsel->core.nr_members; prev_idx =perf_evsel__group_idx (evsel);
@@ -165,7 +165,7 @@ static int __hpp__sort(struct hist_entry *a, struct hist_entry *b,if (!perf_evsel__is_group_event (evsel))return ret; - nr_members = evsel->nr_members; + nr_members = evsel->core.nr_members; fields_a =calloc (nr_members,sizeof (*fields_a)); fields_b =calloc (nr_members,sizeof (*fields_b));
@@ -226,7 +226,7 @@ static int hpp__width_fn(struct perf_hpp_fmt *fmt,struct evsel *evsel =hists_to_evsel (hists);if (symbol_conf.event_group) - len =max (len, evsel->nr_members * fmt->len); + len =max (len, evsel->core.nr_members * fmt->len);if (len < (int )strlen (fmt->name)) len =strlen (fmt->name);
tools/perf/util/annotate.c +4 -4
@@ -1170,7 +1170,7 @@ annotation_line__new(struct annotate_args *args, size_t privsize)int nr =1 ;if (perf_evsel__is_group_event (evsel)) - nr = evsel->nr_members; + nr = evsel->core.nr_members; size +=sizeof (al->data[0 ]) * nr;
@@ -1448,7 +1448,7 @@ annotation_line__print(struct annotation_line *al, struct symbol *sym, u64 startreturn -1 ;if (perf_evsel__is_group_event (evsel)) - width *= evsel->nr_members; + width *= evsel->core.nr_members;if (!*al->line)printf (" %*s:\n" , width," " );
@@ -2272,7 +2272,7 @@ int symbol__annotate_printf(struct symbol *sym, struct map *map, len =symbol__size (sym);if (perf_evsel__is_group_event (evsel)) { - width *= evsel->nr_members; + width *= evsel->core.nr_members;perf_evsel__group_desc (evsel, buf,sizeof (buf)); evsel_name = buf; }
@@ -2968,7 +2968,7 @@ int symbol__annotate2(struct symbol *sym, struct map *map, struct evsel *evsel,return -1 ;if (perf_evsel__is_group_event (evsel)) - nr_pcnt = evsel->nr_members; + nr_pcnt = evsel->core.nr_members; err =symbol__annotate (sym, map, evsel,0 , options, parch);if (err)
tools/perf/util/evlist.c +3 -3
@@ -188,7 +188,7 @@ void __perf_evlist__set_leader(struct list_head *list) leader = list_entry(list->next, struct evsel, core.node); evsel = list_entry(list->prev, struct evsel, core.node); - leader->nr_members = evsel->idx - leader->idx +1 ; + leader->core.nr_members = evsel->idx - leader->idx +1 ;__evlist__for_each_entry (list, evsel) { evsel->leader = leader;
@@ -1761,7 +1761,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, leader = evsel->leader;pr_debug ("Weak group for %s/%d failed\n" , - leader->name, leader->nr_members); + leader->name, leader->core.nr_members);/* * for_each_group_member doesn't work here because it doesn't
@@ -1774,7 +1774,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,if (is_open)perf_evsel__close (c2); c2->leader = c2; - c2->nr_members =0 ; + c2->core.nr_members =0 ; } }return leader;
tools/perf/util/evsel.c +3 -3
@@ -948,7 +948,7 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,* Apply group format only if we belong to group * with more than one members. */ -if (leader->nr_members >1 ) { +if (leader->core.nr_members >1 ) { attr->read_format |=PERF_FORMAT_GROUP ; attr->inherit =0 ; }
@@ -1396,7 +1396,7 @@ static int perf_evsel__read_size(struct evsel *evsel) entry +=sizeof (u64);if (read_format &PERF_FORMAT_GROUP ) { - nr = evsel->nr_members; + nr = evsel->core.nr_members; size +=sizeof (u64); }
@@ -1453,7 +1453,7 @@ perf_evsel__process_group_data(struct evsel *leader, nr = *data++; -if (nr != (u64 ) leader->nr_members) +if (nr != (u64 ) leader->core.nr_members)return -EINVAL ;if (read_format &PERF_FORMAT_TOTAL_TIME_ENABLED )
tools/perf/util/evsel.h +1 -2
@@ -142,7 +142,6 @@ struct evsel {bool use_uncore_alias;/* parse modifier helper */ int exclude_GH; -int nr_members;int sample_read;unsigned long *per_pkg_mask;struct evsel *leader;
@@ -414,7 +413,7 @@ static inline bool perf_evsel__is_group_event(struct evsel *evsel)if (!symbol_conf.event_group)return false; -return perf_evsel__is_group_leader (evsel) && evsel->nr_members >1 ; +return perf_evsel__is_group_leader (evsel) && evsel->core.nr_members >1 ; }bool perf_evsel__is_function_event (struct evsel *evsel);
tools/perf/util/evsel_fprintf.c +2 -2
@@ -45,14 +45,14 @@ int perf_evsel__fprintf(struct evsel *evsel,if (!perf_evsel__is_group_leader (evsel))return 0 ; -if (evsel->nr_members >1 ) +if (evsel->core.nr_members >1 ) printed +=fprintf (fp,"%s{" , evsel->group_name ?:"" ); printed +=fprintf (fp,"%s" ,perf_evsel__name (evsel));for_each_group_member (pos, evsel) printed +=fprintf (fp,",%s" ,perf_evsel__name (pos)); -if (evsel->nr_members >1 ) +if (evsel->core.nr_members >1 ) printed +=fprintf (fp,"}" ); goto out; }
tools/perf/util/header.c +6 -6
@@ -772,10 +772,10 @@ static int write_group_desc(struct feat_fd *ff,evlist__for_each_entry (evlist, evsel) {if (perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { + evsel->core.nr_members >1 ) {const char *name = evsel->group_name ?:"{anon_group}" ;u32 leader_idx = evsel->idx; -u32 nr_members = evsel->nr_members; +u32 nr_members = evsel->core.nr_members; ret =do_write_string (ff, name);if (ret <0 )
@@ -1812,11 +1812,11 @@ static void print_group_desc(struct feat_fd *ff, FILE *fp)evlist__for_each_entry (session->evlist, evsel) {if (perf_evsel__is_group_leader (evsel) && - evsel->nr_members >1 ) { + evsel->core.nr_members >1 ) {fprintf (fp,"# group: %s{%s" , evsel->group_name ?:"" ,perf_evsel__name (evsel)); - nr = evsel->nr_members -1 ; + nr = evsel->core.nr_members -1 ; }else if (nr) {fprintf (fp,",%s" ,perf_evsel__name (evsel));
@@ -2463,7 +2463,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) evsel->group_name = desc[i].name; desc[i].name =NULL ; } - evsel->nr_members = desc[i].nr_members; + evsel->core.nr_members = desc[i].nr_members;if (i >= nr_groups || nr >0 ) {pr_debug ("invalid group desc\n" );
@@ -2471,7 +2471,7 @@ static int process_group_desc(struct feat_fd *ff, void *data __maybe_unused) } leader = evsel; - nr = evsel->nr_members -1 ; + nr = evsel->core.nr_members -1 ; i++; }else if (nr) {/* This is a group member */
tools/perf/util/hist.c +1 -1
@@ -2643,7 +2643,7 @@ int __hists__scnprintf_title(struct hists *hists, char *bf, size_t size, bool sh nr_samples =convert_unit (nr_samples, &unit); printed =scnprintf (bf, size,"Samples: %lu%c of event%s '%s',%s%sEvent count (approx.): %" PRIu64, - nr_samples, unit, evsel->nr_members >1 ?"s" :"" , + nr_samples, unit, evsel->core.nr_members >1 ?"s" :"" , ev_name, sample_freq_str, enable_ref ? ref :" " , nr_events);
tools/perf/util/parse-events.c +1 -1
@@ -1528,7 +1528,7 @@ parse_events__set_leader_for_uncore_aliase(char *name, struct list_head *list,/* The number of members and group name are same for each group */ for (i =0 ; i < nr_pmu; i++) { evsel = (struct evsel *) leaders[i]; - evsel->nr_members = total_members / nr_pmu; + evsel->core.nr_members = total_members / nr_pmu; evsel->group_name = name ?strdup (name) :NULL ; }
tools/perf/util/stat-display.c +1 -1
@@ -369,7 +369,7 @@ static bool is_mixed_hw_group(struct evsel *counter)u32 pmu_type = counter->core.attr.type;struct evsel *pos; -if (counter->nr_members <2 ) +if (counter->core.nr_members <2 )return false;evlist__for_each_entry (evlist, pos) {
tools/perf/util/stat.c +1 -1
@@ -452,7 +452,7 @@ int create_perf_stat_counter(struct evsel *evsel,* the group read (for leader) and ID retrieval for all * members. */ -if (leader->nr_members >1 ) +if (leader->core.nr_members >1 ) attr->read_format |=PERF_FORMAT_ID |PERF_FORMAT_GROUP ; attr->inherit = !config->no_inherit;
Jiri Olsa
reviewerPATCH 60/79 libperf: Add readn/writen function
In reply to Jiri OlsaMoving readn/writen functions into libperf. Keeping the name because they will be shared only between perf and libperf.
These are not exported functions.
--- tools/perf/lib/Build | 1 + tools/perf/lib/include/internal/lib.h | 10 ++++++ tools/perf/lib/lib.c | 46 +++++++++++++++++++++++++++ tools/perf/util/util.c | 40 ----------------------- tools/perf/util/util.h | 4 +-- 5 files changed, 58 insertions(+), 43 deletions(-) create mode 100644 tools/perf/lib/include/internal/lib.h create mode 100644 tools/perf/lib/lib.c
tools/perf/lib/Build +1 -0
@@ -5,6 +5,7 @@ libperf-y += evsel.o libperf-y += evlist.o libperf-y += zalloc.o libperf-y += xyarray.o +libperf-y += lib.o $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE $(call rule_mkdir)
tools/perf/lib/include/internal/lib.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_INTERNAL_LIB_H +#define __LIBPERF_INTERNAL_LIB_H + +#include <unistd.h> + +ssize_t readn (int fd,void *buf,size_t n); +ssize_t writen (int fd,const void *buf,size_t n); + +#endif /* __LIBPERF_INTERNAL_CPUMAP_H */
tools/perf/lib/lib.c new file +46 -0
46 lines not on this page · raw message
tools/perf/util/util.c +0 -40
@@ -384,46 +384,6 @@ int copyfile(const char *from, const char *to)return copyfile_mode (from, to,0755 ); } -static ssize_t ion (bool is_read,int fd,void *buf,size_t n) -{ -void *buf_start = buf; -size_t left = n; - -while (left) { -/* buf must be treated as const if !is_read. */ -ssize_t ret = is_read ?read (fd, buf, left) : -write (fd, buf, left); - -if (ret <0 && errno ==EINTR ) -continue ; -if (ret <=0 ) -return ret; - - left -= ret; - buf += ret; - } - -BUG_ON ((size_t )(buf - buf_start) != n); -return n; -} - -/* -* Read exactly 'n' bytes or return an error. -*/ -ssize_t readn (int fd,void *buf,size_t n) -{ -return ion (true, fd, buf, n); -} - -/* -* Write exactly 'n' bytes or return an error. -*/ -ssize_t writen (int fd,const void *buf,size_t n) -{ -/* ion does not modify buf. */ -return ion (false, fd, (void *)buf, n); -} -size_t hex_width (u64 v) {size_t n =1 ;
tools/perf/util/util.h +1 -3
@@ -11,6 +11,7 @@#include <stddef.h> #include <linux/compiler.h> #include <sys/types.h> +#include <internal/lib.h> /* General helper functions */ void usage (const char *err)__noreturn ;
@@ -30,9 +31,6 @@ int copyfile_mode(const char *from, const char *to, mode_t mode);int copyfile_ns (const char *from,const char *to,struct nsinfo *nsi);int copyfile_offset (int ifd,loff_t off_in,int ofd,loff_t off_out,u64 size); -ssize_t readn (int fd,void *buf,size_t n); -ssize_t writen (int fd,const void *buf,size_t n); -size_t hex_width (u64 v);extern unsigned int page_size;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt the readn()/writen() functions from tools/perf
libperf: Adopt the readn()/writen() functions from tools/perf
Commit-ID: c03538b1f1a7e0e996a8d6feb20cf001d4b14939 Gitweb: https://git.kernel.org/tip/c03538b1f1a7e0e996a8d6feb20cf001d4b14939 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:47 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt the readn()/writen() functions from tools/perf
Move the readn()/writen() functions into libperf.
Keep those non-namespaced names because they will be shared only between perf and libperf.
Again, these are not exported functions.
--- tools/perf/lib/Build | 1 + tools/perf/lib/include/internal/lib.h | 10 ++++++++ tools/perf/lib/lib.c | 46 +++++++++++++++++++++++++++++++++++ tools/perf/util/util.c | 40 ------------------------------ tools/perf/util/util.h | 4 +-- 5 files changed, 58 insertions(+), 43 deletions(-)
tools/perf/lib/Build +1 -0
@@ -5,6 +5,7 @@ libperf-y += evsel.o libperf-y += evlist.o libperf-y += zalloc.o libperf-y += xyarray.o +libperf-y += lib.o $(OUTPUT)zalloc.o: ../../lib/zalloc.c FORCE $(call rule_mkdir)
tools/perf/lib/include/internal/lib.h new file +10 -0
@@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_INTERNAL_LIB_H +#define __LIBPERF_INTERNAL_LIB_H + +#include <unistd.h> + +ssize_t readn (int fd,void *buf,size_t n); +ssize_t writen (int fd,const void *buf,size_t n); + +#endif /* __LIBPERF_INTERNAL_CPUMAP_H */
tools/perf/lib/lib.c new file +46 -0
46 lines not on this page · raw message
tools/perf/util/util.c +0 -40
@@ -384,46 +384,6 @@ int copyfile(const char *from, const char *to)return copyfile_mode (from, to,0755 ); } -static ssize_t ion (bool is_read,int fd,void *buf,size_t n) -{ -void *buf_start = buf; -size_t left = n; - -while (left) { -/* buf must be treated as const if !is_read. */ -ssize_t ret = is_read ?read (fd, buf, left) : -write (fd, buf, left); - -if (ret <0 && errno ==EINTR ) -continue ; -if (ret <=0 ) -return ret; - - left -= ret; - buf += ret; - } - -BUG_ON ((size_t )(buf - buf_start) != n); -return n; -} - -/* -* Read exactly 'n' bytes or return an error. -*/ -ssize_t readn (int fd,void *buf,size_t n) -{ -return ion (true, fd, buf, n); -} - -/* -* Write exactly 'n' bytes or return an error. -*/ -ssize_t writen (int fd,const void *buf,size_t n) -{ -/* ion does not modify buf. */ -return ion (false, fd, (void *)buf, n); -} -size_t hex_width (u64 v) {size_t n =1 ;
tools/perf/util/util.h +1 -3
@@ -11,6 +11,7 @@#include <stddef.h> #include <linux/compiler.h> #include <sys/types.h> +#include <internal/lib.h> /* General helper functions */ void usage (const char *err)__noreturn ;
@@ -30,9 +31,6 @@ int copyfile_mode(const char *from, const char *to, mode_t mode);int copyfile_ns (const char *from,const char *to,struct nsinfo *nsi);int copyfile_offset (int ifd,loff_t off_in,int ofd,loff_t off_out,u64 size); -ssize_t readn (int fd,void *buf,size_t n); -ssize_t writen (int fd,const void *buf,size_t n); -size_t hex_width (u64 v);extern unsigned int page_size;
Jiri Olsa
reviewerPATCH 61/79 libperf: Add perf_evsel__alloc_fd function
In reply to Jiri OlsaMoving perf_evsel__alloc_fd function into libperf. It's not exported.
--- tools/perf/lib/evsel.c | 21 +++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/util/evsel.c | 18 +----------------- 3 files changed, 24 insertions(+), 17 deletions(-)
tools/perf/lib/evsel.c +21 -0
@@ -1,9 +1,12 @@// SPDX-License-Identifier: GPL-2.0 +#include <errno.h> #include <perf/evsel.h> #include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> #include <stdlib.h> +#include <internal/xyarray.h> +#include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -25,3 +28,21 @@ void perf_evsel__delete(struct perf_evsel *evsel) {free (evsel); } + +#define FD (e, x, y) (*(int *) xyarray__entry(e->fd, x, y)) + +int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads) +{ + evsel->fd =xyarray__new (ncpus, nthreads,sizeof (int )); + +if (evsel->fd) { +int cpu, thread; +for (cpu =0 ; cpu < ncpus; cpu++) { +for (thread =0 ; thread < nthreads; thread++) { +FD (evsel, cpu, thread) =-1 ; + } + } + } + +return evsel->fd !=NULL ?0 : -ENOMEM ; +}
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -20,4 +20,6 @@ struct perf_evsel { int nr_members; }; +int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads); +#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evsel.c +1 -17
@@ -1153,22 +1153,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,perf_evsel__reset_sample_bit (evsel,BRANCH_STACK ); } -static int perf_evsel__alloc_fd (struct evsel *evsel,int ncpus,int nthreads) -{ - evsel->core.fd =xyarray__new (ncpus, nthreads,sizeof (int )); - -if (evsel->core.fd) { -int cpu, thread; -for (cpu =0 ; cpu < ncpus; cpu++) { -for (thread =0 ; thread < nthreads; thread++) { -FD (evsel, cpu, thread) =-1 ; - } - } - } - -return evsel->core.fd !=NULL ?0 : -ENOMEM ; -} -static int perf_evsel__run_ioctl (struct evsel *evsel,int ioc,void *arg) {
@@ -1866,7 +1850,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, nthreads = threads->nr;if (evsel->core.fd ==NULL && -perf_evsel__alloc_fd (evsel, cpus->nr, nthreads) <0 ) +perf_evsel__alloc_fd (&evsel->core, cpus->nr, nthreads) <0 )return -ENOMEM ;if (evsel->cgrp) {
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt perf_evsel__alloc_fd() function from tools/perf
libperf: Adopt perf_evsel__alloc_fd() function from tools/perf
Commit-ID: b8eca4d761c57fcf691a8063cd562f205645d11f Gitweb: https://git.kernel.org/tip/b8eca4d761c57fcf691a8063cd562f205645d11f Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:48 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt perf_evsel__alloc_fd() function from tools/perf
Move the perf_evsel__alloc_fd() function from perf to libperf.
It's not exported.
--- tools/perf/lib/evsel.c | 21 +++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/util/evsel.c | 18 +----------------- 3 files changed, 24 insertions(+), 17 deletions(-)
tools/perf/lib/evsel.c +21 -0
@@ -1,9 +1,12 @@// SPDX-License-Identifier: GPL-2.0 +#include <errno.h> #include <perf/evsel.h> #include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> #include <stdlib.h> +#include <internal/xyarray.h> +#include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -25,3 +28,21 @@ void perf_evsel__delete(struct perf_evsel *evsel) {free (evsel); } + +#define FD (e, x, y) (*(int *) xyarray__entry(e->fd, x, y)) + +int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads) +{ + evsel->fd =xyarray__new (ncpus, nthreads,sizeof (int )); + +if (evsel->fd) { +int cpu, thread; +for (cpu =0 ; cpu < ncpus; cpu++) { +for (thread =0 ; thread < nthreads; thread++) { +FD (evsel, cpu, thread) =-1 ; + } + } + } + +return evsel->fd !=NULL ?0 : -ENOMEM ; +}
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -20,4 +20,6 @@ struct perf_evsel { int nr_members; }; +int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads); +#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/util/evsel.c +1 -17
@@ -1153,22 +1153,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,perf_evsel__reset_sample_bit (evsel,BRANCH_STACK ); } -static int perf_evsel__alloc_fd (struct evsel *evsel,int ncpus,int nthreads) -{ - evsel->core.fd =xyarray__new (ncpus, nthreads,sizeof (int )); - -if (evsel->core.fd) { -int cpu, thread; -for (cpu =0 ; cpu < ncpus; cpu++) { -for (thread =0 ; thread < nthreads; thread++) { -FD (evsel, cpu, thread) =-1 ; - } - } - } - -return evsel->core.fd !=NULL ?0 : -ENOMEM ; -} -static int perf_evsel__run_ioctl (struct evsel *evsel,int ioc,void *arg) {
@@ -1866,7 +1850,7 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus, nthreads = threads->nr;if (evsel->core.fd ==NULL && -perf_evsel__alloc_fd (evsel, cpus->nr, nthreads) <0 ) +perf_evsel__alloc_fd (&evsel->core, cpus->nr, nthreads) <0 )return -ENOMEM ;if (evsel->cgrp) {
Jiri Olsa
reviewerPATCH 62/79 libperf: Add perf_evsel__open function
In reply to Jiri OlsaAdding perf_evsel__open function into libperf.
It's a simplified version of evsel__open without fallback stuff. We can try to merge it in the future to libperf, but it has many glitches.
--- tools/perf/lib/evsel.c | 65 +++++++++++++++++++++++++++++ tools/perf/lib/include/perf/evsel.h | 4 ++ tools/perf/lib/libperf.map | 1 + 3 files changed, 70 insertions(+)
tools/perf/lib/evsel.c +65 -0
@@ -1,11 +1,17 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> +#include <unistd.h> +#include <sys/syscall.h> #include <perf/evsel.h> +#include <perf/cpumap.h> +#include <perf/threadmap.h> #include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> #include <stdlib.h> #include <internal/xyarray.h> +#include <internal/cpumap.h> +#include <internal/threadmap.h> #include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr)
@@ -46,3 +52,62 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)return evsel->fd !=NULL ?0 : -ENOMEM ; } + +static int +sys_perf_event_open (struct perf_event_attr *attr, +pid_t pid,int cpu,int group_fd, +unsigned long flags) +{ +return syscall (__NR_perf_event_open, attr, pid, cpu, group_fd, flags); +} + +int perf_evsel__open (struct perf_evsel *evsel,struct perf_cpu_map *cpus, +struct perf_thread_map *threads) +{ +int cpu, thread, err =0 ; + +if (cpus ==NULL ) { +static struct perf_cpu_map *empty_cpu_map; + +if (empty_cpu_map ==NULL ) { + empty_cpu_map =perf_cpu_map__dummy_new (); +if (empty_cpu_map ==NULL ) +return -ENOMEM ; + } + + cpus = empty_cpu_map; + } + +if (threads ==NULL ) { +static struct perf_thread_map *empty_thread_map; + +if (empty_thread_map ==NULL ) { + empty_thread_map =perf_thread_map__new_dummy (); +if (empty_thread_map ==NULL ) +return -ENOMEM ; + } + + threads = empty_thread_map; + } + +if (evsel->fd ==NULL && +perf_evsel__alloc_fd (evsel, cpus->nr, threads->nr) <0 ) +return -ENOMEM ; + +for (cpu =0 ; cpu < cpus->nr; cpu++) { +for (thread =0 ; thread < threads->nr; thread++) { +int fd; + + fd =sys_perf_event_open (&evsel->attr, + threads->map[thread].pid, + cpus->map[cpu],-1 ,0 ); + +if (fd <0 ) +return -errno; + +FD (evsel, cpu, thread) = fd; + } + } + +return err; +}
tools/perf/lib/include/perf/evsel.h +4 -0
@@ -6,10 +6,14 @@#include <perf/core.h> struct perf_evsel ; +struct perf_cpu_map ; +struct perf_thread_map ; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus, +struct perf_thread_map *threads);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -14,6 +14,7 @@ LIBPERF_0.0.1 { perf_evsel__new; perf_evsel__delete; perf_evsel__init; + perf_evsel__open; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt simplified perf_evsel__open() function from tools/perf
libperf: Adopt simplified perf_evsel__open() function from tools/perf
Commit-ID: 50a4e6fa450c4e5b688814a7ec8236d0de6e38bf Gitweb: https://git.kernel.org/tip/50a4e6fa450c4e5b688814a7ec8236d0de6e38bf Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:49 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt simplified perf_evsel__open() function from tools/perf
Add a perf_evsel__open() function to libperf.
It's a simplified version of evsel__open() without the fallback mechanism.
We can try to merge it in the future to libperf, but it has many details, lets start simple, requiring the latest kernel, perf should continue using its evsel__open() version, continuing to support running on older kernels when possible.
--- tools/perf/lib/evsel.c | 65 +++++++++++++++++++++++++++++++++++++ tools/perf/lib/include/perf/evsel.h | 4 +++ tools/perf/lib/libperf.map | 1 + 3 files changed, 70 insertions(+)
tools/perf/lib/evsel.c +65 -0
@@ -1,11 +1,17 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> +#include <unistd.h> +#include <sys/syscall.h> #include <perf/evsel.h> +#include <perf/cpumap.h> +#include <perf/threadmap.h> #include <linux/list.h> #include <internal/evsel.h> #include <linux/zalloc.h> #include <stdlib.h> #include <internal/xyarray.h> +#include <internal/cpumap.h> +#include <internal/threadmap.h> #include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr)
@@ -46,3 +52,62 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)return evsel->fd !=NULL ?0 : -ENOMEM ; } + +static int +sys_perf_event_open (struct perf_event_attr *attr, +pid_t pid,int cpu,int group_fd, +unsigned long flags) +{ +return syscall (__NR_perf_event_open, attr, pid, cpu, group_fd, flags); +} + +int perf_evsel__open (struct perf_evsel *evsel,struct perf_cpu_map *cpus, +struct perf_thread_map *threads) +{ +int cpu, thread, err =0 ; + +if (cpus ==NULL ) { +static struct perf_cpu_map *empty_cpu_map; + +if (empty_cpu_map ==NULL ) { + empty_cpu_map =perf_cpu_map__dummy_new (); +if (empty_cpu_map ==NULL ) +return -ENOMEM ; + } + + cpus = empty_cpu_map; + } + +if (threads ==NULL ) { +static struct perf_thread_map *empty_thread_map; + +if (empty_thread_map ==NULL ) { + empty_thread_map =perf_thread_map__new_dummy (); +if (empty_thread_map ==NULL ) +return -ENOMEM ; + } + + threads = empty_thread_map; + } + +if (evsel->fd ==NULL && +perf_evsel__alloc_fd (evsel, cpus->nr, threads->nr) <0 ) +return -ENOMEM ; + +for (cpu =0 ; cpu < cpus->nr; cpu++) { +for (thread =0 ; thread < threads->nr; thread++) { +int fd; + + fd =sys_perf_event_open (&evsel->attr, + threads->map[thread].pid, + cpus->map[cpu],-1 ,0 ); + +if (fd <0 ) +return -errno; + +FD (evsel, cpu, thread) = fd; + } + } + +return err; +}
tools/perf/lib/include/perf/evsel.h +4 -0
@@ -6,10 +6,14 @@struct perf_evsel ;struct perf_event_attr ; +struct perf_cpu_map ; +struct perf_thread_map ; LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus, +struct perf_thread_map *threads);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -14,6 +14,7 @@ LIBPERF_0.0.1 { perf_evsel__new; perf_evsel__delete; perf_evsel__init; + perf_evsel__open; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
Jiri Olsa
reviewerPATCH 63/79 libperf: Add perf_evsel__close function
In reply to Jiri OlsaAdding perf_evsel__close function into libperf
and keeping evsel__close to free ids.
--- tools/perf/builtin-trace.c | 2 +- tools/perf/lib/evsel.c | 26 +++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 2 +- tools/perf/tests/openat-syscall.c | 2 +- tools/perf/util/evlist.c | 5 ++-- tools/perf/util/evsel.c | 27 +++------------------- tools/perf/util/evsel.h | 3 +-- 10 files changed, 40 insertions(+), 31 deletions(-)
tools/perf/builtin-trace.c +1 -1
@@ -2413,7 +2413,7 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel,if (evsel->max_events !=ULONG_MAX && ++evsel->nr_events_printed == evsel->max_events) {evsel__disable (evsel); -perf_evsel__close (evsel); +evsel__close (evsel); } } }
tools/perf/lib/evsel.c +26 -0
@@ -111,3 +111,29 @@ int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,return err; } + +void perf_evsel__close_fd (struct perf_evsel *evsel) +{ +int cpu, thread; + +for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) +for (thread =0 ; thread <xyarray__max_y (evsel->fd); ++thread) { +close (FD (evsel, cpu, thread)); +FD (evsel, cpu, thread) =-1 ; + } +} + +void perf_evsel__free_fd (struct perf_evsel *evsel) +{ +xyarray__delete (evsel->fd); + evsel->fd =NULL ; +} + +void perf_evsel__close (struct perf_evsel *evsel) +{ +if (evsel->fd ==NULL ) +return ; + +perf_evsel__close_fd (evsel); +perf_evsel__free_fd (evsel); +}
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -21,5 +21,7 @@ struct perf_evsel { };int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads); +void perf_evsel__close_fd (struct perf_evsel *evsel); +void perf_evsel__free_fd (struct perf_evsel *evsel);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -15,5 +15,6 @@ LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,struct perf_thread_map *threads); +LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -15,6 +15,7 @@ LIBPERF_0.0.1 { perf_evsel__delete; perf_evsel__init; perf_evsel__open; + perf_evsel__close; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/tests/openat-syscall-all-cpus.c +1 -1
@@ -116,7 +116,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, intperf_evsel__free_counts (evsel); out_close_fd: -perf_evsel__close_fd (evsel); +perf_evsel__close_fd (&evsel->core); out_evsel_delete:evsel__delete (evsel); out_cpu_map_delete:
tools/perf/tests/openat-syscall.c +1 -1
@@ -57,7 +57,7 @@ int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __m err =0 ; out_close_fd: -perf_evsel__close_fd (evsel); +perf_evsel__close_fd (&evsel->core); out_evsel_delete:evsel__delete (evsel); out_thread_map_delete:
tools/perf/util/evlist.c +3 -2
@@ -34,6 +34,7 @@#include <linux/err.h> #include <linux/zalloc.h> #include <perf/evlist.h> +#include <perf/evsel.h> #include <perf/cpumap.h> #ifdef LACKS_SIGQUEUE_PROTOTYPE
@@ -1303,7 +1304,7 @@ void evlist__close(struct evlist *evlist)struct evsel *evsel;evlist__for_each_entry_reverse (evlist, evsel) -perf_evsel__close (evsel); +evsel__close (evsel); }static int perf_evlist__create_syswide_maps (struct evlist *evlist)
@@ -1772,7 +1773,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, is_open = false;if (c2->leader == leader) {if (is_open) -perf_evsel__close (c2); +evsel__close (c2); c2->leader = c2; c2->core.nr_members =0 ; }
tools/perf/util/evsel.c +3 -24
@@ -1265,12 +1265,6 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads)return 0 ; } -static void perf_evsel__free_fd (struct evsel *evsel) -{ -xyarray__delete (evsel->core.fd); - evsel->core.fd =NULL ; -} -static void perf_evsel__free_id (struct evsel *evsel) {xyarray__delete (evsel->sample_id);
@@ -1289,23 +1283,12 @@ static void perf_evsel__free_config_terms(struct evsel *evsel) } } -void perf_evsel__close_fd (struct evsel *evsel) -{ -int cpu, thread; - -for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) -for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); ++thread) { -close (FD (evsel, cpu, thread)); -FD (evsel, cpu, thread) =-1 ; - } -} -void perf_evsel__exit (struct evsel *evsel) {assert (list_empty (&evsel->core.node));assert (evsel->evlist ==NULL );perf_evsel__free_counts (evsel); -perf_evsel__free_fd (evsel); +perf_evsel__free_fd (&evsel->core);perf_evsel__free_id (evsel);perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp);
@@ -2057,13 +2040,9 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_map *cpus,return err; } -void perf_evsel__close (struct evsel *evsel) +void evsel__close (struct evsel *evsel) { -if (evsel->core.fd ==NULL ) -return ; - -perf_evsel__close_fd (evsel); -perf_evsel__free_fd (evsel); +perf_evsel__close (&evsel->core);perf_evsel__free_id (evsel); }
tools/perf/util/evsel.h +1 -2
@@ -268,7 +268,6 @@ const char *perf_evsel__group_name(struct evsel *evsel);int perf_evsel__group_desc (struct evsel *evsel,char *buf,size_t size);int perf_evsel__alloc_id (struct evsel *evsel,int ncpus,int nthreads); -void perf_evsel__close_fd (struct evsel *evsel);void __perf_evsel__set_sample_bit (struct evsel *evsel,enum perf_event_sample_format bit);
@@ -298,7 +297,7 @@ int perf_evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads);int evsel__open (struct evsel *evsel,struct perf_cpu_map *cpus,struct perf_thread_map *threads); -void perf_evsel__close (struct evsel *evsel); +void evsel__close (struct evsel *evsel);struct perf_sample ;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt simplified perf_evsel__close() function from tools/perf
libperf: Adopt simplified perf_evsel__close() function from tools/perf
Commit-ID: 88761fa1f1e3fb2df86727ac99f88abf2ac7e00b Gitweb: https://git.kernel.org/tip/88761fa1f1e3fb2df86727ac99f88abf2ac7e00b Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:50 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt simplified perf_evsel__close() function from tools/perf
Add perf_evsel__close() function to libperf while keeping a tools/perf specific evsel__close() to free ids.
--- tools/perf/builtin-trace.c | 2 +- tools/perf/lib/evsel.c | 26 ++++++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 2 ++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + tools/perf/tests/openat-syscall-all-cpus.c | 2 +- tools/perf/tests/openat-syscall.c | 2 +- tools/perf/util/evlist.c | 5 +++-- tools/perf/util/evsel.c | 27 +++------------------------ tools/perf/util/evsel.h | 3 +-- 10 files changed, 40 insertions(+), 31 deletions(-)
tools/perf/builtin-trace.c +1 -1
@@ -2401,7 +2401,7 @@ static int trace__event_handler(struct trace *trace, struct evsel *evsel,if (evsel->max_events !=ULONG_MAX && ++evsel->nr_events_printed == evsel->max_events) {evsel__disable (evsel); -perf_evsel__close (evsel); +evsel__close (evsel); } } }
tools/perf/lib/evsel.c +26 -0
@@ -111,3 +111,29 @@ int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,return err; } + +void perf_evsel__close_fd (struct perf_evsel *evsel) +{ +int cpu, thread; + +for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) +for (thread =0 ; thread <xyarray__max_y (evsel->fd); ++thread) { +close (FD (evsel, cpu, thread)); +FD (evsel, cpu, thread) =-1 ; + } +} + +void perf_evsel__free_fd (struct perf_evsel *evsel) +{ +xyarray__delete (evsel->fd); + evsel->fd =NULL ; +} + +void perf_evsel__close (struct perf_evsel *evsel) +{ +if (evsel->fd ==NULL ) +return ; + +perf_evsel__close_fd (evsel); +perf_evsel__free_fd (evsel); +}
tools/perf/lib/include/internal/evsel.h +2 -0
@@ -21,5 +21,7 @@ struct perf_evsel { };int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads); +void perf_evsel__close_fd (struct perf_evsel *evsel); +void perf_evsel__free_fd (struct perf_evsel *evsel);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -15,5 +15,6 @@ LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr); LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,struct perf_thread_map *threads); +LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -15,6 +15,7 @@ LIBPERF_0.0.1 { perf_evsel__delete; perf_evsel__init; perf_evsel__open; + perf_evsel__close; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/tests/openat-syscall-all-cpus.c +1 -1
@@ -116,7 +116,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, intperf_evsel__free_counts (evsel); out_close_fd: -perf_evsel__close_fd (evsel); +perf_evsel__close_fd (&evsel->core); out_evsel_delete:evsel__delete (evsel); out_cpu_map_delete:
tools/perf/tests/openat-syscall.c +1 -1
@@ -57,7 +57,7 @@ int test__openat_syscall_event(struct test *test __maybe_unused, int subtest __m err =0 ; out_close_fd: -perf_evsel__close_fd (evsel); +perf_evsel__close_fd (&evsel->core); out_evsel_delete:evsel__delete (evsel); out_thread_map_delete:
tools/perf/util/evlist.c +3 -2
@@ -34,6 +34,7 @@#include <linux/err.h> #include <linux/zalloc.h> #include <perf/evlist.h> +#include <perf/evsel.h> #include <perf/cpumap.h> #ifdef LACKS_SIGQUEUE_PROTOTYPE
@@ -1303,7 +1304,7 @@ void evlist__close(struct evlist *evlist)struct evsel *evsel;evlist__for_each_entry_reverse (evlist, evsel) -perf_evsel__close (evsel); +evsel__close (evsel); }static int perf_evlist__create_syswide_maps (struct evlist *evlist)
@@ -1772,7 +1773,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, is_open = false;if (c2->leader == leader) {if (is_open) -perf_evsel__close (c2); +evsel__close (c2); c2->leader = c2; c2->core.nr_members =0 ; }
tools/perf/util/evsel.c +3 -24
@@ -1265,12 +1265,6 @@ int perf_evsel__alloc_id(struct evsel *evsel, int ncpus, int nthreads)return 0 ; } -static void perf_evsel__free_fd (struct evsel *evsel) -{ -xyarray__delete (evsel->core.fd); - evsel->core.fd =NULL ; -} -static void perf_evsel__free_id (struct evsel *evsel) {xyarray__delete (evsel->sample_id);
@@ -1289,23 +1283,12 @@ static void perf_evsel__free_config_terms(struct evsel *evsel) } } -void perf_evsel__close_fd (struct evsel *evsel) -{ -int cpu, thread; - -for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) -for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); ++thread) { -close (FD (evsel, cpu, thread)); -FD (evsel, cpu, thread) =-1 ; - } -} -void perf_evsel__exit (struct evsel *evsel) {assert (list_empty (&evsel->core.node));assert (evsel->evlist ==NULL );perf_evsel__free_counts (evsel); -perf_evsel__free_fd (evsel); +perf_evsel__free_fd (&evsel->core);perf_evsel__free_id (evsel);perf_evsel__free_config_terms (evsel);cgroup__put (evsel->cgrp);
@@ -2057,13 +2040,9 @@ out_close:return err; } -void perf_evsel__close (struct evsel *evsel) +void evsel__close (struct evsel *evsel) { -if (evsel->core.fd ==NULL ) -return ; - -perf_evsel__close_fd (evsel); -perf_evsel__free_fd (evsel); +perf_evsel__close (&evsel->core);perf_evsel__free_id (evsel); }
tools/perf/util/evsel.h +1 -2
@@ -268,7 +268,6 @@ const char *perf_evsel__group_name(struct evsel *evsel);int perf_evsel__group_desc (struct evsel *evsel,char *buf,size_t size);int perf_evsel__alloc_id (struct evsel *evsel,int ncpus,int nthreads); -void perf_evsel__close_fd (struct evsel *evsel);void __perf_evsel__set_sample_bit (struct evsel *evsel,enum perf_event_sample_format bit);
@@ -298,7 +297,7 @@ int perf_evsel__open_per_thread(struct evsel *evsel, struct perf_thread_map *threads);int evsel__open (struct evsel *evsel,struct perf_cpu_map *cpus,struct perf_thread_map *threads); -void perf_evsel__close (struct evsel *evsel); +void evsel__close (struct evsel *evsel);struct perf_sample ;
Jiri Olsa
reviewerPATCH 64/79 libperf: Add perf_evsel__read function
In reply to Jiri OlsaMove perf_evsel__read function into libperf as a public interface together with struct perf_counts_values for passing the counter values to the user.
--- tools/perf/lib/evsel.c | 42 +++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/lib/include/perf/evsel.h | 14 ++++++++ tools/perf/lib/libperf.map | 1 + tools/perf/tests/event-times.c | 2 +- tools/perf/util/counts.h | 12 +------ tools/perf/util/evsel.c | 45 ++----------------------- tools/perf/util/evsel.h | 3 -- 8 files changed, 62 insertions(+), 58 deletions(-)
tools/perf/lib/evsel.c +42 -0
@@ -12,6 +12,7 @@#include <internal/xyarray.h> #include <internal/cpumap.h> #include <internal/threadmap.h> +#include <internal/lib.h> #include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr)
@@ -137,3 +138,44 @@ void perf_evsel__close(struct perf_evsel *evsel)perf_evsel__close_fd (evsel);perf_evsel__free_fd (evsel); } + +int perf_evsel__read_size (struct perf_evsel *evsel) +{ +u64 read_format = evsel->attr.read_format; +int entry =sizeof (u64);/* value */ +int size =0 ; +int nr =1 ; + +if (read_format &PERF_FORMAT_TOTAL_TIME_ENABLED ) + size +=sizeof (u64); + +if (read_format &PERF_FORMAT_TOTAL_TIME_RUNNING ) + size +=sizeof (u64); + +if (read_format &PERF_FORMAT_ID ) + entry +=sizeof (u64); + +if (read_format &PERF_FORMAT_GROUP ) { + nr = evsel->nr_members; + size +=sizeof (u64); + } + + size += entry * nr; +return size; +} + +int perf_evsel__read (struct perf_evsel *evsel,int cpu,int thread, +struct perf_counts_values *count) +{ +size_t size =perf_evsel__read_size (evsel); + +memset (count,0 ,sizeof (*count)); + +if (FD (evsel, cpu, thread) <0 ) +return -EINVAL ; + +if (readn (FD (evsel, cpu, thread), count->values, size) <=0 ) +return -errno; + +return 0 ; +}
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -23,5 +23,6 @@ struct perf_evsel {int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads);void perf_evsel__close_fd (struct perf_evsel *evsel);void perf_evsel__free_fd (struct perf_evsel *evsel); +int perf_evsel__read_size (struct perf_evsel *evsel);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +14 -0
@@ -3,12 +3,24 @@#define __LIBPERF_EVSEL_H#include <linux/perf_event.h> +#include <stdint.h> #include <perf/core.h> struct perf_evsel ;struct perf_cpu_map ;struct perf_thread_map ; +struct perf_counts_values { +union { +struct { +uint64_t val; +uint64_t ena; +uint64_t run; + }; +uint64_t values[3 ]; + }; +}; + LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
@@ -16,5 +28,7 @@ LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,struct perf_thread_map *threads); LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, +struct perf_counts_values *count);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -16,6 +16,7 @@ LIBPERF_0.0.1 { perf_evsel__init; perf_evsel__open; perf_evsel__close; + perf_evsel__read; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/tests/event-times.c +1 -1
@@ -196,7 +196,7 @@ static int test_times(int (attach)(struct evlist *),TEST_ASSERT_VAL ("failed to detach" , !detach (evlist)); -perf_evsel__read (evsel,0 ,0 , &count); +perf_evsel__read (&evsel->core,0 ,0 , &count); err = !(count.ena == count.run);
tools/perf/util/counts.h +1 -11
@@ -3,17 +3,7 @@#define __PERF_COUNTS_H#include <internal/xyarray.h> - -struct perf_counts_values { -union { -struct { -u64 val; -u64 ena; -u64 run; - }; -u64 values[3 ]; - }; -}; +#include <perf/evsel.h> struct perf_counts {s8 scaled;
tools/perf/util/evsel.c +2 -43
62 lines not on this page · raw message
tools/perf/util/evsel.h +0 -3
@@ -336,9 +336,6 @@ static inline bool perf_evsel__match2(struct evsel *e1, (a)->core.attr.type == (b)->core.attr.type && \ (a)->core.attr.config == (b)->core.attr.config) -int perf_evsel__read (struct evsel *evsel,int cpu,int thread, -struct perf_counts_values *count); -int perf_evsel__read_counter (struct evsel *evsel,int cpu,int thread); int __perf_evsel__read_on_cpu(struct evsel *evsel,
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt perf_evsel__read() function from tools/perf
libperf: Adopt perf_evsel__read() function from tools/perf
Commit-ID: 5c30af92f2b1e9d844e1ae3243e4adcd7753d4c1 Gitweb: https://git.kernel.org/tip/5c30af92f2b1e9d844e1ae3243e4adcd7753d4c1 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:51 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt perf_evsel__read() function from tools/perf
Move the perf_evsel__read() function to libperf as a public interface together with struct perf_counts_values for returning counter values.
--- tools/perf/lib/evsel.c | 42 ++++++++++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/lib/include/perf/evsel.h | 14 ++++++++++ tools/perf/lib/libperf.map | 1 + tools/perf/tests/event-times.c | 2 +- tools/perf/util/counts.h | 12 +-------- tools/perf/util/evsel.c | 45 ++------------------------------- tools/perf/util/evsel.h | 3 --- 8 files changed, 62 insertions(+), 58 deletions(-)
tools/perf/lib/evsel.c +42 -0
@@ -12,6 +12,7 @@#include <internal/xyarray.h> #include <internal/cpumap.h> #include <internal/threadmap.h> +#include <internal/lib.h> #include <linux/string.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr)
@@ -137,3 +138,44 @@ void perf_evsel__close(struct perf_evsel *evsel)perf_evsel__close_fd (evsel);perf_evsel__free_fd (evsel); } + +int perf_evsel__read_size (struct perf_evsel *evsel) +{ +u64 read_format = evsel->attr.read_format; +int entry =sizeof (u64);/* value */ +int size =0 ; +int nr =1 ; + +if (read_format &PERF_FORMAT_TOTAL_TIME_ENABLED ) + size +=sizeof (u64); + +if (read_format &PERF_FORMAT_TOTAL_TIME_RUNNING ) + size +=sizeof (u64); + +if (read_format &PERF_FORMAT_ID ) + entry +=sizeof (u64); + +if (read_format &PERF_FORMAT_GROUP ) { + nr = evsel->nr_members; + size +=sizeof (u64); + } + + size += entry * nr; +return size; +} + +int perf_evsel__read (struct perf_evsel *evsel,int cpu,int thread, +struct perf_counts_values *count) +{ +size_t size =perf_evsel__read_size (evsel); + +memset (count,0 ,sizeof (*count)); + +if (FD (evsel, cpu, thread) <0 ) +return -EINVAL ; + +if (readn (FD (evsel, cpu, thread), count->values, size) <=0 ) +return -errno; + +return 0 ; +}
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -23,5 +23,6 @@ struct perf_evsel {int perf_evsel__alloc_fd (struct perf_evsel *evsel,int ncpus,int nthreads);void perf_evsel__close_fd (struct perf_evsel *evsel);void perf_evsel__free_fd (struct perf_evsel *evsel); +int perf_evsel__read_size (struct perf_evsel *evsel);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +14 -0
@@ -2,6 +2,7 @@#ifndef __LIBPERF_EVSEL_H#define __LIBPERF_EVSEL_H +#include <stdint.h> #include <perf/core.h> struct perf_evsel ;
@@ -9,6 +10,17 @@ struct perf_event_attr;struct perf_cpu_map ;struct perf_thread_map ; +struct perf_counts_values { +union { +struct { +uint64_t val; +uint64_t ena; +uint64_t run; + }; +uint64_t values[3 ]; + }; +}; + LIBPERF_API void perf_evsel__init(struct perf_evsel *evsel,struct perf_event_attr *attr); LIBPERF_API struct perf_evsel *perf_evsel__new(struct perf_event_attr *attr);
@@ -16,5 +28,7 @@ LIBPERF_API void perf_evsel__delete(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map *cpus,struct perf_thread_map *threads); LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, +struct perf_counts_values *count);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -16,6 +16,7 @@ LIBPERF_0.0.1 { perf_evsel__init; perf_evsel__open; perf_evsel__close; + perf_evsel__read; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/tests/event-times.c +1 -1
@@ -196,7 +196,7 @@ static int test_times(int (attach)(struct evlist *),TEST_ASSERT_VAL ("failed to detach" , !detach (evlist)); -perf_evsel__read (evsel,0 ,0 , &count); +perf_evsel__read (&evsel->core,0 ,0 , &count); err = !(count.ena == count.run);
tools/perf/util/counts.h +1 -11
@@ -3,17 +3,7 @@#define __PERF_COUNTS_H#include <internal/xyarray.h> - -struct perf_counts_values { -union { -struct { -u64 val; -u64 ena; -u64 run; - }; -u64 values[3 ]; - }; -}; +#include <perf/evsel.h> struct perf_counts {s8 scaled;
tools/perf/util/evsel.c +2 -43
62 lines not on this page · raw message
tools/perf/util/evsel.h +0 -3
@@ -336,9 +336,6 @@ static inline bool perf_evsel__match2(struct evsel *e1, (a)->core.attr.type == (b)->core.attr.type && \ (a)->core.attr.config == (b)->core.attr.config) -int perf_evsel__read (struct evsel *evsel,int cpu,int thread, -struct perf_counts_values *count); -int perf_evsel__read_counter (struct evsel *evsel,int cpu,int thread); int __perf_evsel__read_on_cpu(struct evsel *evsel,
Jiri Olsa
reviewerPATCH 65/79 libperf: Add perf_evsel__enable/disable/apply_filter functions
In reply to Jiri OlsaMoving following functions:
evsel__enable
evsel__disable
evsel__apply_filter
under libperf with following names:
perf_evsel__enable
perf_evsel__disable
perf_evsel__apply_filter
Exporting only perf_evsel__enable/disable, keeping the perf_evsel__apply_filter private for the moment.
--- tools/perf/lib/evsel.c | 36 +++++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/lib/include/perf/evsel.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 29 ++------------------ tools/perf/util/evsel.h | 1 - 7 files changed, 44 insertions(+), 29 deletions(-)
tools/perf/lib/evsel.c +36 -0
@@ -14,6 +14,7 @@#include <internal/threadmap.h> #include <internal/lib.h> #include <linux/string.h> +#include <sys/ioctl.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -179,3 +180,38 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,return 0 ; } + +static int perf_evsel__run_ioctl (struct perf_evsel *evsel, +int ioc,void *arg) +{ +int cpu, thread; + +for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->fd); thread++) { +int fd =FD (evsel, cpu, thread), + err =ioctl (fd, ioc, arg); + +if (err) +return err; + } + } + +return 0 ; +} + +int perf_evsel__enable (struct perf_evsel *evsel) +{ +return perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_ENABLE ,0 ); +} + +int perf_evsel__disable (struct perf_evsel *evsel) +{ +return perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_DISABLE ,0 ); +} + +int perf_evsel__apply_filter (struct perf_evsel *evsel,const char *filter) +{ +return perf_evsel__run_ioctl (evsel, +PERF_EVENT_IOC_SET_FILTER , + (void *)filter); +}
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -24,5 +24,6 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);void perf_evsel__close_fd (struct perf_evsel *evsel);void perf_evsel__free_fd (struct perf_evsel *evsel);int perf_evsel__read_size (struct perf_evsel *evsel); +int perf_evsel__apply_filter (struct perf_evsel *evsel,const char *filter);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +2 -0
@@ -30,5 +30,7 @@ LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map * LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,struct perf_counts_values *count); +LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +2 -0
@@ -13,6 +13,8 @@ LIBPERF_0.0.1 { perf_thread_map__put; perf_evsel__new; perf_evsel__delete; + perf_evsel__enable; + perf_evsel__disable; perf_evsel__init; perf_evsel__open; perf_evsel__close;
tools/perf/util/evlist.c +1 -1
@@ -1109,7 +1109,7 @@ int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel)* filters only work for tracepoint event, which doesn't have cpu limit. * So evlist and evsel should always be same. */ - err =evsel__apply_filter (evsel, evsel->filter); + err =perf_evsel__apply_filter (&evsel->core, evsel->filter);if (err) { *err_evsel = evsel;break ;
tools/perf/util/evsel.c +2 -27
@@ -1153,31 +1153,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,perf_evsel__reset_sample_bit (evsel,BRANCH_STACK ); } -static int perf_evsel__run_ioctl (struct evsel *evsel, -int ioc,void *arg) -{ -int cpu, thread; - -for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) { -int fd =FD (evsel, cpu, thread), - err =ioctl (fd, ioc, arg); - -if (err) -return err; - } - } - -return 0 ; -} - -int evsel__apply_filter (struct evsel *evsel,const char *filter) -{ -return perf_evsel__run_ioctl (evsel, -PERF_EVENT_IOC_SET_FILTER , - (void *)filter); -} -int perf_evsel__set_filter (struct evsel *evsel,const char *filter) {char *new_filter =strdup (filter);
@@ -1220,7 +1195,7 @@ int perf_evsel__append_addr_filter(struct evsel *evsel, const char *filter)int evsel__enable (struct evsel *evsel) { -int err =perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_ENABLE ,0 ); +int err =perf_evsel__enable (&evsel->core);if (!err) evsel->disabled = false;
@@ -1230,7 +1205,7 @@ int evsel__enable(struct evsel *evsel)int evsel__disable (struct evsel *evsel) { -int err =perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_DISABLE ,0 ); +int err =perf_evsel__disable (&evsel->core);/* * We mark it disabled here so that tools that disable a event can * ignore events after they disable it. I.e. the ring buffer may have
tools/perf/util/evsel.h +0 -1
@@ -287,7 +287,6 @@ int perf_evsel__set_filter(struct evsel *evsel, const char *filter);int perf_evsel__append_tp_filter (struct evsel *evsel,const char *filter);int perf_evsel__append_addr_filter (struct evsel *evsel,const char *filter); -int evsel__apply_filter (struct evsel *evsel,const char *filter);int evsel__enable (struct evsel *evsel);int evsel__disable (struct evsel *evsel);
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt perf_evsel__enable()/disable()/apply_filter() functions
libperf: Adopt perf_evsel__enable()/disable()/apply_filter() functions
Commit-ID: a00571fda6091b5268d05e87d0797efe2db1920a Gitweb: https://git.kernel.org/tip/a00571fda6091b5268d05e87d0797efe2db1920a Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:52 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt perf_evsel__enable()/disable()/apply_filter() functions
Move the following functions:
evsel__enable()
evsel__disable()
evsel__apply_filter()
to libperf with the following names:
perf_evsel__enable()
perf_evsel__disable()
perf_evsel__apply_filter()
Export only perf_evsel__enable()/disable(), keeping the perf_evsel__apply_filter() one private for the moment.
--- tools/perf/lib/evsel.c | 36 +++++++++++++++++++++++++++++++++ tools/perf/lib/include/internal/evsel.h | 1 + tools/perf/lib/include/perf/evsel.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 29 ++------------------------ tools/perf/util/evsel.h | 1 - 7 files changed, 44 insertions(+), 29 deletions(-)
tools/perf/lib/evsel.c +36 -0
@@ -14,6 +14,7 @@#include <internal/threadmap.h> #include <internal/lib.h> #include <linux/string.h> +#include <sys/ioctl.h> void perf_evsel__init (struct perf_evsel *evsel,struct perf_event_attr *attr) {
@@ -179,3 +180,38 @@ int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,return 0 ; } + +static int perf_evsel__run_ioctl (struct perf_evsel *evsel, +int ioc,void *arg) +{ +int cpu, thread; + +for (cpu =0 ; cpu <xyarray__max_x (evsel->fd); cpu++) { +for (thread =0 ; thread <xyarray__max_y (evsel->fd); thread++) { +int fd =FD (evsel, cpu, thread), + err =ioctl (fd, ioc, arg); + +if (err) +return err; + } + } + +return 0 ; +} + +int perf_evsel__enable (struct perf_evsel *evsel) +{ +return perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_ENABLE ,0 ); +} + +int perf_evsel__disable (struct perf_evsel *evsel) +{ +return perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_DISABLE ,0 ); +} + +int perf_evsel__apply_filter (struct perf_evsel *evsel,const char *filter) +{ +return perf_evsel__run_ioctl (evsel, +PERF_EVENT_IOC_SET_FILTER , + (void *)filter); +}
tools/perf/lib/include/internal/evsel.h +1 -0
@@ -24,5 +24,6 @@ int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads);void perf_evsel__close_fd (struct perf_evsel *evsel);void perf_evsel__free_fd (struct perf_evsel *evsel);int perf_evsel__read_size (struct perf_evsel *evsel); +int perf_evsel__apply_filter (struct perf_evsel *evsel,const char *filter);#endif /* __LIBPERF_INTERNAL_EVSEL_H */
tools/perf/lib/include/perf/evsel.h +2 -0
@@ -30,5 +30,7 @@ LIBPERF_API int perf_evsel__open(struct perf_evsel *evsel, struct perf_cpu_map * LIBPERF_API void perf_evsel__close(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread,struct perf_counts_values *count); +LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); +LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +2 -0
@@ -13,6 +13,8 @@ LIBPERF_0.0.1 { perf_thread_map__put; perf_evsel__new; perf_evsel__delete; + perf_evsel__enable; + perf_evsel__disable; perf_evsel__init; perf_evsel__open; perf_evsel__close;
tools/perf/util/evlist.c +1 -1
@@ -1109,7 +1109,7 @@ int perf_evlist__apply_filters(struct evlist *evlist, struct evsel **err_evsel)* filters only work for tracepoint event, which doesn't have cpu limit. * So evlist and evsel should always be same. */ - err =evsel__apply_filter (evsel, evsel->filter); + err =perf_evsel__apply_filter (&evsel->core, evsel->filter);if (err) { *err_evsel = evsel;break ;
tools/perf/util/evsel.c +2 -27
@@ -1153,31 +1153,6 @@ void perf_evsel__config(struct evsel *evsel, struct record_opts *opts,perf_evsel__reset_sample_bit (evsel,BRANCH_STACK ); } -static int perf_evsel__run_ioctl (struct evsel *evsel, -int ioc,void *arg) -{ -int cpu, thread; - -for (cpu =0 ; cpu <xyarray__max_x (evsel->core.fd); cpu++) { -for (thread =0 ; thread <xyarray__max_y (evsel->core.fd); thread++) { -int fd =FD (evsel, cpu, thread), - err =ioctl (fd, ioc, arg); - -if (err) -return err; - } - } - -return 0 ; -} - -int evsel__apply_filter (struct evsel *evsel,const char *filter) -{ -return perf_evsel__run_ioctl (evsel, -PERF_EVENT_IOC_SET_FILTER , - (void *)filter); -} -int perf_evsel__set_filter (struct evsel *evsel,const char *filter) {char *new_filter =strdup (filter);
@@ -1220,7 +1195,7 @@ int perf_evsel__append_addr_filter(struct evsel *evsel, const char *filter)int evsel__enable (struct evsel *evsel) { -int err =perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_ENABLE ,0 ); +int err =perf_evsel__enable (&evsel->core);if (!err) evsel->disabled = false;
@@ -1230,7 +1205,7 @@ int evsel__enable(struct evsel *evsel)int evsel__disable (struct evsel *evsel) { -int err =perf_evsel__run_ioctl (evsel,PERF_EVENT_IOC_DISABLE ,0 ); +int err =perf_evsel__disable (&evsel->core);/* * We mark it disabled here so that tools that disable a event can * ignore events after they disable it. I.e. the ring buffer may have
tools/perf/util/evsel.h +0 -1
@@ -287,7 +287,6 @@ int perf_evsel__set_filter(struct evsel *evsel, const char *filter);int perf_evsel__append_tp_filter (struct evsel *evsel,const char *filter);int perf_evsel__append_addr_filter (struct evsel *evsel,const char *filter); -int evsel__apply_filter (struct evsel *evsel,const char *filter);int evsel__enable (struct evsel *evsel);int evsel__disable (struct evsel *evsel);
Jiri Olsa
reviewerPATCH 66/79 libperf: Add perf_cpu_map__for_each_cpu macro
In reply to Jiri OlsaAdding following macro to libperf:
perf_cpu_map__for_each_cpu
And its related functions:
perf_cpu_map__cpu
perf_cpu_map__nr
--- tools/perf/lib/cpumap.c | 13 +++++++++++++ tools/perf/lib/include/perf/cpumap.h | 7 +++++++ tools/perf/lib/libperf.map | 2 ++ 3 files changed, 22 insertions(+)
tools/perf/lib/cpumap.c +13 -0
@@ -224,3 +224,16 @@ struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list) out:return cpus; } + +int perf_cpu_map__cpu (const struct perf_cpu_map *cpus,int idx) +{ +if (idx < cpus->nr) +return cpus->map[idx]; + +return -1 ; +} + +int perf_cpu_map__nr (const struct perf_cpu_map *cpus) +{ +return cpus ? cpus->nr :1 ; +}
tools/perf/lib/include/perf/cpumap.h +7 -0
@@ -12,5 +12,12 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file); LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); +LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); +LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); + +#define perf_cpu_map__for_each_cpu (cpu, idx, cpus) \ + for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx); \ + (idx) < perf_cpu_map__nr(cpus); \ + (idx)++, (cpu) = perf_cpu_map__cpu(cpus, idx))#endif /* __LIBPERF_CPUMAP_H */
tools/perf/lib/libperf.map +2 -0
@@ -6,6 +6,8 @@ LIBPERF_0.0.1 { perf_cpu_map__put; perf_cpu_map__new; perf_cpu_map__read; + perf_cpu_map__nr; + perf_cpu_map__cpu; perf_thread_map__new_dummy; perf_thread_map__set_pid; perf_thread_map__comm;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_cpu_map__for_each_cpu() macro
libperf: Add perf_cpu_map__for_each_cpu() macro
Commit-ID: 09145d26b608e886415396e9277ae08f0617d21b Gitweb: https://git.kernel.org/tip/09145d26b608e886415396e9277ae08f0617d21b Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:53 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add perf_cpu_map__for_each_cpu() macro
Add the following macro to libperf:
perf_cpu_map__for_each_cpu()
And its related functions:
perf_cpu_map__cpu()
perf_cpu_map__nr()
That will allow hiding how it is implemented.
--- tools/perf/lib/cpumap.c | 13 +++++++++++++ tools/perf/lib/include/perf/cpumap.h | 7 +++++++ tools/perf/lib/libperf.map | 2 ++ 3 files changed, 22 insertions(+)
tools/perf/lib/cpumap.c +13 -0
@@ -224,3 +224,16 @@ invalid: out:return cpus; } + +int perf_cpu_map__cpu (const struct perf_cpu_map *cpus,int idx) +{ +if (idx < cpus->nr) +return cpus->map[idx]; + +return -1 ; +} + +int perf_cpu_map__nr (const struct perf_cpu_map *cpus) +{ +return cpus ? cpus->nr :1 ; +}
tools/perf/lib/include/perf/cpumap.h +7 -0
@@ -12,5 +12,12 @@ LIBPERF_API struct perf_cpu_map *perf_cpu_map__new(const char *cpu_list); LIBPERF_API struct perf_cpu_map *perf_cpu_map__read(FILE *file); LIBPERF_API struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map); LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map); +LIBPERF_API int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); +LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); + +#define perf_cpu_map__for_each_cpu (cpu, idx, cpus) \ + for ((idx) = 0, (cpu) = perf_cpu_map__cpu(cpus, idx); \ + (idx) < perf_cpu_map__nr(cpus); \ + (idx)++, (cpu) = perf_cpu_map__cpu(cpus, idx))#endif /* __LIBPERF_CPUMAP_H */
tools/perf/lib/libperf.map +2 -0
@@ -6,6 +6,8 @@ LIBPERF_0.0.1 { perf_cpu_map__put; perf_cpu_map__new; perf_cpu_map__read; + perf_cpu_map__nr; + perf_cpu_map__cpu; perf_thread_map__new_dummy; perf_thread_map__set_pid; perf_thread_map__comm;
Jiri Olsa
reviewerPATCH 67/79 libperf: Add perf_evsel__cpus/threads functions
In reply to Jiri OlsaAdding following functions:
perf_evsel__cpus
perf_evsel__threads
to access evsel's cpus and threads objects
--- tools/perf/lib/evsel.c | 10 ++++++++++ tools/perf/lib/include/perf/evsel.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ tools/perf/util/evsel.h | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-)
tools/perf/lib/evsel.c +10 -0
@@ -215,3 +215,13 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter)PERF_EVENT_IOC_SET_FILTER , (void *)filter); } + +struct perf_cpu_map *perf_evsel__cpus (struct perf_evsel *evsel) +{ +return evsel->cpus; +} + +struct perf_thread_map *perf_evsel__threads (struct perf_evsel *evsel) +{ +return evsel->threads; +}
tools/perf/lib/include/perf/evsel.h +2 -0
@@ -32,5 +32,7 @@ LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count); LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); +LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel); +LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +2 -0
@@ -21,6 +21,8 @@ LIBPERF_0.0.1 { perf_evsel__open; perf_evsel__close; perf_evsel__read; + perf_evsel__cpus; + perf_evsel__threads; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/util/evsel.h +1 -1
@@ -193,7 +193,7 @@ struct record_opts;static inline struct perf_cpu_map *evsel__cpus (struct evsel *evsel) { -return evsel->core.cpus; +return perf_evsel__cpus (&evsel->core); }static inline int perf_evsel__nr_cpus (struct evsel *evsel)
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evsel__cpus()/threads() functions
libperf: Add perf_evsel__cpus()/threads() functions
Commit-ID: 0ff1a0fdf52cffa998eee4303e02780d39b2b09c Gitweb: https://git.kernel.org/tip/0ff1a0fdf52cffa998eee4303e02780d39b2b09c Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:54 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add perf_evsel__cpus()/threads() functions
Add the following functions:
perf_evsel__cpus()
perf_evsel__threads()
to access the evsel's cpus and threads objects.
--- tools/perf/lib/evsel.c | 10 ++++++++++ tools/perf/lib/include/perf/evsel.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ tools/perf/util/evsel.h | 2 +- 4 files changed, 15 insertions(+), 1 deletion(-)
tools/perf/lib/evsel.c +10 -0
@@ -215,3 +215,13 @@ int perf_evsel__apply_filter(struct perf_evsel *evsel, const char *filter)PERF_EVENT_IOC_SET_FILTER , (void *)filter); } + +struct perf_cpu_map *perf_evsel__cpus (struct perf_evsel *evsel) +{ +return evsel->cpus; +} + +struct perf_thread_map *perf_evsel__threads (struct perf_evsel *evsel) +{ +return evsel->threads; +}
tools/perf/lib/include/perf/evsel.h +2 -0
@@ -32,5 +32,7 @@ LIBPERF_API int perf_evsel__read(struct perf_evsel *evsel, int cpu, int thread, struct perf_counts_values *count); LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); +LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel); +LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +2 -0
@@ -21,6 +21,8 @@ LIBPERF_0.0.1 { perf_evsel__open; perf_evsel__close; perf_evsel__read; + perf_evsel__cpus; + perf_evsel__threads; perf_evlist__new; perf_evlist__delete; perf_evlist__init;
tools/perf/util/evsel.h +1 -1
@@ -193,7 +193,7 @@ struct record_opts;static inline struct perf_cpu_map *evsel__cpus (struct evsel *evsel) { -return evsel->core.cpus; +return perf_evsel__cpus (&evsel->core); }static inline int perf_evsel__nr_cpus (struct evsel *evsel)
Jiri Olsa
reviewerPATCH 68/79 libperf: Add perf_evlist__open/close functions
In reply to Jiri OlsaAdding following functions:
perf_evlist__open
perf_evlist__close
It's a simplified version of evlist__open without sampling id index calculations. We can try to merge it in the future when these are moved to libperf.
Also adding some helper evlist traversing macros. In future we can remove them from util/evlist.h, but that requires also some other changes.
--- tools/perf/lib/evlist.c | 27 +++++++++++++++++++ tools/perf/lib/include/internal/evlist.h | 34 ++++++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ 4 files changed, 65 insertions(+)
tools/perf/lib/evlist.c +27 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <perf/evlist.h> +#include <perf/evsel.h> #include <linux/list.h> #include <internal/evlist.h> #include <internal/evsel.h>
@@ -114,3 +115,29 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,perf_evlist__propagate_maps (evlist); } + +int perf_evlist__open (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; +int err; + +perf_evlist__for_each_entry (evlist, evsel) { + err =perf_evsel__open (evsel, evsel->cpus, evsel->threads); +if (err <0 ) + goto out_err; + } + +return 0 ; + +out_err: +perf_evlist__close (evlist); +return err; +} + +void perf_evlist__close (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry_reverse (evlist, evsel) +perf_evsel__close (evsel); +}
tools/perf/lib/include/internal/evlist.h +34 -0
@@ -2,6 +2,8 @@#ifndef __LIBPERF_INTERNAL_EVLIST_H#define __LIBPERF_INTERNAL_EVLIST_H +#include <linux/list.h> +struct perf_cpu_map ;struct perf_thread_map ;
@@ -13,4 +15,36 @@ struct perf_evlist { struct perf_thread_map *threads; }; +/** +* __perf_evlist__for_each_entry - iterate thru all the evsels +* @list: list_head instance to iterate +* @evsel: struct perf_evsel iterator +*/ +#define __perf_evlist__for_each_entry (list, evsel) \ + list_for_each_entry(evsel, list, node) + +/** +* evlist__for_each_entry - iterate thru all the evsels +* @evlist: perf_evlist instance to iterate +* @evsel: struct perf_evsel iterator +*/ +#define perf_evlist__for_each_entry (evlist, evsel) \ + __perf_evlist__for_each_entry(&(evlist)->entries, evsel) + +/** +* __perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order +* @list: list_head instance to iterate +* @evsel: struct evsel iterator +*/ +#define __perf_evlist__for_each_entry_reverse (list, evsel) \ + list_for_each_entry_reverse(evsel, list, node) + +/** +* perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order +* @evlist: evlist instance to iterate +* @evsel: struct evsel iterator +*/ +#define perf_evlist__for_each_entry_reverse (evlist, evsel) \ + __perf_evlist__for_each_entry_reverse(&(evlist)->entries, evsel) +#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/lib/include/perf/evlist.h +2 -0
@@ -18,6 +18,8 @@ LIBPERF_API struct perf_evlist *perf_evlist__new(void); LIBPERF_API void perf_evlist__delete(struct perf_evlist *evlist); LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist,struct perf_evsel *evsel); +LIBPERF_API int perf_evlist__open(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__close(struct perf_evlist *evlist);#define perf_evlist__for_each_evsel (evlist, pos) \ for ((pos) = perf_evlist__next((evlist), NULL); \
tools/perf/lib/libperf.map +2 -0
@@ -25,6 +25,8 @@ LIBPERF_0.0.1 { perf_evsel__threads; perf_evlist__new; perf_evlist__delete; + perf_evlist__open; + perf_evlist__close; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt simplified perf_evlist__open()/close() functions from tools/perf
libperf: Adopt simplified perf_evlist__open()/close() functions from tools/perf
Commit-ID: 80dc2b3e257cbd62e1cd5b18a6581f231c828c81 Gitweb: https://git.kernel.org/tip/80dc2b3e257cbd62e1cd5b18a6581f231c828c81 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:55 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt simplified perf_evlist__open()/close() functions from tools/perf
Add the following functions:
perf_evlist__open()
perf_evlist__close()
It's a simplified version of perf's evlist__open() without the sampling id index calculations. We can try to merge it in the future when we need it in some new libperf user.
Also adopt some helper evlist traversing macros. In the future we can remove them from util/evlist.h, but that requires also some other changes.
--- tools/perf/lib/evlist.c | 27 +++++++++++++++++++++++++ tools/perf/lib/include/internal/evlist.h | 34 ++++++++++++++++++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ 4 files changed, 65 insertions(+)
tools/perf/lib/evlist.c +27 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <perf/evlist.h> +#include <perf/evsel.h> #include <linux/list.h> #include <internal/evlist.h> #include <internal/evsel.h>
@@ -114,3 +115,29 @@ void perf_evlist__set_maps(struct perf_evlist *evlist,perf_evlist__propagate_maps (evlist); } + +int perf_evlist__open (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; +int err; + +perf_evlist__for_each_entry (evlist, evsel) { + err =perf_evsel__open (evsel, evsel->cpus, evsel->threads); +if (err <0 ) + goto out_err; + } + +return 0 ; + +out_err: +perf_evlist__close (evlist); +return err; +} + +void perf_evlist__close (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry_reverse (evlist, evsel) +perf_evsel__close (evsel); +}
tools/perf/lib/include/internal/evlist.h +34 -0
@@ -2,6 +2,8 @@#ifndef __LIBPERF_INTERNAL_EVLIST_H#define __LIBPERF_INTERNAL_EVLIST_H +#include <linux/list.h> +struct perf_cpu_map ;struct perf_thread_map ;
@@ -13,4 +15,36 @@ struct perf_evlist { struct perf_thread_map *threads; }; +/** +* __perf_evlist__for_each_entry - iterate thru all the evsels +* @list: list_head instance to iterate +* @evsel: struct perf_evsel iterator +*/ +#define __perf_evlist__for_each_entry (list, evsel) \ + list_for_each_entry(evsel, list, node) + +/** +* evlist__for_each_entry - iterate thru all the evsels +* @evlist: perf_evlist instance to iterate +* @evsel: struct perf_evsel iterator +*/ +#define perf_evlist__for_each_entry (evlist, evsel) \ + __perf_evlist__for_each_entry(&(evlist)->entries, evsel) + +/** +* __perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order +* @list: list_head instance to iterate +* @evsel: struct evsel iterator +*/ +#define __perf_evlist__for_each_entry_reverse (list, evsel) \ + list_for_each_entry_reverse(evsel, list, node) + +/** +* perf_evlist__for_each_entry_reverse - iterate thru all the evsels in reverse order +* @evlist: evlist instance to iterate +* @evsel: struct evsel iterator +*/ +#define perf_evlist__for_each_entry_reverse (evlist, evsel) \ + __perf_evlist__for_each_entry_reverse(&(evlist)->entries, evsel) +#endif /* __LIBPERF_INTERNAL_EVLIST_H */
tools/perf/lib/include/perf/evlist.h +2 -0
@@ -18,6 +18,8 @@ LIBPERF_API struct perf_evlist *perf_evlist__new(void); LIBPERF_API void perf_evlist__delete(struct perf_evlist *evlist); LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist,struct perf_evsel *evsel); +LIBPERF_API int perf_evlist__open(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__close(struct perf_evlist *evlist);#define perf_evlist__for_each_evsel (evlist, pos) \ for ((pos) = perf_evlist__next((evlist), NULL); \
tools/perf/lib/libperf.map +2 -0
@@ -25,6 +25,8 @@ LIBPERF_0.0.1 { perf_evsel__threads; perf_evlist__new; perf_evlist__delete; + perf_evlist__open; + perf_evlist__close; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Jiri Olsa
reviewerPATCH 69/79 libperf: Add perf_evlist__enable/disable functions
In reply to Jiri OlsaMoving following functions:
perf_evlist__enable
perf_evlist__disable
--- tools/perf/lib/evlist.c | 16 ++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ 3 files changed, 20 insertions(+)
tools/perf/lib/evlist.c +16 -0
@@ -141,3 +141,19 @@ void perf_evlist__close(struct perf_evlist *evlist)perf_evlist__for_each_entry_reverse (evlist, evsel)perf_evsel__close (evsel); } + +void perf_evlist__enable (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry (evlist, evsel) +perf_evsel__enable (evsel); +} + +void perf_evlist__disable (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry (evlist, evsel) +perf_evsel__disable (evsel); +}
tools/perf/lib/include/perf/evlist.h +2 -0
@@ -20,6 +20,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *evsel); LIBPERF_API int perf_evlist__open(struct perf_evlist *evlist); LIBPERF_API void perf_evlist__close(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__enable(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__disable(struct perf_evlist *evlist);#define perf_evlist__for_each_evsel (evlist, pos) \ for ((pos) = perf_evlist__next((evlist), NULL); \
tools/perf/lib/libperf.map +2 -0
@@ -27,6 +27,8 @@ LIBPERF_0.0.1 { perf_evlist__delete; perf_evlist__open; perf_evlist__close; + perf_evlist__enable; + perf_evlist__disable; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Adopt perf_evlist__enable()/disable() functions from perf
libperf: Adopt perf_evlist__enable()/disable() functions from perf
Commit-ID: fcc97c3e7a9d6fd3fda7674f52fb005f4e8453e7 Gitweb: https://git.kernel.org/tip/fcc97c3e7a9d6fd3fda7674f52fb005f4e8453e7 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:56 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Adopt perf_evlist__enable()/disable() functions from perf
Adopt the following functions from tools/perf:
perf_evlist__enable()
perf_evlist__disable()
--- tools/perf/lib/evlist.c | 16 ++++++++++++++++ tools/perf/lib/include/perf/evlist.h | 2 ++ tools/perf/lib/libperf.map | 2 ++ 3 files changed, 20 insertions(+)
tools/perf/lib/evlist.c +16 -0
@@ -141,3 +141,19 @@ void perf_evlist__close(struct perf_evlist *evlist)perf_evlist__for_each_entry_reverse (evlist, evsel)perf_evsel__close (evsel); } + +void perf_evlist__enable (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry (evlist, evsel) +perf_evsel__enable (evsel); +} + +void perf_evlist__disable (struct perf_evlist *evlist) +{ +struct perf_evsel *evsel; + +perf_evlist__for_each_entry (evlist, evsel) +perf_evsel__disable (evsel); +}
tools/perf/lib/include/perf/evlist.h +2 -0
@@ -20,6 +20,8 @@ LIBPERF_API struct perf_evsel* perf_evlist__next(struct perf_evlist *evlist, struct perf_evsel *evsel); LIBPERF_API int perf_evlist__open(struct perf_evlist *evlist); LIBPERF_API void perf_evlist__close(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__enable(struct perf_evlist *evlist); +LIBPERF_API void perf_evlist__disable(struct perf_evlist *evlist);#define perf_evlist__for_each_evsel (evlist, pos) \ for ((pos) = perf_evlist__next((evlist), NULL); \
tools/perf/lib/libperf.map +2 -0
@@ -27,6 +27,8 @@ LIBPERF_0.0.1 { perf_evlist__delete; perf_evlist__open; perf_evlist__close; + perf_evlist__enable; + perf_evlist__disable; perf_evlist__init; perf_evlist__add; perf_evlist__remove;
Jiri Olsa
reviewerPATCH 70/79 libperf: Add perf_evsel__attr functions
In reply to Jiri OlsaMoving perf_evsel__attr function to get attr pointer.
--- tools/perf/lib/evsel.c | 5 +++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 7 insertions(+)
tools/perf/lib/evsel.c +5 -0
@@ -225,3 +225,8 @@ struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel) {return evsel->threads; } + +struct perf_event_attr *perf_evsel__attr (struct perf_evsel *evsel) +{ +return &evsel->attr; +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -34,5 +34,6 @@ LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel); LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel); +LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -23,6 +23,7 @@ LIBPERF_0.0.1 { perf_evsel__read; perf_evsel__cpus; perf_evsel__threads; + perf_evsel__attr; perf_evlist__new; perf_evlist__delete; perf_evlist__open;
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evsel__attr() function
libperf: Add perf_evsel__attr() function
Commit-ID: 384c4ad192a01fe235c7ac9e9fd8605d12a807e8 Gitweb: https://git.kernel.org/tip/384c4ad192a01fe235c7ac9e9fd8605d12a807e8 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:57 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add perf_evsel__attr() function
Add a perf_evsel__attr() function to get attr pointer from a perf_evsel instance.
--- tools/perf/lib/evsel.c | 5 +++++ tools/perf/lib/include/perf/evsel.h | 1 + tools/perf/lib/libperf.map | 1 + 3 files changed, 7 insertions(+)
tools/perf/lib/evsel.c +5 -0
@@ -225,3 +225,8 @@ struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel) {return evsel->threads; } + +struct perf_event_attr *perf_evsel__attr (struct perf_evsel *evsel) +{ +return &evsel->attr; +}
tools/perf/lib/include/perf/evsel.h +1 -0
@@ -34,5 +34,6 @@ LIBPERF_API int perf_evsel__enable(struct perf_evsel *evsel); LIBPERF_API int perf_evsel__disable(struct perf_evsel *evsel); LIBPERF_API struct perf_cpu_map *perf_evsel__cpus(struct perf_evsel *evsel); LIBPERF_API struct perf_thread_map *perf_evsel__threads(struct perf_evsel *evsel); +LIBPERF_API struct perf_event_attr *perf_evsel__attr(struct perf_evsel *evsel);#endif /* __LIBPERF_EVSEL_H */
tools/perf/lib/libperf.map +1 -0
@@ -23,6 +23,7 @@ LIBPERF_0.0.1 { perf_evsel__read; perf_evsel__cpus; perf_evsel__threads; + perf_evsel__attr; perf_evlist__new; perf_evlist__delete; perf_evlist__open;
Jiri Olsa
reviewerPATCH 71/79 libperf: Add install targets
In reply to Jiri OlsaAdd install targets (mostly copied from lib/bpf),
it's now possible to install libperf with:
$ make DESTDIR=/tmp/krava install
INSTALL libperf.a
INSTALL libperf.so
INSTALL libperf.so.0
INSTALL libperf.so.0.0.1
INSTALL headers
INSTALL libperf.pc$ find /tmp/krava/ /tmp/krava/ /tmp/krava/include /tmp/krava/include/perf /tmp/krava/include/perf/evsel.h /tmp/krava/include/perf/evlist.h /tmp/krava/include/perf/threadmap.h /tmp/krava/include/perf/cpumap.h /tmp/krava/include/perf/core.h /tmp/krava/lib64 /tmp/krava/lib64/pkgconfig /tmp/krava/lib64/pkgconfig/libperf.pc /tmp/krava/lib64/libperf.so.0.0.1 /tmp/krava/lib64/libperf.so.0 /tmp/krava/lib64/libperf.so /tmp/krava/lib64/libperf.a
--- tools/perf/lib/Makefile | 69 +++++++++++++++++++++++++++++- tools/perf/lib/libperf.pc.template | 11 +++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tools/perf/lib/libperf.pc.template
tools/perf/lib/Makefile +67 -2
@@ -14,9 +14,31 @@ srctree := $(patsubst %/,%,$(dir $(srctree))) #$(info Determined 'srctree' to be $(srctree)) endif +INSTALL = install + +# Use DESTDIR for installing into a different root directory. +# This is useful for building a package. The program will be +# installed in this directory as if it was the root directory. +# Then the build tool can move it later. +DESTDIR ?= +DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' + include $(srctree)/tools/scripts/Makefile.include include $(srctree)/tools/scripts/Makefile.arch +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) +libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) + ifeq ("$(origin V)", "command line") VERBOSE = $(V) endif
@@ -49,6 +71,8 @@ override CFLAGS += -fvisibility=hidden all: export srctree OUTPUT CC LD CFLAGS V +export DESTDIR DESTDIR_SQ + include $(srctree)/tools/build/Makefile.include VERSION_SCRIPT := libperf.map
@@ -60,6 +84,9 @@ VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION) LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION) LIBPERF_A := $(OUTPUT)libperf.a LIBPERF_IN := $(OUTPUT)libperf-in.o +LIBPERF_PC := $(OUTPUT)libperf.pc + +LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so* $(LIBPERF_IN): FORCE $(Q)$(MAKE) $(build)=libperf
@@ -74,14 +101,52 @@ $(LIBPERF_SO): $(LIBPERF_IN) @ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION) -libs: $(LIBPERF_A) $(LIBPERF_SO) +libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC) all: fixdep $(Q)$(MAKE) libs clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ - *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS + *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + +$(LIBPERF_PC): + $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ + -e "s|@LIBDIR@|$(libdir_SQ)|" \ + -e "s|@VERSION@|$(VERSION)|" \ + < libperf.pc.template > $@ + +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: libs + $(call QUIET_INSTALL, $(LIBPERF_ALL)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); + +install_pkgconfig: $(LIBPERF_PC) + $(call QUIET_INSTALL, $(LIBPERF_PC)) \ + $(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644) + +install: install_lib install_headers install_pkgconfig FORCE:
tools/perf/lib/libperf.pc.template new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=${prefix}/include + +Name: libperf +Description: perf library +Version: @VERSION@ +Libs: -L${libdir} -lperf +Cflags: -I${includedir}
Signature · 1 line
2.21.0
Re: [PATCH 71/79] libperf: Add install targets
Em Sun, Jul 21, 2019 at 01:24:58PM +0200, Jiri Olsa escreveu:
Quoted 10 lines
Add install targets (mostly copied from lib/bpf),
it's now possible to install libperf with:$ make DESTDIR=/tmp/krava install INSTALL libperf.a INSTALL libperf.so INSTALL libperf.so.0 INSTALL libperf.so.0.0.1 INSTALL headers INSTALL libperf.pc
'make install' shouldn't install the development parts, just what is needed by an application dynamicly linking with libperf, right?
And I also noticed that it installs directl in /, i.e. one would have to include '/usr' in the DESTDIR, which is different from libbpf:
[acme@quaco perf]$ rm -rf /tmp/C
[acme@quaco perf]$ make -C tools/lib/bpf DESTDIR=/tmp/C install
make: Entering directory '/home/acme/git/perf/tools/lib/bpf'
INSTALL libbpf.a INSTALL libbpf.so.0.0.4 INSTALL libbpf.pc
make: Leaving directory '/home/acme/git/perf/tools/lib/bpf' [acme@quaco perf]$
[acme@quaco perf]$ find /tmp/C/tmp/C/tmp/C/usr/tmp/C/usr/local/tmp/C/usr/local/lib64 /tmp/C/usr/local/lib64/pkgconfig /tmp/C/usr/local/lib64/pkgconfig/libbpf.pc /tmp/C/usr/local/lib64/libbpf.so.0.0.4 /tmp/C/usr/local/lib64/libbpf.so.0 /tmp/C/usr/local/lib64/libbpf.so /tmp/C/usr/local/lib64/libbpf.a
[acme@quaco perf]$
I'm applying the patch as we can fix this later, but I think .a, .pc files do not need to be installed for the main 'install' target, not even libbpf should do it, do you see any reason why it should?
I.e. we should remove 'install_headers' from the main 'install' target, I think.
- Arnaldo
Quoted 154 lines
$ find /tmp/krava/ /tmp/krava/ /tmp/krava/include /tmp/krava/include/perf /tmp/krava/include/perf/evsel.h /tmp/krava/include/perf/evlist.h /tmp/krava/include/perf/threadmap.h /tmp/krava/include/perf/cpumap.h /tmp/krava/include/perf/core.h /tmp/krava/lib64 /tmp/krava/lib64/pkgconfig /tmp/krava/lib64/pkgconfig/libperf.pc /tmp/krava/lib64/libperf.so.0.0.1 /tmp/krava/lib64/libperf.so.0 /tmp/krava/lib64/libperf.so /tmp/krava/lib64/libperf.aSigned-off-by Jiri Olsa <[email protected]>--- tools/perf/lib/Makefile | 69 +++++++++++++++++++++++++++++- tools/perf/lib/libperf.pc.template | 11 +++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tools/perf/lib/libperf.pc.templatetools/perf/lib/Makefile +67
-2@@ -14,9 +14,31 @@ srctree := $(patsubst %/,%,$(dir $(srctree))) #$(info Determined 'srctree' to be $(srctree)) endif +INSTALL = install + +# Use DESTDIR for installing into a different root directory. +# This is useful for building a package. The program will be +# installed in this directory as if it was the root directory. +# Then the build tool can move it later. +DESTDIR ?= +DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' + include $(srctree)/tools/scripts/Makefile.include include $(srctree)/tools/scripts/Makefile.arch +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) +libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) + ifeq ("$(origin V)", "command line") VERBOSE = $(V) endif@@ -49,6 +71,8 @@ override CFLAGS += -fvisibility=hidden all: export srctree OUTPUT CC LD CFLAGS V +export DESTDIR DESTDIR_SQ + include $(srctree)/tools/build/Makefile.include VERSION_SCRIPT := libperf.map@@ -60,6 +84,9 @@ VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION) LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION) LIBPERF_A := $(OUTPUT)libperf.a LIBPERF_IN := $(OUTPUT)libperf-in.o +LIBPERF_PC := $(OUTPUT)libperf.pc + +LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so* $(LIBPERF_IN): FORCE $(Q)$(MAKE) $(build)=libperf@@ -74,14 +101,52 @@ $(LIBPERF_SO): $(LIBPERF_IN) @ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION) -libs: $(LIBPERF_A) $(LIBPERF_SO) +libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC) all: fixdep $(Q)$(MAKE) libs clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ - *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS + *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + +$(LIBPERF_PC): + $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ + -e "s|@LIBDIR@|$(libdir_SQ)|" \ + -e "s|@VERSION@|$(VERSION)|" \ + < libperf.pc.template > $@ + +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: libs + $(call QUIET_INSTALL, $(LIBPERF_ALL)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); + +install_pkgconfig: $(LIBPERF_PC) + $(call QUIET_INSTALL, $(LIBPERF_PC)) \ + $(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644) + +install: install_lib install_headers install_pkgconfig FORCE:tools/perf/lib/libperf.pc.template new file +11
-0@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=${prefix}/include + +Name: libperf +Description: perf library +Version: @VERSION@ +Libs: -L${libdir} -lperf +Cflags: -I${includedir}Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add install targets
In reply to Jiri Olsalibperf: Add install targets
Commit-ID: 0a64d7091efde161a7d0fa385ed5c3bdb72ecdf9 Gitweb: https://git.kernel.org/tip/0a64d7091efde161a7d0fa385ed5c3bdb72ecdf9 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:58 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add install targets
Add install targets (mostly copied from tools/lib/bpf), it's now possible to install libperf with:
$ make DESTDIR=/tmp/krava install
INSTALL libperf.a
INSTALL libperf.so
INSTALL libperf.so.0
INSTALL libperf.so.0.0.1
INSTALL headers
INSTALL libperf.pc$ find /tmp/krava/ /tmp/krava/ /tmp/krava/include /tmp/krava/include/perf /tmp/krava/include/perf/evsel.h /tmp/krava/include/perf/evlist.h /tmp/krava/include/perf/threadmap.h /tmp/krava/include/perf/cpumap.h /tmp/krava/include/perf/core.h /tmp/krava/lib64 /tmp/krava/lib64/pkgconfig /tmp/krava/lib64/pkgconfig/libperf.pc /tmp/krava/lib64/libperf.so.0.0.1 /tmp/krava/lib64/libperf.so.0 /tmp/krava/lib64/libperf.so /tmp/krava/lib64/libperf.a
--- tools/perf/lib/Makefile | 69 +++++++++++++++++++++- .../lib/libperf.pc.template} | 7 +-- 2 files changed, 70 insertions(+), 6 deletions(-)
tools/perf/lib/Makefile +67 -2
@@ -14,9 +14,31 @@ srctree := $(patsubst %/,%,$(dir $(srctree))) #$(info Determined 'srctree' to be $(srctree)) endif +INSTALL = install + +# Use DESTDIR for installing into a different root directory. +# This is useful for building a package. The program will be +# installed in this directory as if it was the root directory. +# Then the build tool can move it later. +DESTDIR ?= +DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))' + include $(srctree)/tools/scripts/Makefile.include include $(srctree)/tools/scripts/Makefile.arch +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) +libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) + ifeq ("$(origin V)", "command line") VERBOSE = $(V) endif
@@ -49,6 +71,8 @@ override CFLAGS += -fvisibility=hidden all: export srctree OUTPUT CC LD CFLAGS V +export DESTDIR DESTDIR_SQ + include $(srctree)/tools/build/Makefile.include VERSION_SCRIPT := libperf.map
@@ -60,6 +84,9 @@ VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION) LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION) LIBPERF_A := $(OUTPUT)libperf.a LIBPERF_IN := $(OUTPUT)libperf-in.o +LIBPERF_PC := $(OUTPUT)libperf.pc + +LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so* $(LIBPERF_IN): FORCE $(Q)$(MAKE) $(build)=libperf
@@ -74,14 +101,52 @@ $(LIBPERF_SO): $(LIBPERF_IN) @ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION) -libs: $(LIBPERF_A) $(LIBPERF_SO) +libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC) all: fixdep $(Q)$(MAKE) libs clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ - *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS + *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + +$(LIBPERF_PC): + $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ + -e "s|@LIBDIR@|$(libdir_SQ)|" \ + -e "s|@VERSION@|$(VERSION)|" \ + < libperf.pc.template > $@ + +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: libs + $(call QUIET_INSTALL, $(LIBPERF_ALL)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); + +install_pkgconfig: $(LIBPERF_PC) + $(call QUIET_INSTALL, $(LIBPERF_PC)) \ + $(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644) + +install: install_lib install_headers install_pkgconfig FORCE:
tools/perf/lib/libperf.pc.template renamed from tools/lib/bpf/libbpf.pc.template +3 -4
@@ -4,9 +4,8 @@ prefix=@PREFIX@ libdir=@LIBDIR@ includedir=${prefix}/include -Name: libbpf -Description: BPF library +Name: libperf +Description: perf library Version: @VERSION@ -Libs: -L${libdir} -lbpf -Requires.private: libelf +Libs: -L${libdir} -lperf Cflags: -I${includedir}
Jiri Olsa
reviewerPATCH 72/79 libperf: Add tests support
In reply to Jiri OlsaAdding simple test framework, now empty.
--- tools/perf/lib/Makefile | 7 ++++- tools/perf/lib/include/internal/tests.h | 19 +++++++++++++ tools/perf/lib/tests/Makefile | 38 +++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/include/internal/tests.h create mode 100644 tools/perf/lib/tests/Makefile
tools/perf/lib/Makefile +6 -1
@@ -109,6 +109,11 @@ all: fixdep clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + $(Q)$(MAKE) -C tests clean + +tests: + $(Q)$(MAKE) -C tests + $(Q)$(MAKE) -C tests run $(LIBPERF_PC): $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
@@ -150,4 +155,4 @@ install: install_lib install_headers install_pkgconfig FORCE: -.PHONY: all install clean FORCE +.PHONY: all install clean tests FORCE
tools/perf/lib/include/internal/tests.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_INTERNAL_TESTS_H +#define __LIBPERF_INTERNAL_TESTS_H + +#include <stdio.h> + +#define __T_START fprintf(stdout, "- running %s...", __FILE__) +#define __T_OK fprintf(stdout, "OK\n") +#define __T_FAIL fprintf(stdout, "FAIL\n") + +#define __T (text, cond) \ +do { \ + if (!(cond)) { \ + fprintf(stderr, "FAILED %s:%d %s\n", __FILE__, __LINE__, text); \ + return -1; \ + } \ +} while (0) + +#endif /* __LIBPERF_INTERNAL_TESTS_H */
tools/perf/lib/tests/Makefile new file +38 -0
@@ -0,0 +1,38 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +TESTS = + +TESTS_SO := $(addsuffix -so,$(TESTS)) +TESTS_A := $(addsuffix -a,$(TESTS)) + +# Set compile option CFLAGS +ifdef EXTRA_CFLAGS + CFLAGS := $(EXTRA_CFLAGS) +else + CFLAGS := -g -Wall +endif + +all: + +include $(srctree)/tools/scripts/Makefile.include + +INCLUDE = -I$(srctree)/tools/perf/lib/include -I$(srctree)/tools/include + +$(TESTS_A): FORCE + $(QUIET_LINK)$(CC) $(INCLUDE) $(CFLAGS) -o $@ $(subst -a,.c,$@) ../libperf.a + +$(TESTS_SO): FORCE + $(QUIET_LINK)$(CC) $(INCLUDE) $(CFLAGS) -L.. -o $@ $(subst -so,.c,$@) -lperf + +all: $(TESTS_A) $(TESTS_SO) + +run: + @echo "running static:" + @for i in $(TESTS_A); do ./$$i; done + @echo "running dynamic:" + @for i in $(TESTS_SO); do LD_LIBRARY_PATH=../ ./$$i; done + +clean: + $(call QUIET_CLEAN, tests)$(RM) $(TESTS_A) $(TESTS_SO) + +.PHONY: all clean FORCE
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add tests support
libperf: Add tests support
Commit-ID: 6a94b52a71b7d3ca3ec47c194f7916b306cb26ef Gitweb: https://git.kernel.org/tip/6a94b52a71b7d3ca3ec47c194f7916b306cb26ef Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:24:59 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add tests support
Adding simple test framework, now empty.
--- tools/perf/lib/Makefile | 7 +++++- tools/perf/lib/include/internal/tests.h | 19 +++++++++++++++++ tools/perf/lib/tests/Makefile | 38 +++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-)
tools/perf/lib/Makefile +6 -1
@@ -109,6 +109,11 @@ all: fixdep clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + $(Q)$(MAKE) -C tests clean + +tests: + $(Q)$(MAKE) -C tests + $(Q)$(MAKE) -C tests run $(LIBPERF_PC): $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
@@ -150,4 +155,4 @@ install: install_lib install_headers install_pkgconfig FORCE: -.PHONY: all install clean FORCE +.PHONY: all install clean tests FORCE
tools/perf/lib/include/internal/tests.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LIBPERF_INTERNAL_TESTS_H +#define __LIBPERF_INTERNAL_TESTS_H + +#include <stdio.h> + +#define __T_START fprintf(stdout, "- running %s...", __FILE__) +#define __T_OK fprintf(stdout, "OK\n") +#define __T_FAIL fprintf(stdout, "FAIL\n") + +#define __T (text, cond) \ +do { \ + if (!(cond)) { \ + fprintf(stderr, "FAILED %s:%d %s\n", __FILE__, __LINE__, text); \ + return -1; \ + } \ +} while (0) + +#endif /* __LIBPERF_INTERNAL_TESTS_H */
tools/perf/lib/tests/Makefile new file +38 -0
@@ -0,0 +1,38 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +TESTS = + +TESTS_SO := $(addsuffix -so,$(TESTS)) +TESTS_A := $(addsuffix -a,$(TESTS)) + +# Set compile option CFLAGS +ifdef EXTRA_CFLAGS + CFLAGS := $(EXTRA_CFLAGS) +else + CFLAGS := -g -Wall +endif + +all: + +include $(srctree)/tools/scripts/Makefile.include + +INCLUDE = -I$(srctree)/tools/perf/lib/include -I$(srctree)/tools/include + +$(TESTS_A): FORCE + $(QUIET_LINK)$(CC) $(INCLUDE) $(CFLAGS) -o $@ $(subst -a,.c,$@) ../libperf.a + +$(TESTS_SO): FORCE + $(QUIET_LINK)$(CC) $(INCLUDE) $(CFLAGS) -L.. -o $@ $(subst -so,.c,$@) -lperf + +all: $(TESTS_A) $(TESTS_SO) + +run: + @echo "running static:" + @for i in $(TESTS_A); do ./$$i; done + @echo "running dynamic:" + @for i in $(TESTS_SO); do LD_LIBRARY_PATH=../ ./$$i; done + +clean: + $(call QUIET_CLEAN, tests)$(RM) $(TESTS_A) $(TESTS_SO) + +.PHONY: all clean FORCE
Jiri Olsa
reviewerPATCH 73/79 libperf: Add perf_cpu_map test
In reply to Jiri OlsaAdd simple perf_cpu_map tests.
--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-cpumap.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/tests/test-cpumap.c
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = +TESTS = test-cpumap TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-cpumap.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <perf/cpumap.h> +#include <internal/tests.h> + +int main (int argc,char **argv) +{ +struct perf_cpu_map *cpus; + + __T_START; + + cpus =perf_cpu_map__dummy_new (); +if (!cpus) +return -1 ; + +perf_cpu_map__get (cpus); +perf_cpu_map__put (cpus); +perf_cpu_map__put (cpus); + + __T_OK; +return 0 ; +}
Signature · 1 line
2.21.0
Re: [PATCH 73/79] libperf: Add perf_cpu_map test
Em Sun, Jul 21, 2019 at 01:25:00PM +0200, Jiri Olsa escreveu:
Quoted 1 line
Add simple
perf_cpu_maptests.
Its not honouring O= and requires that we first build libperf in the source tree, please fix this in a followup patch:
[acme@quaco perf]$ make -C tools/perf/lib clean
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
CLEAN libperf
CLEAN tests
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$ ls -la tools/perf/lib/tests/
total 16
drwxrwxr-x. 2 acme acme 4096 Jul 25 07:35 .
drwxrwxr-x. 4 acme acme 4096 Jul 25 07:35 .. -rw-rw-r--. 1 acme acme 857 Jul 25 07:34 Makefile -rw-rw-r--. 1 acme acme 328 Jul 25 07:34 test-cpumap.c [acme@quaco perf]$ make O=/tmp/build/perf -C tools/perf/lib/ tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
gcc: error: ../libperf.a: No such file or directory make[1]: *** [Makefile:22: test-cpumap-a] Error 1
make: *** [Makefile:115: tests] Error 2
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$
libperf itself is honouring O=:
[acme@quaco perf]$ make O=/tmp/build/perf -C tools/perf/lib
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK /tmp/build/perf/libperf.so.0.0.1
GEN /tmp/build/perf/libperf.pc
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$ make O=/tmp/build/perf -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
gcc: error: ../libperf.a: No such file or directory make[1]: *** [Makefile:22: test-cpumap-a] Error 1
make: *** [Makefile:115: tests] Error 2
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$
Its only when I stop using O= that it works:
[acme@quaco perf]$ make -C tools/perf/lib
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
HOSTCC fixdep.o HOSTLD fixdep-in.o LINK fixdep CC core.o CC cpumap.o CC threadmap.o CC evsel.o CC evlist.o CC zalloc.o CC xyarray.o CC lib.o LD libperf-in.o AR libperf.a LINK libperf.so.0.0.1 GEN libperf.pc
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$ make O=/tmp/build/perf -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
LINK test-cpumap-so
running static:
- running test-cpumap.c...OK
running dynamic:
- running test-cpumap.c...OK
make: Leaving directory '/home/acme/git/perf/tools/perf/lib' [acme@quaco perf]$
It is already useful albeit this limitation, so I'm applying.
- Arnaldo
Quoted 49 lines
Signed-off-by Jiri Olsa <[email protected]>--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-cpumap.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/tests/test-cpumap.ctools/perf/lib/tests/Makefile +1
-1@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = +TESTS = test-cpumap TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))tools/perf/lib/tests/test-cpumap.c new file +21
-0@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <perf/cpumap.h> +#include <internal/tests.h> + +int main (int argc,char **argv) +{ +struct perf_cpu_map *cpus; + + __T_START; + + cpus =perf_cpu_map__dummy_new (); +if (!cpus) +return -1 ; + +perf_cpu_map__get (cpus); +perf_cpu_map__put (cpus); +perf_cpu_map__put (cpus); + + __T_OK; +return 0 ; +}Signature · 1 line
2.21.0
Signature · 1 line
- Arnaldo
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_cpu_map test
In reply to Jiri Olsalibperf: Add perf_cpu_map test
Commit-ID: c0e730456ae8a864701f5ca4f6c2e23010e4b04a Gitweb: https://git.kernel.org/tip/c0e730456ae8a864701f5ca4f6c2e23010e4b04a Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:25:00 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add perf_cpu_map test
Add simple perf_cpu_map tests.
Committer testing:
One has to build it in the source tree, a limitation that should be fixed in followup patches:
$ make O=/tmp/build/perf -C tools/perf/lib
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK /tmp/build/perf/libperf.so.0.0.1
GEN /tmp/build/perf/libperf.pc
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
$ make O=/tmp/build/perf -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
gcc: error: ../libperf.a: No such file or directory
make[1]: *** [Makefile:22: test-cpumap-a] Error 1
make: *** [Makefile:115: tests] Error 2
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
[acme@quaco perf]$ make -C tools/perf/lib
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
HOSTCC fixdep.o
HOSTLD fixdep-in.o
LINK fixdep
CC core.o
CC cpumap.o
CC threadmap.o
CC evsel.o
CC evlist.o
CC zalloc.o
CC xyarray.o
CC lib.o
LD libperf-in.o
AR libperf.a
LINK libperf.so.0.0.1
GEN libperf.pc
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
$ make O=/tmp/build/perf -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
LINK test-cpumap-so
running static:
- running test-cpumap.c...OK
running dynamic:
- running test-cpumap.c...OK
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
$--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-cpumap.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = +TESTS = test-cpumap TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-cpumap.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <perf/cpumap.h> +#include <internal/tests.h> + +int main (int argc,char **argv) +{ +struct perf_cpu_map *cpus; + + __T_START; + + cpus =perf_cpu_map__dummy_new (); +if (!cpus) +return -1 ; + +perf_cpu_map__get (cpus); +perf_cpu_map__put (cpus); +perf_cpu_map__put (cpus); + + __T_OK; +return 0 ; +}
Jiri Olsa
reviewerPATCH 74/79 libperf: Add perf_thread_map test
In reply to Jiri OlsaAdd simple perf_thread_map tests.
--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-threadmap.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/tests/test-threadmap.c
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = test-cpumap +TESTS = test-cpumap test-threadmap TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-threadmap.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <perf/threadmap.h> +#include <internal/tests.h> + +int main (int argc,char **argv) +{ +struct perf_thread_map *threads; + + __T_START; + + threads =perf_thread_map__new_dummy (); +if (!threads) +return -1 ; + +perf_thread_map__get (threads); +perf_thread_map__put (threads); +perf_thread_map__put (threads); + + __T_OK; +return 0 ; +}
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_thread_map test
libperf: Add perf_thread_map test
Commit-ID: 43d6976365d5f90de487e8f9f49ab21775ae84f4 Gitweb: https://git.kernel.org/tip/43d6976365d5f90de487e8f9f49ab21775ae84f4 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:25:01 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:46 -0300
libperf: Add perf_thread_map test
Add simple perf_thread_map tests.
Committer testing:
$ make O=/tmp/build/perf -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
LINK test-threadmap-a
LINK test-cpumap-so
LINK test-threadmap-so
running static:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
running dynamic:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
$--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-threadmap.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = test-cpumap +TESTS = test-cpumap test-threadmap TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-threadmap.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <perf/threadmap.h> +#include <internal/tests.h> + +int main (int argc,char **argv) +{ +struct perf_thread_map *threads; + + __T_START; + + threads =perf_thread_map__new_dummy (); +if (!threads) +return -1 ; + +perf_thread_map__get (threads); +perf_thread_map__put (threads); +perf_thread_map__put (threads); + + __T_OK; +return 0 ; +}
Jiri Olsa
reviewerPATCH 75/79 libperf: Add perf_evlist test
In reply to Jiri OlsaAdd 2 simple perf_evlist tests to test counters reading interface through the struct evlist object.
--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-evlist.c | 123 +++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/tests/test-evlist.c
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = test-cpumap test-threadmap +TESTS = test-cpumap test-threadmap test-evlist TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-evlist.c new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
2.21.0
tip-bot for Jiri Olsa
merge bot[tip:perf/core] libperf: Add perf_evlist test
libperf: Add perf_evlist test
Commit-ID: 8ded5425fa71e2f7f60eb59d64ecdba80582b641 Gitweb: https://git.kernel.org/tip/8ded5425fa71e2f7f60eb59d64ecdba80582b641 Author: Jiri Olsa <[email protected]> AuthorDate: Sun, 21 Jul 2019 13:25:02 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 29 Jul 2019 18:34:47 -0300
libperf: Add perf_evlist test
Add 2 simple perf_evlist tests to test counters reading interface through the struct evlist object.
Committer testing:
# make -C tools/perf/lib tests
make: Entering directory '/home/acme/git/perf/tools/perf/lib'
LINK test-cpumap-a
LINK test-threadmap-a
LINK test-evlist-a
LINK test-cpumap-so
LINK test-threadmap-so
LINK test-evlist-so
running static:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
- running test-evlist.c...OK
running dynamic:
- running test-cpumap.c...OK
- running test-threadmap.c...OK
- running test-evlist.c...OK
make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
#--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-evlist.c | 123 +++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-)
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = test-cpumap test-threadmap +TESTS = test-cpumap test-threadmap test-evlist TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-evlist.c new file +123 -0
123 lines not on this page · raw message
Jiri Olsa
reviewerPATCH 76/79 libperf: Add perf_evsel tests
In reply to Jiri OlsaAdd 2 simple perf_evsel tests to test counters reading interface through the struct evsel object.
--- tools/perf/lib/tests/Makefile | 2 +- tools/perf/lib/tests/test-evsel.c | 82 +++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tools/perf/lib/tests/test-evsel.c
tools/perf/lib/tests/Makefile +1 -1
@@ -1,6 +1,6 @@ # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -TESTS = test-cpumap test-threadmap test-evlist +TESTS = test-cpumap test-threadmap test-evlist test-evsel TESTS_SO := $(addsuffix -so,$(TESTS)) TESTS_A := $(addsuffix -a,$(TESTS))
tools/perf/lib/tests/test-evsel.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
2.21.0