Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp221172rdg; Thu, 12 Oct 2023 03:58:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPh8xPuclG3GFhlPaVxM2l68FhH93/5DODVNFRrs9OIEX7g/EVFC6NS1tbhL+wv78p1ln0 X-Received: by 2002:a17:90a:8001:b0:27d:348:94a8 with SMTP id b1-20020a17090a800100b0027d034894a8mr4145600pjn.6.1697108328933; Thu, 12 Oct 2023 03:58:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697108328; cv=none; d=google.com; s=arc-20160816; b=vqtIY3NX5nZGNr+REki982kJ/y4AJDwSvL0G+0TavdhgMimpHGal6CTWOntpzao+ls mzaUbK/qRzIo7dY4wO2lMo+QvuvHcnLrqf3YuUC3lCg768Ozh4XgwqgJB7i2NoT9fPOp Wc76GW3ze3qneNSC0G4zY7UkxGyxGZfNqaEl24zVcg5UpO3fL53jbhakysePLBUWoXId YuG1k6CLqw+/FlAL46tfXmQB2g8dNE0m9pQOmV3Vz+KRYTjGSFvuT3DBHivCsDy2/HL6 TFp+nivKnnGii1OSVHa2GHHgHrEp+WMOP2AII3fc2EkDeoltYSf4q6NM4j2i7smyaEXL WEcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=BQqB5sw7HkdRaFVu2hRSs754mjZmP65ZHs/hSeZJ6/Y=; fh=nHRLoP6tmTBVIKBu2+Zw6dBF7WZ/0rVcW0H44UO5YIQ=; b=n1CFR3A9XeymzWWoEbhpW8a6Ao4hD5CUDXNdT9pIV4daDGlTn0U0fXixEm47wDQeFr 5ZggqgDbgA2UMddn/xmvbvb0tzXfLX+l0d6pg7ndIgrGBFUH24t9woJo8oA4P5y/E11z sHbYUjnDGG4NzVSgzarwIhD/j4YvYwHxxuF5ZKSHNhPArRRSDJzAJX0ygKhU1LXo83yG 82zbBn7hiZClADUy9bp8ELJ1Lg9MwsaQ2sDYyyizB8Ss66Jt8KBwpw6wyLjvAm2db+Uq 8IHZvzHx3dNg8ZmT0Eyu/HVzRnE4mY7KGtxxQE3uZDMPR1yD9/mGoQJz0koZzpNJttee Xhag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q6-20020a170902dac600b001bc079974dbsi2097798plx.355.2023.10.12.03.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 03:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 3577A80A308B; Thu, 12 Oct 2023 03:58:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377991AbjJLK6g (ORCPT + 99 others); Thu, 12 Oct 2023 06:58:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347143AbjJLK6f (ORCPT ); Thu, 12 Oct 2023 06:58:35 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DCB60B7 for ; Thu, 12 Oct 2023 03:58:33 -0700 (PDT) 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 3A46213D5; Thu, 12 Oct 2023 03:59:14 -0700 (PDT) Received: from [10.163.62.137] (unknown [10.163.62.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E2053F762; Thu, 12 Oct 2023 03:58:31 -0700 (PDT) Message-ID: <999f01f4-4f3f-4a55-ae43-7316c46581c5@arm.com> Date: Thu, 12 Oct 2023 16:28:28 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] driver: perf: arm_pmuv3: Read PMMIR_EL1 unconditionally To: Mark Rutland , James Clark Cc: linux-arm-kernel@lists.infradead.org, zhangshaokun@hisilicon.com, Will Deacon , linux-kernel@vger.kernel.org References: <20231009075631.193208-1-anshuman.khandual@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 12 Oct 2023 03:58:46 -0700 (PDT) On 10/12/23 14:54, Mark Rutland wrote: > On Mon, Oct 09, 2023 at 09:59:19AM +0100, James Clark wrote: >> On 09/10/2023 08:56, Anshuman Khandual wrote: >>> PMMIR_EL1 needs to be captured in 'armpmu->reg_pmmir', for all appropriate >>> PMU version implementations where the register is available and reading it >>> is valid . Hence checking for bus slot event presence is redundant and can >>> be dropped. >>> >>> Cc: Will Deacon >>> Cc: Mark Rutland >>> Cc: linux-arm-kernel@lists.infradead.org >>> Cc: linux-kernel@vger.kernel.org >>> Signed-off-by: Anshuman Khandual >>> --- >>> This applies on v6.6-rc5. >>> >>> drivers/perf/arm_pmuv3.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/perf/arm_pmuv3.c b/drivers/perf/arm_pmuv3.c >>> index 1e72b486c033..9fc1b6da5106 100644 >>> --- a/drivers/perf/arm_pmuv3.c >>> +++ b/drivers/perf/arm_pmuv3.c >>> @@ -1129,7 +1129,7 @@ static void __armv8pmu_probe_pmu(void *info) >>> pmceid, ARMV8_PMUV3_MAX_COMMON_EVENTS); >>> >>> /* store PMMIR register for sysfs */ >>> - if (is_pmuv3p4(pmuver) && (pmceid_raw[1] & BIT(31))) >>> + if (is_pmuv3p4(pmuver)) >>> cpu_pmu->reg_pmmir = read_pmmir(); >>> else >>> cpu_pmu->reg_pmmir = 0; >> >> >> This does have the side effect of showing non-zero values in caps/slots >> even when the STALL_SLOT event isn't implemented. I think that's the >> scenario that the original commit (f5be3a61fd) was trying to avoid: >> >> /sys/bus/event_source/devices/armv8_pmuv3_0/caps/slots is exposed >> under sysfs. [If] Both ARMv8.4-PMU and STALL_SLOT event are >> implemented, it returns the slots from PMMIR_EL1, otherwise it will >> return 0. > > We check for the STALL_SLOT event becuase (at the time) the ARM ARM said: > > | If STALL_SLOT is not implemented, it is IMPLEMENTATION DEFINED whether the > | PMMIR System registers are implemented. > > ... and this was necessary to avoid triggering an UNDEFINED exception if we > attempted to read PMMIR on a CPU which didn't actually implement it. > > See: > > https://lore.kernel.org/linux-arm-kernel/20200720101518.GA11516@willie-the-truck/ > https://lore.kernel.org/linux-arm-kernel/20200720105019.GA54220@C02TD0UTHF1T.local/ > https://lore.kernel.org/linux-arm-kernel/20200720105410.GD11516@willie-the-truck/ > > As I promised in that thread, I did raise that with our architects. According > to the bug I filed against the architecture, this was tightened such that > ARMv8.4-PMU gauaranteed the presence of PMMIR, and that should have changed > between the G.a and G.b releases of the ARM ARM. > > Anshuman, can you go and check that the wording did chaange between G.a and G.b? G.a was the last ARM ARM version to have that STALL_SLOT event dependency for PMMIR_EL1 system register which got dropped in G.b version ARM ARM. > > Assuming it did (and the wording in the latest J.a release is also fine), > please update the commit message to describe the history above. Sure, will update the commit message as follows. driver: perf: arm_pmuv3: Read PMMIR_EL1 unconditionally PMMIR_EL1 needs to be captured in 'armpmu->reg_pmmir', for all appropriate PMU version implementations i.e FEAT_PMUv3p4 onward, where the register is available and reading it is valid. However STALL_SLOT event dependency was included earlier as per previous version ARM ARM wordings [1]. But later i.e ARM ARM version G.a onward, STALL_SLOT event dependency for PMMIR_EL1 register has been dropped. Checking for that dependency is now redundant, and should be dropped. [1] https://lore.kernel.org/linux-arm-kernel/20200720105410.GD11516@willie-the-truck/