Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753482AbbF3NnG (ORCPT ); Tue, 30 Jun 2015 09:43:06 -0400 Received: from mga11.intel.com ([192.55.52.93]:18875 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753180AbbF3Nm6 convert rfc822-to-8bit (ORCPT ); Tue, 30 Jun 2015 09:42:58 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,378,1432623600"; d="scan'208";a="753273586" 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 2/2] perf,tools: check and re-organize evsel cpu maps Thread-Topic: [PATCH 2/2] perf,tools: check and re-organize evsel cpu maps Thread-Index: AQHQsuIqb3BPXlxSTUu88+3PRlsTHp3EcL4AgACZ70A= Date: Tue, 30 Jun 2015 13:42:49 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F07701883578@SHSMSX103.ccr.corp.intel.com> References: <1435607735-6332-1-git-send-email-kan.liang@intel.com> <1435607735-6332-2-git-send-email-kan.liang@intel.com> <20150630121428.GF25631@krava.brq.redhat.com> In-Reply-To: <20150630121428.GF25631@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: 2240 Lines: 81 > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index > > 6cfdee6..f179379 100644 > > --- a/tools/perf/util/evlist.c > > +++ b/tools/perf/util/evlist.c > > @@ -1101,6 +1101,71 @@ int perf_evlist__mmap(struct perf_evlist > *evlist, unsigned int pages, > > return perf_evlist__mmap_ex(evlist, pages, overwrite, 0, false); } > > > > +static int cmp_ids(const void *a, const void *b) { > > + return *(int *)a - *(int *)b; > > +} > > + > > +static int perf_evlist__check_evsel_cpus(struct perf_evlist *evlist, > > +struct perf_evsel *evsel) { > > + const struct cpu_map *cpus = evlist->cpus; > > + const int ncpus = cpu_map__nr(evlist->cpus); > > + int j = 0, cpu_nr = 0, tmp = 0; > > + int i; > > + > > + /* ensure we process id in increasing order */ > > + qsort(evlist->cpus->map, evlist->cpus->nr, sizeof(int), cmp_ids); > > wouldn't sorting maps affect some other code? > I didn't find any bad effect after sorting the maps. Any codes I need to check? > > + > > + /* find the common cpus between evsel and evlist. */ > > + for (i = 0; i < cpu_map__nr(evsel->cpus);) { > > + > > + if (j >= ncpus) { > > + evsel->cpus->map[i++] = -1; > > + continue; > > + } > > + for (; j < ncpus; j++) { > > + if (cpus->map[j] < evsel->cpus->map[i]) > > + continue; > > + if (cpus->map[j] == evsel->cpus->map[i]) { > > + cpu_nr++; > > + j++; > > hum, do you skip 1 item in cpus by j++ here and in for loop header? > If matching, it will break the j loop then. There is no chance to j++ in the loop header. So I do j++ here, and it will not skip any items. > also some easy it'd be easier to read if you identify different cpu maps > somehow.. like evlist_cpus and evsel_cpus or such > OK. I will change the name. > I have no way of testing this.. could you please add automated test for this > one? OK Thanks, Kan > > thanks, > jirka > > > + i++; > > + } else > > + evsel->cpus->map[i++] = -1; > > + break; > > + } > > + } > > + > > SNIP -- 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/