Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1829185pxb; Mon, 12 Apr 2021 07:40:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTATC5jxI9ksV2LwJEI1QYBdiShHD6XVkoBLFQ2SWN5xt66zyy68Uk/HsQdsAbBzeO0GAz X-Received: by 2002:a17:906:235b:: with SMTP id m27mr4951180eja.336.1618238416375; Mon, 12 Apr 2021 07:40:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618238416; cv=none; d=google.com; s=arc-20160816; b=ibtgGvWn/CrNkHicoUvrfjYfLC/whERA6U6S6UkywAHcULaoKMEJJJrqLQUFnxnJ6Q b7ekexYpY74ilqh9fmJIpnDBCVqsvkbAXw6v5g3IFVzd0VIdh4L3nKxfZ1LkV3fAijRx EmLxNwii4PqStVqdeAUq7VVzQZqo/TGfvWk04NMBRGpYKp1qHYjbVrB/1IpCNiBESG7O U0aZB6IrTCRq0vwQ6rfpfL1qgtSjiipWYMl3CPnAvBuJxueNQe5OyBpZ73ItEMmTnwcU LrrPQJAL1m/pF3lHPEuw3sSkZtCO7cwA4/pk3ZvwxAL8O2WL2zGUm7C0AFhYma2LmIqS pTEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=TyvE70EexcVBXW9mNFWfNNvCfefnTcyrbE8JgIs+XRk=; b=vog+oOSpY3NVUZWy+FRkmgsrgGdYK6TF432fDV0JjyiqqFCgixQCn0dcVSdgGvTpvu U096D9F6uMUA/jB61Y8p7qbbROwjkMo0I+C2Al+WlK1V262Wa0g51fL2qW7ww33FDbQv W3P1RgyW+MEFWIvtrDKglPEMfdMwlT8TMTgKc3n6g4z90ojsy7PtP6FyPs4lkz5qvNne XbJT5AvTEWOWXQAIOsp7347yN1E+PL1mQonmjaqk4PdHN9BYnjYG5di+6aINjzaIyDXT 5DRCwOM5vX/nOEd7Q2hk7WBERa0kiyiYLHqwLc25R0ae34Udd7QbOfRFA2+eqV6x49Py T9Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si7184057edy.78.2021.04.12.07.39.53; Mon, 12 Apr 2021 07:40:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242453AbhDLOi6 (ORCPT + 99 others); Mon, 12 Apr 2021 10:38:58 -0400 Received: from mga09.intel.com ([134.134.136.24]:29197 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242380AbhDLOil (ORCPT ); Mon, 12 Apr 2021 10:38:41 -0400 IronPort-SDR: xmczutqcrLW9GoPqqWN90a4tH7SFabGPfXJpsB/oroRxkdKqzn2Eo3B3rcDsQd88q1DCU0d5qI TVK5VGBmZQ+A== X-IronPort-AV: E=McAfee;i="6200,9189,9952"; a="194317955" X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="194317955" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Apr 2021 07:38:23 -0700 IronPort-SDR: PA03nVguKJNX5n+A8j7f4YzZnKh++qTAoW3YHl0NVXdj88AQXi1e/9zkQC+bVPDbr1/nTc+LNp 8Ubci8gRZxFA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,216,1613462400"; d="scan'208";a="398392769" Received: from otc-lr-04.jf.intel.com ([10.54.39.41]) by orsmga002.jf.intel.com with ESMTP; 12 Apr 2021 07:38:23 -0700 From: kan.liang@linux.intel.com To: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org Cc: acme@kernel.org, tglx@linutronix.de, bp@alien8.de, namhyung@kernel.org, jolsa@redhat.com, ak@linux.intel.com, yao.jin@linux.intel.com, alexander.shishkin@linux.intel.com, adrian.hunter@intel.com, ricardo.neri-calderon@linux.intel.com, Kan Liang Subject: [PATCH V6 08/25] perf/x86: Hybrid PMU support for hardware cache event Date: Mon, 12 Apr 2021 07:30:48 -0700 Message-Id: <1618237865-33448-9-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1618237865-33448-1-git-send-email-kan.liang@linux.intel.com> References: <1618237865-33448-1-git-send-email-kan.liang@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kan Liang The hardware cache events are different among hybrid PMUs. Each hybrid PMU should have its own hw cache event table. Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Kan Liang --- arch/x86/events/core.c | 5 ++--- arch/x86/events/perf_event.h | 9 +++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 3b99864..a5f8a5e 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -376,8 +376,7 @@ set_ext_hw_attr(struct hw_perf_event *hwc, struct perf_event *event) return -EINVAL; cache_result = array_index_nospec(cache_result, PERF_COUNT_HW_CACHE_RESULT_MAX); - val = hw_cache_event_ids[cache_type][cache_op][cache_result]; - + val = hybrid_var(event->pmu, hw_cache_event_ids)[cache_type][cache_op][cache_result]; if (val == 0) return -ENOENT; @@ -385,7 +384,7 @@ set_ext_hw_attr(struct hw_perf_event *hwc, struct perf_event *event) return -EINVAL; hwc->config |= val; - attr->config1 = hw_cache_extra_regs[cache_type][cache_op][cache_result]; + attr->config1 = hybrid_var(event->pmu, hw_cache_extra_regs)[cache_type][cache_op][cache_result]; return x86_pmu_extra_regs(val, event); } diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 93d6479..10ef244 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -640,6 +640,15 @@ struct x86_hybrid_pmu { int num_counters; int num_counters_fixed; struct event_constraint unconstrained; + + u64 hw_cache_event_ids + [PERF_COUNT_HW_CACHE_MAX] + [PERF_COUNT_HW_CACHE_OP_MAX] + [PERF_COUNT_HW_CACHE_RESULT_MAX]; + u64 hw_cache_extra_regs + [PERF_COUNT_HW_CACHE_MAX] + [PERF_COUNT_HW_CACHE_OP_MAX] + [PERF_COUNT_HW_CACHE_RESULT_MAX]; }; static __always_inline struct x86_hybrid_pmu *hybrid_pmu(struct pmu *pmu) -- 2.7.4