From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25D16C433F5 for ; Tue, 11 Jan 2022 20:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=27xSQ04bwuYJD6SED8orYTYR0MfuQdbJNiZ9CmatCVA=; b=NEu+3ZOiAjcS6G vphRLYxLv9rSxjTiT/7DHHbanAeE9vYYRCAohVT7+TFLnflykBYTGSpd5OGLrkUYjKixDzgOHpb3T 0kXE+nz4UGfRIBHAC+6yrx5Na4QA94yH0ki2MUtgD6CmLzlRzV72XD3WkBNg5vF3pzOgM/cWNTT4a cs0fGAdXHuI9kL7fqxguWZcmoe375V5B7B6sa5JGl+UAN/fHt7C6RLLZtYBZHCezgEYxVN+nOSGUz rCTKmfm4Rdz8Tn/BL7FVnoI2/gU4++iNFPOytMAbFq3x4bOx3kSCS/gMjw1WB24TzoSD8fMRkVF00 Rrs6oClVj78ZXPMNRhoA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7NKY-00HU5o-Va; Tue, 11 Jan 2022 20:01:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7NKV-00HU5D-HZ for linux-arm-kernel@bombadil.infradead.org; Tue, 11 Jan 2022 20:01:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=j80TUajUgqEsV5qWoGVJR4BBajyDg6oFCHDHCTiQ4K4=; b=lTUGJ3e3Y4+fs6D8ttNDCnGlVo p+bnYG4jvR2WneJOsc2BN0/zpyZ40FjSydUGwVtDfhO40c/TsZycUuI1FI+HEZWuNOoVcp7fNxOWE aEAI8uL0EolIIpAmJxGUey7skQ+1tlY4LCUl6CYm+y/FJT+LXq5yh1HV9GomeDqRJ87zqEejoBC7a MaxbvjBxGghkqpeUrXgA+9yygBrq7Uq5WIN+lkXAbGOUiRqZ7BelRL6ytWUBo7pbwSZRz7F7Wxrjt mdy3bYSdmDdKPcdaIL8gQsB/D1H/4NOwYHjgTWWOiaxEqWdiI+GwihPAZNwmlkISRTE6L9O3k1+ae aC9p/edQ==; Received: from [179.97.37.151] (helo=quaco.ghostprotocols.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7NKS-000f9y-O7; Tue, 11 Jan 2022 20:01:13 +0000 Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 7190040714; Tue, 11 Jan 2022 17:01:10 -0300 (-03) Date: Tue, 11 Jan 2022 17:01:10 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Riccardo Mancini , Kan Liang , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Vineet Singh , James Clark , Mathieu Poirier , Suzuki K Poulose , Mike Leach , Leo Yan , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, zhengjun.xing@intel.com, eranian@google.com Subject: Re: [PATCH v4 48/48] perf cpumap: Give CPUs their own type. Message-ID: References: <20220105061351.120843-1-irogers@google.com> <20220105061351.120843-49-irogers@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Em Tue, Jan 11, 2022 at 11:16:16AM -0800, Ian Rogers escreveu: > On Mon, Jan 10, 2022 at 11:50 AM Arnaldo Carvalho de Melo > wrote: > > > > Em Tue, Jan 04, 2022 at 10:13:51PM -0800, Ian Rogers escreveu: > > > A common problem is confusing CPU map indices with the CPU, by wrappi= ng > > > the CPU with a struct then this is avoided. This approach is similar = to > > > atomic_t. > > > > This one needed this to build with BUILD_BPF_SKEL=3D1, please check, I'= ll > > soon push this to tmp.perf/perf_cpu so that you can take a look and test > > it. > = > = > Thanks Arnaldo, I did eye-ball one issue where cpu_map__default_new's > behavior would be impacted (nr would be 1 rather than nr_cpus). The > fix is: > = > --- a/tools/lib/perf/cpumap.c > +++ b/tools/lib/perf/cpumap.c > @@ -18,7 +18,7 @@ static struct perf_cpu_map *perf_cpu_map__alloc(int nr_= cpus) > if (!cpus) > return NULL; > = > - cpus->nr =3D 1; > + cpus->nr =3D nr_cpus; > refcount_set(&cpus->refcnt, 1); > return cpus; > } > Could you add that into this patch as well? Sure. I=B4m now running perf-test after each of those csets, so far so good. = > Thanks, > Ian > = > = > > - Arnaldo > > > > diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counte= r.c > > index 80d1a3a31052fe55..328479df5e16a638 100644 > > --- a/tools/perf/util/bpf_counter.c > > +++ b/tools/perf/util/bpf_counter.c > > @@ -540,7 +540,7 @@ static int bperf__load(struct evsel *evsel, struct = target *target) > > filter_type =3D=3D BPERF_FILTER_TGID) > > key =3D evsel->core.threads->map[i].pid; > > else if (filter_type =3D=3D BPERF_FILTER_CPU) > > - key =3D evsel->core.cpus->map[i]; > > + key =3D evsel->core.cpus->map[i].cpu; > > else > > break; > > > > @@ -584,7 +584,7 @@ static int bperf_sync_counters(struct evsel *evsel) > > > > num_cpu =3D all_cpu_map->nr; > > for (i =3D 0; i < num_cpu; i++) { > > - cpu =3D all_cpu_map->map[i]; > > + cpu =3D all_cpu_map->map[i].cpu; > > bperf_trigger_reading(evsel->bperf_leader_prog_fd, cpu); > > } > > return 0; > > @@ -605,7 +605,7 @@ static int bperf__disable(struct evsel *evsel) > > static int bperf__read(struct evsel *evsel) > > { > > struct bperf_follower_bpf *skel =3D evsel->follower_skel; > > - __u32 num_cpu_bpf =3D cpu__max_cpu(); > > + __u32 num_cpu_bpf =3D cpu__max_cpu().cpu; > > struct bpf_perf_event_value values[num_cpu_bpf]; > > int reading_map_fd, err =3D 0; > > __u32 i; > > @@ -615,6 +615,7 @@ static int bperf__read(struct evsel *evsel) > > reading_map_fd =3D bpf_map__fd(skel->maps.accum_readings); > > > > for (i =3D 0; i < bpf_map__max_entries(skel->maps.accum_reading= s); i++) { > > + struct perf_cpu entry; > > __u32 cpu; > > > > err =3D bpf_map_lookup_elem(reading_map_fd, &i, values); > > @@ -624,14 +625,15 @@ static int bperf__read(struct evsel *evsel) > > case BPERF_FILTER_GLOBAL: > > assert(i =3D=3D 0); > > > > - perf_cpu_map__for_each_cpu(cpu, j, all_cpu_map)= { > > + perf_cpu_map__for_each_cpu(entry, j, all_cpu_ma= p) { > > + cpu =3D entry.cpu; > > perf_counts(evsel->counts, cpu, 0)->val= =3D values[cpu].counter; > > perf_counts(evsel->counts, cpu, 0)->ena= =3D values[cpu].enabled; > > perf_counts(evsel->counts, cpu, 0)->run= =3D values[cpu].running; > > } > > break; > > case BPERF_FILTER_CPU: > > - cpu =3D evsel->core.cpus->map[i]; > > + cpu =3D evsel->core.cpus->map[i].cpu; > > perf_counts(evsel->counts, i, 0)->val =3D value= s[cpu].counter; > > perf_counts(evsel->counts, i, 0)->ena =3D value= s[cpu].enabled; > > perf_counts(evsel->counts, i, 0)->run =3D value= s[cpu].running; > > diff --git a/tools/perf/util/bpf_counter_cgroup.c b/tools/perf/util/bpf= _counter_cgroup.c > > index cbc6c2bca488f6bf..631e34a0b66ff084 100644 > > --- a/tools/perf/util/bpf_counter_cgroup.c > > +++ b/tools/perf/util/bpf_counter_cgroup.c > > @@ -48,7 +48,7 @@ static int bperf_load_program(struct evlist *evlist) > > struct cgroup *cgrp, *leader_cgrp; > > __u32 i, cpu; > > __u32 nr_cpus =3D evlist->core.all_cpus->nr; > > - int total_cpus =3D cpu__max_cpu(); > > + int total_cpus =3D cpu__max_cpu().cpu; > > int map_size, map_fd; > > int prog_fd, err; > > > > @@ -125,7 +125,7 @@ static int bperf_load_program(struct evlist *evlist) > > for (cpu =3D 0; cpu < nr_cpus; cpu++) { > > int fd =3D FD(evsel, cpu); > > __u32 idx =3D evsel->core.idx * total_c= pus + > > - evlist->core.all_cpus->map[cpu]; > > + evlist->core.all_cpus->map[cpu]= .cpu; > > > > err =3D bpf_map_update_elem(map_fd, &id= x, &fd, > > BPF_ANY); > > @@ -212,7 +212,7 @@ static int bperf_cgrp__sync_counters(struct evlist = *evlist) > > int prog_fd =3D bpf_program__fd(skel->progs.trigger_read); > > > > for (i =3D 0; i < nr_cpus; i++) { > > - cpu =3D evlist->core.all_cpus->map[i]; > > + cpu =3D evlist->core.all_cpus->map[i].cpu; > > bperf_trigger_reading(prog_fd, cpu); > > } > > > > @@ -245,7 +245,7 @@ static int bperf_cgrp__read(struct evsel *evsel) > > { > > struct evlist *evlist =3D evsel->evlist; > > int i, cpu, nr_cpus =3D evlist->core.all_cpus->nr; > > - int total_cpus =3D cpu__max_cpu(); > > + int total_cpus =3D cpu__max_cpu().cpu; > > struct perf_counts_values *counts; > > struct bpf_perf_event_value *values; > > int reading_map_fd, err =3D 0; > > @@ -272,7 +272,7 @@ static int bperf_cgrp__read(struct evsel *evsel) > > } > > > > for (i =3D 0; i < nr_cpus; i++) { > > - cpu =3D evlist->core.all_cpus->map[i]; > > + cpu =3D evlist->core.all_cpus->map[i].cpu; > > > > counts =3D perf_counts(evsel->counts, i, 0); > > counts->val =3D values[cpu].counter; > > diff --git a/tools/perf/util/bpf_ftrace.c b/tools/perf/util/bpf_ftrace.c > > index 28dc4c60c7884818..d756cc66eef32ae8 100644 > > --- a/tools/perf/util/bpf_ftrace.c > > +++ b/tools/perf/util/bpf_ftrace.c > > @@ -63,7 +63,7 @@ int perf_ftrace__latency_prepare_bpf(struct perf_ftra= ce *ftrace) > > fd =3D bpf_map__fd(skel->maps.cpu_filter); > > > > for (i =3D 0; i < ncpus; i++) { > > - cpu =3D perf_cpu_map__cpu(ftrace->evlist->core.= cpus, i); > > + cpu =3D perf_cpu_map__cpu(ftrace->evlist->core.= cpus, i).cpu; > > bpf_map_update_elem(fd, &cpu, &val, BPF_ANY); > > } > > } > > @@ -122,7 +122,7 @@ int perf_ftrace__latency_read_bpf(struct perf_ftrac= e *ftrace __maybe_unused, > > int i, fd, err; > > u32 idx; > > u64 *hist; > > - int ncpus =3D cpu__max_cpu(); > > + int ncpus =3D cpu__max_cpu().cpu; > > > > fd =3D bpf_map__fd(skel->maps.latency); > > -- = - Arnaldo _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel