mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
libperf: Add perf_cpu_map__get()/perf_cpu_map__put()
Moving the following functions: cpu_map__get() cpu_map__put() to libperf with following names: perf_cpu_map__get() perf_cpu_map__put() Committer notes: Added fixes for arm/arm64 Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Budankov <alexey.budankov@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20190721112506.12306-31-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
397721e06e
commit
38f01d8da1
@@ -181,7 +181,7 @@ static int cs_etm_set_option(struct auxtrace_record *itr,
|
||||
|
||||
err = 0;
|
||||
out:
|
||||
cpu_map__put(online_cpus);
|
||||
perf_cpu_map__put(online_cpus);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ cs_etm_info_priv_size(struct auxtrace_record *itr __maybe_unused,
|
||||
}
|
||||
}
|
||||
|
||||
cpu_map__put(online_cpus);
|
||||
perf_cpu_map__put(online_cpus);
|
||||
|
||||
return (CS_ETM_HEADER_SIZE +
|
||||
(etmv4 * CS_ETMV4_PRIV_SIZE) +
|
||||
@@ -679,7 +679,7 @@ static int cs_etm_info_fill(struct auxtrace_record *itr,
|
||||
if (cpu_map__has(cpu_map, i))
|
||||
cs_etm_get_metadata(i, &offset, itr, info);
|
||||
|
||||
cpu_map__put(online_cpus);
|
||||
perf_cpu_map__put(online_cpus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ char *get_cpuid_str(struct perf_pmu *pmu)
|
||||
return NULL;
|
||||
|
||||
/* read midr from list of cpus mapped to this pmu */
|
||||
cpus = cpu_map__get(pmu->cpus);
|
||||
cpus = perf_cpu_map__get(pmu->cpus);
|
||||
for (cpu = 0; cpu < cpus->nr; cpu++) {
|
||||
scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR,
|
||||
sysfs, cpus->map[cpu]);
|
||||
@@ -60,6 +60,6 @@ char *get_cpuid_str(struct perf_pmu *pmu)
|
||||
buf = NULL;
|
||||
}
|
||||
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ static int reset_tracing_cpu(void)
|
||||
int ret;
|
||||
|
||||
ret = set_tracing_cpumask(cpumap);
|
||||
cpu_map__put(cpumap);
|
||||
perf_cpu_map__put(cpumap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -933,8 +933,8 @@ static int perf_stat_init_aggr_mode(void)
|
||||
|
||||
static void perf_stat__exit_aggr_mode(void)
|
||||
{
|
||||
cpu_map__put(stat_config.aggr_map);
|
||||
cpu_map__put(stat_config.cpus_aggr_map);
|
||||
perf_cpu_map__put(stat_config.aggr_map);
|
||||
perf_cpu_map__put(stat_config.cpus_aggr_map);
|
||||
stat_config.aggr_map = NULL;
|
||||
stat_config.cpus_aggr_map = NULL;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <linux/refcount.h>
|
||||
#include <internal/cpumap.h>
|
||||
#include <asm/bug.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct perf_cpu_map *perf_cpu_map__dummy_new(void)
|
||||
{
|
||||
@@ -16,3 +18,25 @@ struct perf_cpu_map *perf_cpu_map__dummy_new(void)
|
||||
|
||||
return cpus;
|
||||
}
|
||||
|
||||
static void cpu_map__delete(struct perf_cpu_map *map)
|
||||
{
|
||||
if (map) {
|
||||
WARN_ONCE(refcount_read(&map->refcnt) != 0,
|
||||
"cpu_map refcnt unbalanced\n");
|
||||
free(map);
|
||||
}
|
||||
}
|
||||
|
||||
struct perf_cpu_map *perf_cpu_map__get(struct perf_cpu_map *map)
|
||||
{
|
||||
if (map)
|
||||
refcount_inc(&map->refcnt);
|
||||
return map;
|
||||
}
|
||||
|
||||
void perf_cpu_map__put(struct perf_cpu_map *map)
|
||||
{
|
||||
if (map && refcount_dec_and_test(&map->refcnt))
|
||||
cpu_map__delete(map);
|
||||
}
|
||||
|
||||
@@ -7,5 +7,7 @@
|
||||
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__get(struct perf_cpu_map *map);
|
||||
LIBPERF_API void perf_cpu_map__put(struct perf_cpu_map *map);
|
||||
|
||||
#endif /* __LIBPERF_CPUMAP_H */
|
||||
|
||||
@@ -2,6 +2,8 @@ LIBPERF_0.0.1 {
|
||||
global:
|
||||
libperf_set_print;
|
||||
perf_cpu_map__dummy_new;
|
||||
perf_cpu_map__get;
|
||||
perf_cpu_map__put;
|
||||
local:
|
||||
*;
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ static unsigned long *get_bitmap(const char *str, int nbits)
|
||||
}
|
||||
|
||||
if (map)
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
return bm;
|
||||
}
|
||||
|
||||
|
||||
@@ -655,7 +655,7 @@ static int do_test_code_reading(bool try_kcore)
|
||||
* and will be freed by following perf_evlist__set_maps
|
||||
* call. Getting refference to keep them alive.
|
||||
*/
|
||||
cpu_map__get(cpus);
|
||||
perf_cpu_map__get(cpus);
|
||||
thread_map__get(threads);
|
||||
perf_evlist__set_maps(evlist, NULL, NULL);
|
||||
evlist__delete(evlist);
|
||||
@@ -705,7 +705,7 @@ out_err:
|
||||
if (evlist) {
|
||||
evlist__delete(evlist);
|
||||
} else {
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
thread_map__put(threads);
|
||||
}
|
||||
machine__delete_threads(machine);
|
||||
|
||||
@@ -39,7 +39,7 @@ static int process_event_mask(struct perf_tool *tool __maybe_unused,
|
||||
TEST_ASSERT_VAL("wrong cpu", map->map[i] == i);
|
||||
}
|
||||
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
|
||||
TEST_ASSERT_VAL("wrong cpu", map->map[0] == 1);
|
||||
TEST_ASSERT_VAL("wrong cpu", map->map[1] == 256);
|
||||
TEST_ASSERT_VAL("wrong refcnt", refcount_read(&map->refcnt) == 1);
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may
|
||||
TEST_ASSERT_VAL("failed to synthesize map",
|
||||
!perf_event__synthesize_cpu_map(NULL, cpus, process_event_mask, NULL));
|
||||
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
|
||||
/* This one is better stores in cpu values. */
|
||||
cpus = cpu_map__new("1,256");
|
||||
@@ -91,7 +91,7 @@ int test__cpu_map_synthesize(struct test *test __maybe_unused, int subtest __may
|
||||
TEST_ASSERT_VAL("failed to synthesize map",
|
||||
!perf_event__synthesize_cpu_map(NULL, cpus, process_event_cpus, NULL));
|
||||
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ static int attach__cpu_disabled(struct evlist *evlist)
|
||||
return err;
|
||||
}
|
||||
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
return evsel__enable(evsel);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ static int attach__cpu_enabled(struct evlist *evlist)
|
||||
if (err == -EACCES)
|
||||
return TEST_SKIP;
|
||||
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
return err ? TEST_FAIL : TEST_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ static int process_event_cpus(struct perf_tool *tool __maybe_unused,
|
||||
TEST_ASSERT_VAL("wrong cpus", map->map[0] == 1);
|
||||
TEST_ASSERT_VAL("wrong cpus", map->map[1] == 2);
|
||||
TEST_ASSERT_VAL("wrong cpus", map->map[2] == 3);
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,6 @@ int test__event_update(struct test *test __maybe_unused, int subtest __maybe_unu
|
||||
TEST_ASSERT_VAL("failed to synthesize attr update cpus",
|
||||
!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
|
||||
|
||||
cpu_map__put(evsel->own_cpus);
|
||||
perf_cpu_map__put(evsel->own_cpus);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ out_err:
|
||||
evlist__disable(evlist);
|
||||
evlist__delete(evlist);
|
||||
} else {
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
thread_map__put(threads);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ static unsigned long *get_bitmap(const char *str, int nbits)
|
||||
}
|
||||
|
||||
if (map)
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
else
|
||||
free(bm);
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ out_delete_evlist:
|
||||
cpus = NULL;
|
||||
threads = NULL;
|
||||
out_free_cpus:
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
out_free_threads:
|
||||
thread_map__put(threads);
|
||||
return err;
|
||||
|
||||
@@ -120,7 +120,7 @@ out_close_fd:
|
||||
out_evsel_delete:
|
||||
evsel__delete(evsel);
|
||||
out_cpu_map_delete:
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
out_thread_map_delete:
|
||||
thread_map__put(threads);
|
||||
return err;
|
||||
|
||||
@@ -125,7 +125,7 @@ out_init:
|
||||
}
|
||||
|
||||
out_free_maps:
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
thread_map__put(threads);
|
||||
out_delete_evlist:
|
||||
evlist__delete(evlist);
|
||||
|
||||
@@ -569,7 +569,7 @@ out:
|
||||
evlist__disable(evlist);
|
||||
evlist__delete(evlist);
|
||||
} else {
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
thread_map__put(threads);
|
||||
}
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ out_init:
|
||||
}
|
||||
|
||||
out_free_maps:
|
||||
cpu_map__put(cpus);
|
||||
perf_cpu_map__put(cpus);
|
||||
thread_map__put(threads);
|
||||
out_delete_evlist:
|
||||
evlist__delete(evlist);
|
||||
|
||||
@@ -133,7 +133,7 @@ int test__session_topology(struct test *test __maybe_unused, int subtest __maybe
|
||||
}
|
||||
|
||||
ret = check_cpu_topology(path, map);
|
||||
cpu_map__put(map);
|
||||
perf_cpu_map__put(map);
|
||||
|
||||
free_path:
|
||||
unlink(path);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user