From patchwork Thu Nov 7 07:15:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13865954 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 A6EB5D5AE6F for ; Thu, 7 Nov 2024 07:29:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:To:From:Subject :References:Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=KYK64IbVI+oTr67YzD9eKbuyvUN57DhW3er38c63SVk=; b=ny8zSVcmmYCc8k/XqtNDP6UjqG 4p+z/sDbl0KWL72RF5Oi22suxGLTpue5OOh4PIksQQB7Cmr4yv4y3YcwBkZ/QB3aSkdj2OVFySVZx YsFnHnxcltdjCCT0TeB0ACQQQdQK4qshbI7+dCKTiYINc/Z7Tyiq9xz/SLQfUKy4+bB49326FqmZr 7vhv7hECS9RtZ99OhNehytjtvb5kKyQeWTOaocGV4/hpxMguSG21CJnG1M+/M11fHXwVnE+MDDyqA Dlmjm5qsPNh3hTDr8+W5468oz7fWRhX03v9sz7Nc/lnUmpbO9QAkPTJlnLmHlWfG13XbPPYpRlQru rxQtbSaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t8wwk-00000005zRR-3NAH; Thu, 07 Nov 2024 07:28:50 +0000 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t8wkc-00000005wxN-32uJ for linux-arm-kernel@lists.infradead.org; Thu, 07 Nov 2024 07:16:20 +0000 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-6e59dc7df64so8863647b3.1 for ; Wed, 06 Nov 2024 23:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730963777; x=1731568577; darn=lists.infradead.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=KYK64IbVI+oTr67YzD9eKbuyvUN57DhW3er38c63SVk=; b=koEUr6a+f4byEreO1i4FBx/whHynuFNhr9G2pATpG7V+Fwbk4alBETsdr9eobMLCQw KM2MgxWdNu8tFjuoyaiCsKm43vSgbSqpLoZ8XVE+Is1tFfkuo4ZBs5kMfvSZtR9deOJG DEFO0CP7gFri3/PjMpw5YVw9Qn5TziuLzTxlTZDel4rbTwMXOtgII7Emqu6TvPeQX6Nq n0p8ZhMnCvKXS95aK/4P3Exl+OyQ8DfCxy0JrIXK2lRkgOMum7ssKcKcCHpND3eWH9oU DJVMxQlmQ0Tw2kBFZet8AD09d77NwC8cAU2Xkp6AjkfrdTUaIskmiJESwT1ztR4oyojd o+nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730963777; x=1731568577; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KYK64IbVI+oTr67YzD9eKbuyvUN57DhW3er38c63SVk=; b=T33GZAvClYS/OKV+pbvb8UKARN5ZHTi1SuSKMoFIi0kgofKPkk/2TfGXJPywJhTrT/ yFyseNYMleRRylcvmQKwvle36Opps7HJDr6nKx1z64j4xYKbkshHj6wXvCBNTTP1+LBk PdBZwow4mwr2+E6xTAvD/JeaWGL5u1x1Z3HfP5e5TsUu8A4Vo5oNZfBkBewz/Ntj4TA/ D5ZidcVQqmvXaVowHeE8QQVdBDE24gDs2It/bmNNouB3Nnot+KPRY1TvraX6Ri/1EER1 Oi2UOlZ2DPBb8NNusCT/ojMuonR2CkRC462pvhP0plt94iHPc9BT8gfZe8ONPqLZUwp5 941Q== X-Forwarded-Encrypted: i=1; AJvYcCUUNwtZc7NhIMvmS8d2uLmpwrcHMlkCKXEwuqzM7OkGO9/539h3In7lDjoMeqfbUcpx15qk/Mo7TTNE5URjfHex@lists.infradead.org X-Gm-Message-State: AOJu0YycLkQXQVvPk8QCtXgtxN5IvyUS7G65uoeoeFqYS7FPfCUTiOKN ahg51j+XX+1KODaNTQdoUKZ9Pi7hb8vv0k1L0xa36Tk02kZjwEHy/6kG14nqFRPQ1OXox37Wh9W BV5dU4w== X-Google-Smtp-Source: AGHT+IEE1yqKHgqlv5intPfLwYeQKNT3vieLxoXotrZ7qIt8KVtU6GVAtqxkz210BAUWXZlbW1ErAef+mNNv X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:acc7:bda:7167:18d8]) (user=irogers job=sendgmr) by 2002:a81:b512:0:b0:6ea:881b:b545 with SMTP id 00721157ae682-6ead646907emr707b3.4.1730963776837; Wed, 06 Nov 2024 23:16:16 -0800 (PST) Date: Wed, 6 Nov 2024 23:15:59 -0800 In-Reply-To: <20241107071600.9082-1-irogers@google.com> Message-Id: <20241107071600.9082-7-irogers@google.com> Mime-Version: 1.0 References: <20241107071600.9082-1-irogers@google.com> X-Mailer: git-send-email 2.47.0.199.ga7371fff76-goog Subject: [PATCH v1 6/7] perf jevents: Add map_for_cpu From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , Paul Walmsley , Palmer Dabbelt , Albert Ou , Huacai Chen , Bibo Mao , Athira Rajeev , Ben Zong-You Xie , Alexandre Ghiti , Sandipan Das , Benjamin Gray , Xu Yang , Ravi Bangoria , " =?utf-8?q?Cl=C3=A9ment_Le_Goffic?= " , Yicong Yang , "Masami Hiramatsu (Google)" , Dima Kogan , "Dr. David Alan Gilbert" , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241106_231618_903890_B7B075C3 X-CRM114-Status: GOOD ( 14.50 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The PMU is no longer part of the map finding process and for metrics doesn't make sense as they lack a PMU. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/empty-pmu-events.c | 20 +++++++++++++------- tools/perf/pmu-events/jevents.py | 20 +++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/tools/perf/pmu-events/empty-pmu-events.c b/tools/perf/pmu-events/empty-pmu-events.c index 1f7f39a89ffd..2151e8a43f16 100644 --- a/tools/perf/pmu-events/empty-pmu-events.c +++ b/tools/perf/pmu-events/empty-pmu-events.c @@ -503,11 +503,11 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, return 0; } -static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) +static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu) { static struct { const struct pmu_events_map *map; - struct perf_pmu *pmu; + struct perf_cpu cpu; } last_result; static struct { const struct pmu_events_map *map; @@ -515,15 +515,12 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) } last_map_search; static bool has_last_result, has_last_map_search; const struct pmu_events_map *map = NULL; - struct perf_cpu cpu = {-1}; char *cpuid = NULL; size_t i; - if (has_last_result && last_result.pmu == pmu) + if (has_last_result && last_result.cpu.cpu == cpu.cpu) return last_result.map; - if (pmu) - cpu = perf_cpu_map__min(pmu->cpus); cpuid = get_cpuid_allow_env_override(cpu); /* @@ -555,12 +552,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) has_last_map_search = true; } out_update_last_result: - last_result.pmu = pmu; + last_result.cpu = cpu; last_result.map = map; has_last_result = true; return map; } +static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) +{ + struct perf_cpu cpu = {-1}; + + if (pmu) + cpu = perf_cpu_map__min(pmu->cpus); + return map_for_cpu(cpu); +} + const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) { const struct pmu_events_map *map = map_for_pmu(pmu); diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 17cd1b1c6b66..6d6780ca0889 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -1019,11 +1019,11 @@ int pmu_metrics_table__for_each_metric(const struct pmu_metrics_table *table, return 0; } -static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) +static const struct pmu_events_map *map_for_cpu(struct perf_cpu cpu) { static struct { const struct pmu_events_map *map; - struct perf_pmu *pmu; + struct perf_cpu cpu; } last_result; static struct { const struct pmu_events_map *map; @@ -1031,15 +1031,12 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) } last_map_search; static bool has_last_result, has_last_map_search; const struct pmu_events_map *map = NULL; - struct perf_cpu cpu = {-1}; char *cpuid = NULL; size_t i; - if (has_last_result && last_result.pmu == pmu) + if (has_last_result && last_result.cpu.cpu == cpu.cpu) return last_result.map; - if (pmu) - cpu = perf_cpu_map__min(pmu->cpus); cpuid = get_cpuid_allow_env_override(cpu); /* @@ -1071,12 +1068,21 @@ static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) has_last_map_search = true; } out_update_last_result: - last_result.pmu = pmu; + last_result.cpu = cpu; last_result.map = map; has_last_result = true; return map; } +static const struct pmu_events_map *map_for_pmu(struct perf_pmu *pmu) +{ + struct perf_cpu cpu = {-1}; + + if (pmu) + cpu = perf_cpu_map__min(pmu->cpus); + return map_for_cpu(cpu); +} + const struct pmu_events_table *perf_pmu__find_events_table(struct perf_pmu *pmu) { const struct pmu_events_map *map = map_for_pmu(pmu);