mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
perf cpumap: Use perf_cpu_map__for_each_cpu when possible
Rather than manually iterating the CPU map, use perf_cpu_map__for_each_cpu(). When possible tidy local variables. Reviewed-by: James Clark <james.clark@arm.com> Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexandre Ghiti <alexghiti@rivosinc.com> Cc: Andrew Jones <ajones@ventanamicro.com> Cc: André Almeida <andrealmeid@igalia.com> Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com> Cc: Atish Patra <atishp@rivosinc.com> Cc: Changbin Du <changbin.du@huawei.com> Cc: Darren Hart <dvhart@infradead.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ingo Molnar <mingo@redhat.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: K Prateek Nayak <kprateek.nayak@amd.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mike Leach <mike.leach@linaro.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Paran Lee <p4ranlee@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ravi Bangoria <ravi.bangoria@amd.com> Cc: Sandipan Das <sandipan.das@amd.com> Cc: Sean Christopherson <seanjc@google.com> Cc: Steinar H. Gunderson <sesse@google.com> Cc: Suzuki Poulouse <suzuki.poulose@arm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Will Deacon <will@kernel.org> Cc: Yang Jihong <yangjihong1@huawei.com> Cc: Yang Li <yang.lee@linux.alibaba.com> Cc: Yanteng Si <siyanteng@loongson.cn> Link: https://lore.kernel.org/r/20240202234057.2085863-9-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
954ac1b4a7
commit
71bc3ac8e8
@@ -147,12 +147,12 @@ static bool valid_kwork_class_type(enum kwork_class_type type)
|
||||
|
||||
static int setup_filters(struct perf_kwork *kwork)
|
||||
{
|
||||
u8 val = 1;
|
||||
int i, nr_cpus, key, fd;
|
||||
struct perf_cpu_map *map;
|
||||
|
||||
if (kwork->cpu_list != NULL) {
|
||||
fd = bpf_map__fd(skel->maps.perf_kwork_cpu_filter);
|
||||
int idx, nr_cpus;
|
||||
struct perf_cpu_map *map;
|
||||
struct perf_cpu cpu;
|
||||
int fd = bpf_map__fd(skel->maps.perf_kwork_cpu_filter);
|
||||
|
||||
if (fd < 0) {
|
||||
pr_debug("Invalid cpu filter fd\n");
|
||||
return -1;
|
||||
@@ -165,8 +165,8 @@ static int setup_filters(struct perf_kwork *kwork)
|
||||
}
|
||||
|
||||
nr_cpus = libbpf_num_possible_cpus();
|
||||
for (i = 0; i < perf_cpu_map__nr(map); i++) {
|
||||
struct perf_cpu cpu = perf_cpu_map__cpu(map, i);
|
||||
perf_cpu_map__for_each_cpu(cpu, idx, map) {
|
||||
u8 val = 1;
|
||||
|
||||
if (cpu.cpu >= nr_cpus) {
|
||||
perf_cpu_map__put(map);
|
||||
@@ -181,6 +181,8 @@ static int setup_filters(struct perf_kwork *kwork)
|
||||
}
|
||||
|
||||
if (kwork->profile_name != NULL) {
|
||||
int key, fd;
|
||||
|
||||
if (strlen(kwork->profile_name) >= MAX_KWORKNAME) {
|
||||
pr_err("Requested name filter %s too large, limit to %d\n",
|
||||
kwork->profile_name, MAX_KWORKNAME - 1);
|
||||
|
||||
Reference in New Issue
Block a user