From patchwork Wed Dec 13 19:51:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 13491837 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 8505AC4167B for ; Wed, 13 Dec 2023 19:53:02 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fz7lh6VGfYD1RAhcDxu4OOMpLl1S6ricG0bzYOBHvPk=; b=CsVsoTBTR0vFfZ QsYpvEZ3w50E9kHeNrG6o2WqhT13jsCGxPiI6SYPHh3d56iv1jeMvxudLW71ztAFQpDbIQTfF+1Fp ALjWQRIiDTfqmz2nqbBeO9YTvRkgRt0ogQZahsFaHZ50BLpcP6uiKNCkffTbieUKrN0+C6OkHiI2u XtOJ8N48VAQX5dm2ULUS9HFaqBTtNf3I1BgpM+osfUSkd0LzSy0FTQiYWzLtp9d2NMEsAJL54wT+O QuiPnpuqhOnwZdKgH/s/ITYw5k+AcF5Fokx4fIolVYgWC10s9vHfpCoDzF2svCkPIAMQMWIwCFXRp PuemlgTteTJIs89RlDpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDVHX-00FtSy-2i; Wed, 13 Dec 2023 19:52:35 +0000 Received: from mgamail.intel.com ([192.198.163.8]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDVHG-00Ft7M-2T for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2023 19:52:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702497139; x=1734033139; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OgOFyuxRKcLOzqxt3C1lozEyX1aFj1Oa+GydWrLoLmI=; b=Z7Bc/8P3z1N+kBQYuo66HLUercm5ubxltMb37mMQnAN1bGwOsgS5IELR NlctDe8JtT1L8FIq+IoM+sCeV0Um6gbW424ZyLiID0EHnjXQS072ojNkc 51HwqQLdQS3qFXej/hWB69tzAfL2P/t2XQdQas7yhSH+YHJ4TqVJQyeYE JwEJ9fgFq1f5YKzYZ7CnUT39NoBScwagBWqiVuLn9az12PuinvjdMyW7M E6J5PcLFMWVhxQYHqIzDeYEDoOLbhB5hbqSyoTQa3Qg8sypN14E9skN+/ wNaump2W+OZxjKQOxp3KL9bVUNjzZkJdY8Zne3umv2gachR5fP+TEu20n A==; X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="8412941" X-IronPort-AV: E=Sophos;i="6.04,273,1695711600"; d="scan'208";a="8412941" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 11:52:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="917772573" X-IronPort-AV: E=Sophos;i="6.04,273,1695711600"; d="scan'208";a="917772573" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga001.fm.intel.com with ESMTP; 13 Dec 2023 11:52:07 -0800 From: kan.liang@linux.intel.com To: acme@kernel.org, irogers@google.com, peterz@infradead.org, mingo@redhat.com, namhyung@kernel.org, jolsa@kernel.org, adrian.hunter@intel.com, john.g.garry@oracle.com, will@kernel.org, james.clark@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, yuhaixin.yhx@linux.alibaba.com, renyu.zj@linux.alibaba.com, tmricht@linux.ibm.com, ravi.bangoria@amd.com, atrajeev@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Kan Liang Subject: [PATCH V3 5/7] perf mem: Clean up is_mem_loads_aux_event() Date: Wed, 13 Dec 2023 11:51:52 -0800 Message-Id: <20231213195154.1085945-6-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231213195154.1085945-1-kan.liang@linux.intel.com> References: <20231213195154.1085945-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_115218_897026_3A13487F X-CRM114-Status: GOOD ( 11.84 ) 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 From: Kan Liang The aux_event can be retrieved from the perf_pmu now. Implement a generic support. Reviewed-by: Ian Rogers Tested-by: Ravi Bangoria Signed-off-by: Kan Liang --- tools/perf/arch/x86/util/mem-events.c | 23 ++++------------------- tools/perf/util/mem-events.c | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/tools/perf/arch/x86/util/mem-events.c b/tools/perf/arch/x86/util/mem-events.c index b776d849fc64..62df03e91c7e 100644 --- a/tools/perf/arch/x86/util/mem-events.c +++ b/tools/perf/arch/x86/util/mem-events.c @@ -1,11 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -#include "util/pmu.h" -#include "util/pmus.h" -#include "util/env.h" -#include "map_symbol.h" -#include "mem-events.h" #include "linux/string.h" -#include "env.h" +#include "util/map_symbol.h" +#include "util/mem-events.h" +#include "mem-events.h" + #define MEM_LOADS_AUX 0x8203 @@ -28,16 +26,3 @@ struct perf_mem_event perf_mem_events_amd[PERF_MEM_EVENTS__MAX] = { E(NULL, NULL, NULL, false, 0), E("mem-ldst", "%s//", NULL, false, 0), }; - -bool is_mem_loads_aux_event(struct evsel *leader) -{ - struct perf_pmu *pmu = perf_pmus__find("cpu"); - - if (!pmu) - pmu = perf_pmus__find("cpu_core"); - - if (pmu && !perf_pmu__have_event(pmu, "mem-loads-aux")) - return false; - - return leader->core.attr.config == MEM_LOADS_AUX; -} diff --git a/tools/perf/util/mem-events.c b/tools/perf/util/mem-events.c index 32890848bb3d..7d7df3d0b2b9 100644 --- a/tools/perf/util/mem-events.c +++ b/tools/perf/util/mem-events.c @@ -107,9 +107,19 @@ static const char *perf_pmu__mem_events_name(int i, struct perf_pmu *pmu) return NULL; } -__weak bool is_mem_loads_aux_event(struct evsel *leader __maybe_unused) +bool is_mem_loads_aux_event(struct evsel *leader) { - return false; + struct perf_pmu *pmu = leader->pmu; + struct perf_mem_event *e; + + if (!pmu || !pmu->mem_events) + return false; + + e = &pmu->mem_events[PERF_MEM_EVENTS__LOAD]; + if (!e->aux_event) + return false; + + return leader->core.attr.config == e->aux_event; } int perf_pmu__mem_events_parse(struct perf_pmu *pmu, const char *str)