From mboxrd@z Thu Jan 1 00:00:00 1970 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 A4279C2BD09 for ; Mon, 1 Jul 2024 17:10:04 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7imHGFarX8d8hhe9UjdiZTtkfMxea2bAKn7J/hN6GDY=; b=eQjTPvzf87KZjSqgMLghFIrErB ZsX2An3G/RRqCwu+77jJvWy8ONn9ORnEy6DhEsT1GtxT0CLdZuvsZxjkt5UD9Bv9L1vXl6kyJQGr/ t2VrMmbJ0LVwUI0aF4hhCNBZAoUEBF6JRovlc5P6+0TUWKs2tCV3q7wuuWqopDEwxKtOQ6mFEcrvi AAmGUvUCu8q2rW2J3IUiqm3y6FRJ2AUAR0IKeTHP1Jmznx9zp70nuGvblmJ5H0jp11OsLkU8VforZ eRdCt93Y3hsRGNtnKWkZdH4FNIejN4yan3FVfXtWWtX5OSTzsczYBAQUTgv+pqBBOwjOTP/tvN3FI lL0XYwOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOKXI-00000004G6J-3Irq; Mon, 01 Jul 2024 17:09:52 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOKX8-00000004G3B-1uqq for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 17:09:43 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 13A7C339; Mon, 1 Jul 2024 10:10:06 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0F5003F766; Mon, 1 Jul 2024 10:09:37 -0700 (PDT) Date: Mon, 1 Jul 2024 18:09:35 +0100 From: Mark Rutland To: "Rob Herring (Arm)" Cc: Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , James Clark , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kvmarm@lists.linux.dev Subject: Re: [PATCH v2 01/12] perf: arm_pmuv3: Avoid assigning fixed cycle counter with threshold Message-ID: References: <20240626-arm-pmu-3-9-icntr-v2-0-c9784b4f4065@kernel.org> <20240626-arm-pmu-3-9-icntr-v2-1-c9784b4f4065@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240626-arm-pmu-3-9-icntr-v2-1-c9784b4f4065@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_100942_609120_A8612059 X-CRM114-Status: GOOD ( 25.57 ) 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 On Wed, Jun 26, 2024 at 04:32:25PM -0600, Rob Herring (Arm) wrote: > If the user has requested a counting threshold for the CPU cycles event, > then the fixed cycle counter can't be assigned as it lacks threshold > support. Currently, the thresholds will work or not randomly depending > on which counter the event is assigned. > > While using thresholds for CPU cycles doesn't make much sense, it can be > useful for testing purposes. > > Fixes: 816c26754447 ("arm64: perf: Add support for event counting threshold") > Signed-off-by: Rob Herring (Arm) Acked-by: Mark Rutland Mark. > --- > This should go to 6.10 and stable. It is also a dependency for ICNTR > support. > > v2: > - Add and use armv8pmu_event_get_threshold() helper. > > v1: https://lore.kernel.org/all/20240611155012.2286044-1-robh@kernel.org/ > --- > drivers/perf/arm_pmuv3.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c > index 23fa6c5da82c..8ed5c3358920 100644 > --- a/drivers/perf/arm_pmuv3.c > +++ b/drivers/perf/arm_pmuv3.c > @@ -338,6 +338,11 @@ static bool armv8pmu_event_want_user_access(struct perf_event *event) > return ATTR_CFG_GET_FLD(&event->attr, rdpmc); > } > > +static u32 armv8pmu_event_get_threshold(struct perf_event_attr *attr) > +{ > + return ATTR_CFG_GET_FLD(attr, threshold); > +} > + > static u8 armv8pmu_event_threshold_control(struct perf_event_attr *attr) > { > u8 th_compare = ATTR_CFG_GET_FLD(attr, threshold_compare); > @@ -941,7 +946,8 @@ static int armv8pmu_get_event_idx(struct pmu_hw_events *cpuc, > unsigned long evtype = hwc->config_base & ARMV8_PMU_EVTYPE_EVENT; > > /* Always prefer to place a cycle counter into the cycle counter. */ > - if (evtype == ARMV8_PMUV3_PERFCTR_CPU_CYCLES) { > + if ((evtype == ARMV8_PMUV3_PERFCTR_CPU_CYCLES) && > + !armv8pmu_event_get_threshold(&event->attr)) { > if (!test_and_set_bit(ARMV8_IDX_CYCLE_COUNTER, cpuc->used_mask)) > return ARMV8_IDX_CYCLE_COUNTER; > else if (armv8pmu_event_is_64bit(event) && > @@ -1033,7 +1039,7 @@ static int armv8pmu_set_event_filter(struct hw_perf_event *event, > * If FEAT_PMUv3_TH isn't implemented, then THWIDTH (threshold_max) will > * be 0 and will also trigger this check, preventing it from being used. > */ > - th = ATTR_CFG_GET_FLD(attr, threshold); > + th = armv8pmu_event_get_threshold(attr); > if (th > threshold_max(cpu_pmu)) { > pr_debug("PMU event threshold exceeds max value\n"); > return -EINVAL; > > -- > 2.43.0 >