Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753605AbbGBQMY (ORCPT ); Thu, 2 Jul 2015 12:12:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36488 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753844AbbGBQMP (ORCPT ); Thu, 2 Jul 2015 12:12:15 -0400 Date: Thu, 2 Jul 2015 18:12:11 +0200 From: Jiri Olsa To: kan.liang@intel.com Cc: acme@kernel.org, jolsa@kernel.org, ak@linux.intel.com, namhyung@kernel.org, eranian@google.com, adrian.hunter@intel.com, dsahern@gmail.com, a.p.zijlstra@chello.nl, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2 3/3] perf,tests: Add cpu_map tests Message-ID: <20150702161211.GC19742@krava.brq.redhat.com> References: <1435820925-51091-1-git-send-email-kan.liang@intel.com> <1435820925-51091-3-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435820925-51091-3-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6289 Lines: 191 On Thu, Jul 02, 2015 at 03:08:45AM -0400, kan.liang@intel.com wrote: > From: Kan Liang > > Adding cpu_map tests to check evlist and evsel cpu map the test needs to be quiet (unless -v is specified).. 38: Test cpu map :event (null) can only be monitored on CPU 1 18. Other CPUs will be discard. event (null) can only be monitored on CPU 18. Other CPUs will be discard. event (null) cannot be monitored on the given cpus.Please check cpumask Ok jirka > > Signed-off-by: Kan Liang > --- > tools/perf/tests/Build | 1 + > tools/perf/tests/builtin-test.c | 4 ++ > tools/perf/tests/cpu-map.c | 113 ++++++++++++++++++++++++++++++++++++++++ > tools/perf/tests/tests.h | 1 + > 4 files changed, 119 insertions(+) > create mode 100644 tools/perf/tests/cpu-map.c > > diff --git a/tools/perf/tests/Build b/tools/perf/tests/Build > index d20d6e6..abc848e 100644 > --- a/tools/perf/tests/Build > +++ b/tools/perf/tests/Build > @@ -32,6 +32,7 @@ perf-y += sample-parsing.o > perf-y += parse-no-sample-id-all.o > perf-y += kmod-path.o > perf-y += thread-map.o > +perf-y += cpu-map.o > > perf-$(CONFIG_X86) += perf-time-to-tsc.o > > diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c > index c1dde73..5f279e1 100644 > --- a/tools/perf/tests/builtin-test.c > +++ b/tools/perf/tests/builtin-test.c > @@ -175,6 +175,10 @@ static struct test { > .func = test__thread_map, > }, > { > + .desc = "Test cpu map", > + .func = test__cpu_map, > + }, > + { > .func = NULL, > }, > }; > diff --git a/tools/perf/tests/cpu-map.c b/tools/perf/tests/cpu-map.c > new file mode 100644 > index 0000000..fa69aca > --- /dev/null > +++ b/tools/perf/tests/cpu-map.c > @@ -0,0 +1,113 @@ > +#include > +#include > +#include "evsel.h" > +#include "evlist.h" > +#include "tests.h" > +#include "debug.h" > + > +static int do_cpumap(struct target *target, > + struct perf_evlist *evlist, > + const char *cpu_list) > +{ > + struct perf_evsel *evsel; > + > + evsel = zalloc(sizeof(struct perf_evsel)); > + if (evsel == NULL) { > + pr_debug("failed to alloc evsel\n"); > + return -1; > + } > + perf_evlist__add(evlist, evsel); > + if (cpu_list != NULL) > + evsel->cpus = cpu_map__new(cpu_list); > + else > + evsel->cpus = NULL; > + > + if (perf_evlist__create_maps(evlist, target) < 0) > + return -1; > + > + return 0; > +} > + > +int test__cpu_map(void) > +{ > + struct perf_evlist *evlist; > + struct perf_evsel *evsel; > + struct target target = { > + .uid = UINT_MAX, > + }; > + int i, err; > + > + /* system wide */ > + evlist = perf_evlist__new(); > + target.system_wide = true; > + err = do_cpumap(&target, evlist, NULL); > + TEST_ASSERT_VAL("wrong ret of do_cpumap", 0 == err); > + > + evsel = perf_evlist__first(evlist); > + TEST_ASSERT_VAL("wrong number of cpu", cpu_map__nr(evlist->cpus) == cpu_map__nr(evsel->cpus)); > + for (i = 0; i < cpu_map__nr(evsel->cpus); i++) > + TEST_ASSERT_VAL("wrong cpu map", evlist->cpus->map[i] == evsel->cpus->map[i]); > + perf_evlist__delete(evlist); > + > + > + /* system wide + evsel cpumask */ > + evlist = perf_evlist__new(); > + target.system_wide = true; > + err = do_cpumap(&target, evlist, "0"); > + > + evsel = perf_evlist__first(evlist); > + TEST_ASSERT_VAL("wrong number of cpu", 1 == cpu_map__nr(evsel->cpus)); > + TEST_ASSERT_VAL("wrong cpu map", 0 == evsel->cpus->map[0]); > + perf_evlist__delete(evlist); > + > + > + /* defined cpu list */ > + evlist = perf_evlist__new(); > + target.cpu_list = "0,1,18,26"; > + err = do_cpumap(&target, evlist, NULL); > + TEST_ASSERT_VAL("wrong ret of do_cpumap", 0 == err); > + > + evsel = perf_evlist__first(evlist); > + TEST_ASSERT_VAL("wrong number of cpu", 4 == cpu_map__nr(evlist->cpus)); > + TEST_ASSERT_VAL("wrong number of cpu", cpu_map__nr(evlist->cpus) == cpu_map__nr(evsel->cpus)); > + for (i = 0; i < cpu_map__nr(evsel->cpus); i++) > + TEST_ASSERT_VAL("wrong cpu map", evlist->cpus->map[i] == evsel->cpus->map[i]); > + perf_evlist__delete(evlist); > + > + > + /* defined cpu list + evsel cpumask (all match) */ > + evlist = perf_evlist__new(); > + target.cpu_list = "0,1,18,26"; > + err = do_cpumap(&target, evlist, "1,18"); > + TEST_ASSERT_VAL("wrong ret of do_cpumap", 0 == err); > + > + evsel = perf_evlist__first(evlist); > + TEST_ASSERT_VAL("wrong number of cpu", 4 == cpu_map__nr(evlist->cpus)); > + TEST_ASSERT_VAL("wrong number of cpu", 2 == cpu_map__nr(evsel->cpus)); > + TEST_ASSERT_VAL("wrong cpu map", 1 == evsel->cpus->map[0]); > + TEST_ASSERT_VAL("wrong cpu map", 18 == evsel->cpus->map[1]); > + perf_evlist__delete(evlist); > + > + > + /* defined cpu list + evsel cpumask (partial match) */ > + evlist = perf_evlist__new(); > + target.cpu_list = "0,1,18,26"; > + err = do_cpumap(&target, evlist, "2,18,30"); > + TEST_ASSERT_VAL("wrong ret of do_cpumap", 0 == err); > + > + evsel = perf_evlist__first(evlist); > + TEST_ASSERT_VAL("wrong number of cpu", 4 == cpu_map__nr(evlist->cpus)); > + TEST_ASSERT_VAL("wrong number of cpu", 1 == cpu_map__nr(evsel->cpus)); > + TEST_ASSERT_VAL("wrong cpu map", 18 == evsel->cpus->map[0]); > + perf_evlist__delete(evlist); > + > + > + /* defined cpu list + evsel cpumask (not match) */ > + evlist = perf_evlist__new(); > + target.cpu_list = "0,1,18,26"; > + err = do_cpumap(&target, evlist, "2,9,30"); > + TEST_ASSERT_VAL("wrong ret of do_cpumap", 0 != err); > + perf_evlist__delete(evlist); > + > + return 0; > +} > diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h > index ebb47d9..cb6b994 100644 > --- a/tools/perf/tests/tests.h > +++ b/tools/perf/tests/tests.h > @@ -62,6 +62,7 @@ int test__fdarray__filter(void); > int test__fdarray__add(void); > int test__kmod_path__parse(void); > int test__thread_map(void); > +int test__cpu_map(void); > > #if defined(__x86_64__) || defined(__i386__) || defined(__arm__) || defined(__aarch64__) > #ifdef HAVE_DWARF_UNWIND_SUPPORT > -- > 1.8.3.1 > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/