Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3588602pxf; Mon, 5 Apr 2021 16:43:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWnWJFZqewZR2hmncvCCdXukiFakg+SldZrJmaX+iY73sls9A122ZkKIxATCcuKHCYH8t3 X-Received: by 2002:a05:6e02:c09:: with SMTP id d9mr21350244ile.62.1617666186400; Mon, 05 Apr 2021 16:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617666186; cv=none; d=google.com; s=arc-20160816; b=z+I1oDwGVo3OcalZAp5QbAMnKuil4EYEm1bb1uCd3qzcwo9+7qDS+KFTnGQcek9qIv xmKj8N0/hk+OoGlPMxbIt47NczelzufMZn64xgguQriqpN7Gw3Att5KIsLsFe2Ow4gKD vfSe+NgwuwAOyYYj8OcC0S55LwaHNqbAGJXswLDcRoJxfTJK3us0AD5ahsDnITYC4Mkz GsxYEfofulRlGUKCwgraHDCNtoW/XhlRpBW94FqBA7SPwXz/PeGbyCXiz6yYWuicd/W1 Hk/rcaytYW+owtUc0fj1rj9g1yC1xHlNek+4epffcyK1WxPC3dtgDyrFUKzr9TtqZVZX dPag== 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=pqYIZCfh4hD1ZR/taazbXRDWjLxzaJE8qzcN5FnSdUI=; b=E2f/+/dxQghXMNq8q0Gzv1ez+JIBPbdJ/m9haihAAIwT89HSAhldjtx4whZUyMxe5y pP4t+BwflLnSZZwOqFX730SNmlIKjh6LmzWLYMiAfa2x1ga+Rvn4jHtUw0hrN8/yR8sC V2InSVYewvhdmBG8MRncYRFO7LZD0ndIOmY8ZzWs8lczH6+RaLa6PlahyN9sya6aJq5F tUw+l9ILvj04ZWTYEm41BgozBLk12Ia1OzwLqxcZpD9/Y5NDIbd2l1GgK5gxe+keyOQu QXYvSTMvcRvaBLWvKAiGJx33YcH4kpk/LX4UJ+rDVbwv0LFgtWRbjggCJ/DHv+zteofW k0ow== 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 s190si17111446ios.22.2021.04.05.16.42.54; Mon, 05 Apr 2021 16:43:06 -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 S241551AbhDEPS2 (ORCPT + 99 others); Mon, 5 Apr 2021 11:18:28 -0400 Received: from mga18.intel.com ([134.134.136.126]:43416 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241525AbhDEPSW (ORCPT ); Mon, 5 Apr 2021 11:18:22 -0400 IronPort-SDR: 58Q981QLIa694jcZxWwn+GxQ+OebsCIxSigFI4z6XThZP/RRP14uJTCTvNR87t/BwtCiCBcTq/ F7tAPonYp4HA== X-IronPort-AV: E=McAfee;i="6000,8403,9945"; a="180402950" X-IronPort-AV: E=Sophos;i="5.81,306,1610438400"; d="scan'208";a="180402950" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2021 08:18:13 -0700 IronPort-SDR: nGYsBn/tFd/v9eSNjT0MurqvDsRDSshbeNWsFTiHUTzR/ON0NEw47Pil2buEODg+DuQs1Td8K7 ZbAWrVmI1JAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,306,1610438400"; d="scan'208";a="379006276" Received: from otc-lr-04.jf.intel.com ([10.54.39.41]) by orsmga003.jf.intel.com with ESMTP; 05 Apr 2021 08:18:13 -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 V5 09/25] perf/x86: Hybrid PMU support for event constraints Date: Mon, 5 Apr 2021 08:10:51 -0700 Message-Id: <1617635467-181510-10-git-send-email-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1617635467-181510-1-git-send-email-kan.liang@linux.intel.com> References: <1617635467-181510-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 events are different among hybrid PMUs. Each hybrid PMU should use its own event constraints. Reviewed-by: Andi Kleen Signed-off-by: Kan Liang --- arch/x86/events/core.c | 3 ++- arch/x86/events/intel/core.c | 5 +++-- arch/x86/events/intel/ds.c | 5 +++-- arch/x86/events/perf_event.h | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index d71ca69..b866867 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -1526,6 +1526,7 @@ void perf_event_print_debug(void) struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu); int num_counters = hybrid(cpuc->pmu, num_counters); int num_counters_fixed = hybrid(cpuc->pmu, num_counters_fixed); + struct event_constraint *pebs_constraints = hybrid(cpuc->pmu, pebs_constraints); unsigned long flags; int idx; @@ -1545,7 +1546,7 @@ void perf_event_print_debug(void) pr_info("CPU#%d: status: %016llx\n", cpu, status); pr_info("CPU#%d: overflow: %016llx\n", cpu, overflow); pr_info("CPU#%d: fixed: %016llx\n", cpu, fixed); - if (x86_pmu.pebs_constraints) { + if (pebs_constraints) { rdmsrl(MSR_IA32_PEBS_ENABLE, pebs); pr_info("CPU#%d: pebs: %016llx\n", cpu, pebs); } diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 39f57ae..d304ba3 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3136,10 +3136,11 @@ struct event_constraint * x86_get_event_constraints(struct cpu_hw_events *cpuc, int idx, struct perf_event *event) { + struct event_constraint *event_constraints = hybrid(cpuc->pmu, event_constraints); struct event_constraint *c; - if (x86_pmu.event_constraints) { - for_each_event_constraint(c, x86_pmu.event_constraints) { + if (event_constraints) { + for_each_event_constraint(c, event_constraints) { if (constraint_match(c, event->hw.config)) { event->hw.flags |= c->flags; return c; diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 312bf3b..f1402bc 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -959,13 +959,14 @@ struct event_constraint intel_spr_pebs_event_constraints[] = { struct event_constraint *intel_pebs_constraints(struct perf_event *event) { + struct event_constraint *pebs_constraints = hybrid(event->pmu, pebs_constraints); struct event_constraint *c; if (!event->attr.precise_ip) return NULL; - if (x86_pmu.pebs_constraints) { - for_each_event_constraint(c, x86_pmu.pebs_constraints) { + if (pebs_constraints) { + for_each_event_constraint(c, pebs_constraints) { if (constraint_match(c, event->hw.config)) { event->hw.flags |= c->flags; return c; diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 203c165..c32e9dc 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -649,6 +649,8 @@ struct x86_hybrid_pmu { [PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_OP_MAX] [PERF_COUNT_HW_CACHE_RESULT_MAX]; + struct event_constraint *event_constraints; + struct event_constraint *pebs_constraints; }; static __always_inline struct x86_hybrid_pmu *hybrid_pmu(struct pmu *pmu) -- 2.7.4