Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752784AbbGBQ6p (ORCPT ); Thu, 2 Jul 2015 12:58:45 -0400 Received: from mga02.intel.com ([134.134.136.20]:60484 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753327AbbGBQ6i convert rfc822-to-8bit (ORCPT ); Thu, 2 Jul 2015 12:58:38 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,394,1432623600"; d="scan'208";a="721862951" From: "Liang, Kan" To: Jiri Olsa CC: "acme@kernel.org" , "jolsa@kernel.org" , "ak@linux.intel.com" , "namhyung@kernel.org" , "eranian@google.com" , "Hunter, Adrian" , "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 Thread-Topic: [PATCH V2 3/3] perf,tests: Add cpu_map tests Thread-Index: AQHQtNKR0XjO2wMyTkWtjmdR4uTFZ53H0/KAgACRx9A= Date: Thu, 2 Jul 2015 16:58:29 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F07701884D31@SHSMSX103.ccr.corp.intel.com> References: <1435820925-51091-1-git-send-email-kan.liang@intel.com> <1435820925-51091-3-git-send-email-kan.liang@intel.com> <20150702161211.GC19742@krava.brq.redhat.com> In-Reply-To: <20150702161211.GC19742@krava.brq.redhat.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6887 Lines: 211 > > 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).. The test includes some cases to check error handling, which will print some warnings. For example, the user setting is not compatible with cpumask. Should I remove the cases which checking error handling? Thanks, Kan > > 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/