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 BB3E2C433EF for ; Thu, 30 Dec 2021 07:57:55 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=hrIyZSQIZSPT7FyWm7Er1Zuia5m0mkvAeWadnB9avO8=; b=xm5A2KgQkwCjakXp8rEJAUGOuU Se6AZvKcek7hKFVl3eiGW4C6hxTcfMMpZTXFB8TpgUBULtXAGT/JnHMdXCfHO/81YXBsDzp79txj1 NwjQy82NR1TTz/WoF9fA2zeiiOR0mOhc56dO23uC6IHWGyl/LVLnHH+aqagB4uSCTaJw/FU5l9ZXe ediJDon6Q931rg+MjI0P48IGBAnTA/m09rWzkFbIyckQ/jVf5Hm2q0JmPwoVUzNqkD8h/JxqE2tT6 8rldNU8vPweKegpbBAnSiXRDc7YL9jvL2Cz7Na1+Fpwe/36hNEAOgWFki1o0yEEau6LoFoniLeKfh z+fqD7MA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2qIV-003w6K-26; Thu, 30 Dec 2021 07:56:29 +0000 Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2plf-003kNH-46 for linux-arm-kernel@lists.infradead.org; Thu, 30 Dec 2021 07:22:34 +0000 Received: by mail-yb1-xb49.google.com with SMTP id e2-20020a25d302000000b0060c57942183so22012736ybf.18 for ; Wed, 29 Dec 2021 23:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Uc3y2XubM268HoD+IkmNJwiXqvYvgqQuPR9NEiJZLmc=; b=UU9Pps5USbCJB4bMY54SQPTOXdYoggeqA3PNH6FHoGJpEWCJcemclzPo3evy9MM9Tw PFOiwuSZsYroPQcFSKpYwzB5ZfSSv7dGEOOoc0quUBwg0uPmdY/GztO9m31OIDCEizc5 hmU2hv7EmRANtiTJbTXr1O6zp+YQKyUFq1Bp/1PWYZsvlNdDknRqgzMZDggwdNMcknXP B25Dix/qD0wblGheSYh68qCPU2AIrUHzja2sf/xFx5v79YZKDINeE/Whrz2w7VYK29k2 ZPf1nH4RVbBAyH4aci0WckZMl/RZDFVZ/ryooqZ7YSTBO4Vajwx0CbhtYW9Jw+0WKqfl BI0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Uc3y2XubM268HoD+IkmNJwiXqvYvgqQuPR9NEiJZLmc=; b=nHH4RgSn+aNs8bfCI+8vWOr2rMEqOtI6Fpc5p+6xppThLVoLLq2KFdpvJaH86gYzEX fLy/R3vgcxHAD8n+FQZYWlyw7CrjHI/QQrwVse4bzDtA9Jk+zsZRfNf706TRZkFgRYXD 4eRqfmrWCZq51qo1R/cWw5vIX4bxZ+AxkJfV6cQawwwVSIlnALgG0M4xBaW2321CKqdT bCjZyxkbVn2YdzHWdLpcdOoflBgvbhSp01WgU09T/Dzh9KrNBicLRUKDJl+dyrp4etSn 7WIocl7eXn6dW8r09XCp1owhk5F0BTaRY+5E3Ct3eyeu65cwv6aSf+ca4saU3FYn4HGy li0g== X-Gm-Message-State: AOAM532jmwmuX+7EsG1AZBjgfexkOndP64p68kpu3airpFm1HMCf/ifE FtsmDzkj8OlXtsiycWfuMPjGZAUCuVH2 X-Google-Smtp-Source: ABdhPJzmwD+JdTmKcnf+ab8su0Q2JjY8n7yE3uUXboDJEjQ387d40mnduQF8z1OV90YmVB5fjNjmBzrjrFrO X-Received: from irogers.svl.corp.google.com ([2620:15c:2cd:202:31c4:9539:dba1:a82b]) (user=irogers job=sendgmr) by 2002:a25:cc55:: with SMTP id l82mr29556005ybf.433.1640848949072; Wed, 29 Dec 2021 23:22:29 -0800 (PST) Date: Wed, 29 Dec 2021 23:20:26 -0800 In-Reply-To: <20211230072030.302559-1-irogers@google.com> Message-Id: <20211230072030.302559-46-irogers@google.com> Mime-Version: 1.0 References: <20211230072030.302559-1-irogers@google.com> X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH v3 44/48] perf bpf: Rename cpu to cpu_map_idx From: Ian Rogers To: Andi Kleen , Jiri Olsa , Namhyung Kim , John Garry , Kajol Jain , "Paul A . Clarke" , Arnaldo Carvalho de Melo , 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 Cc: eranian@google.com, Ian Rogers X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211229_232231_226753_90003370 X-CRM114-Status: GOOD ( 16.60 ) 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="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Synchronize the caller in evsel with the called function. Shorten 3 lines of code in bperf_read by using perf_cpu_map__for_each_cpu. This code is frequently using variables named cpu as cpu map indices, which doesn't matter as all CPUs are in the CPU map. It is strange in some cases the cpumap is used at all. Signed-off-by: Ian Rogers --- tools/perf/util/bpf_counter.c | 16 +++++++--------- tools/perf/util/bpf_counter.h | 4 ++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tools/perf/util/bpf_counter.c b/tools/perf/util/bpf_counter.c index c17d4a43ce06..ae5bd87ff020 100644 --- a/tools/perf/util/bpf_counter.c +++ b/tools/perf/util/bpf_counter.c @@ -265,7 +265,7 @@ static int bpf_program_profiler__read(struct evsel *evsel) return 0; } -static int bpf_program_profiler__install_pe(struct evsel *evsel, int cpu, +static int bpf_program_profiler__install_pe(struct evsel *evsel, int cpu_map_idx, int fd) { struct bpf_prog_profiler_bpf *skel; @@ -277,7 +277,7 @@ static int bpf_program_profiler__install_pe(struct evsel *evsel, int cpu, assert(skel != NULL); ret = bpf_map_update_elem(bpf_map__fd(skel->maps.events), - &cpu, &fd, BPF_ANY); + &cpu_map_idx, &fd, BPF_ANY); if (ret) return ret; } @@ -566,12 +566,12 @@ static int bperf__load(struct evsel *evsel, struct target *target) return err; } -static int bperf__install_pe(struct evsel *evsel, int cpu, int fd) +static int bperf__install_pe(struct evsel *evsel, int cpu_map_idx, int fd) { struct bperf_leader_bpf *skel = evsel->leader_skel; return bpf_map_update_elem(bpf_map__fd(skel->maps.events), - &cpu, &fd, BPF_ANY); + &cpu_map_idx, &fd, BPF_ANY); } /* @@ -623,9 +623,7 @@ static int bperf__read(struct evsel *evsel) case BPERF_FILTER_GLOBAL: assert(i == 0); - num_cpu = all_cpu_map->nr; - for (j = 0; j < num_cpu; j++) { - cpu = all_cpu_map->map[j]; + perf_cpu_map__for_each_cpu(cpu, j, all_cpu_map) { perf_counts(evsel->counts, cpu, 0)->val = values[cpu].counter; perf_counts(evsel->counts, cpu, 0)->ena = values[cpu].enabled; perf_counts(evsel->counts, cpu, 0)->run = values[cpu].running; @@ -757,11 +755,11 @@ static inline bool bpf_counter_skip(struct evsel *evsel) evsel->follower_skel == NULL; } -int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd) +int bpf_counter__install_pe(struct evsel *evsel, int cpu_map_idx, int fd) { if (bpf_counter_skip(evsel)) return 0; - return evsel->bpf_counter_ops->install_pe(evsel, cpu, fd); + return evsel->bpf_counter_ops->install_pe(evsel, cpu_map_idx, fd); } int bpf_counter__load(struct evsel *evsel, struct target *target) diff --git a/tools/perf/util/bpf_counter.h b/tools/perf/util/bpf_counter.h index 65ebaa6694fb..4dbf26408b69 100644 --- a/tools/perf/util/bpf_counter.h +++ b/tools/perf/util/bpf_counter.h @@ -16,7 +16,7 @@ typedef int (*bpf_counter_evsel_op)(struct evsel *evsel); typedef int (*bpf_counter_evsel_target_op)(struct evsel *evsel, struct target *target); typedef int (*bpf_counter_evsel_install_pe_op)(struct evsel *evsel, - int cpu, + int cpu_map_idx, int fd); struct bpf_counter_ops { @@ -40,7 +40,7 @@ int bpf_counter__enable(struct evsel *evsel); int bpf_counter__disable(struct evsel *evsel); int bpf_counter__read(struct evsel *evsel); void bpf_counter__destroy(struct evsel *evsel); -int bpf_counter__install_pe(struct evsel *evsel, int cpu, int fd); +int bpf_counter__install_pe(struct evsel *evsel, int cpu_map_idx, int fd); #else /* HAVE_BPF_SKEL */ -- 2.34.1.448.ga2b2bfdf31-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel