Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp171608rdg; Tue, 10 Oct 2023 07:16:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgGbfEk1uzb22Zt2X0E2ThQsJCD9WP6r5u+9g4PK8lICywNar6BdhxVuTrKY4LJ0/mLHb1 X-Received: by 2002:a17:90a:a090:b0:25d:eca9:1621 with SMTP id r16-20020a17090aa09000b0025deca91621mr14854117pjp.6.1696947395985; Tue, 10 Oct 2023 07:16:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696947395; cv=none; d=google.com; s=arc-20160816; b=XBPAr7mMh89pGjalxIE+kW/e5mrmOVo3X9Iy4MrC2H32Lhl9R4MycIc0k2TolrEBDl h3glprkIFP+mlNWS8+Io3gR6NYvntNgGzq1WNEie/OqJ7uR5ytple0x35pscLiQj8WFk URfUzZ0qd6tPG5TyALtJJG8b9d1sWTjMdocv9ZEB/rg699p2eU7g8p0gcvtSuPLwAZ4z uqA84LyM65O5u7g9nBs/bVBySzfb2Y0E4/vVJCg1S04FFmBxXiFEYaSl3aPo+P15u9h6 YjsRyoIP3onCT5NnlsH7MhKxN9VM9LJlIoY9eMYKIa1nDm9DedHBiS3pLcGFQBTjDnMY gV8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=L90XoOP5mHEc54+SWfhMCgSANt5SkvmF5U9KEzp1CN8=; fh=KPH1zn9mqFgiFPF2qyJsNS10z8lwHzAKvHk/mLtdl1A=; b=kP2rXKKKISNYRSBFN56qg8JPu3Jb5iIpbnBak391MyfqjqBKppcbwQMXGn5PAlx/hv Vbn4zVA4WejrofgsvEXNdI7CW1OTZ0haVTs9YpC9xmjpC+ZBNKn3IPBaCbZ7w1Da6cgz RaKnHevije3rR9zSSwMDaG+ttWksO7VPTIVbTeZUf8XYFtex9jQUh9hh+arAr+m6qxdl LmuIw1oPmaw11AtnknU/TXbhMn7jkdmNTWa/lLvelfCjROFETY4AnbYtyyJeieP3Ag0d /E9atbzPxXeOhvMxR7VSbxtVsuuOtSUUHrOjtv+BknV2GInRaAxx5bYaNBmLfBNNUKq/ z4gQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id lx14-20020a17090b4b0e00b0027383ac5ebcsi8798456pjb.130.2023.10.10.07.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 07:16:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 8E832805EAD8; Tue, 10 Oct 2023 07:16:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232783AbjJJOQQ (ORCPT + 99 others); Tue, 10 Oct 2023 10:16:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbjJJOQP (ORCPT ); Tue, 10 Oct 2023 10:16:15 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BD3AD99; Tue, 10 Oct 2023 07:16:12 -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 1B99E1FB; Tue, 10 Oct 2023 07:16:52 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id CFC033F762; Tue, 10 Oct 2023 07:16:08 -0700 (PDT) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, suzuki.poulose@arm.com Cc: James Clark , Catalin Marinas , Will Deacon , Jonathan Corbet , Russell King , Marc Zyngier , Oliver Upton , James Morse , Zenghui Yu , Mark Rutland , Zaid Al-Bassam , Geert Uytterhoeven , Reiji Watanabe , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v3 0/3] arm64: perf: Add support for event counting threshold Date: Tue, 10 Oct 2023 15:15:40 +0100 Message-Id: <20231010141551.2262059-1-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 10 Oct 2023 07:16:25 -0700 (PDT) X-Spam-Level: ** Changes since v2: * Split threshold_control attribute into two, threshold_compare and threshold_count so that it's easier to use * Add some notes to the first commit message and the cover letter about the behavior in KVM * Update the docs commit with regards to the split attribute Changes since v1: * Fix build on aarch32 by disabling FEAT_PMUv3_TH and splitting event type mask between the platforms * Change armv8pmu_write_evtype() to take unsigned long instead of u64 so it isn't unnecessarily wide on aarch32 * Add UL suffix to aarch64 event type mask definition ---- FEAT_PMUv3_TH (Armv8.8) is a new feature that allows conditional counting of PMU events depending on how much the event increments on a single cycle. Two new config fields for perf_event_open have been added, and a PMU cap file for reading the max_threshold. See the second commit message and the docs in the last commit for more details. The feature is not currently supported on KVM guests, and PMMIR is set to read as zero, so it's not advertised as available. But it can be added at a later time. Writes to PMEVTYPER.TC and TH from guests are ignored. The change has been validated on the Arm FVP model: # Zero values, works as expected (as before). $ perf stat -e dtlb_walk/threshold=0,threshold_compare=0/ -- true 5962 dtlb_walk/threshold=0,threshold_compare=0/ # Threshold >= 255 causes count to be 0 because dtlb_walk doesn't # increase by more than 1 per cycle. $ perf stat -e dtlb_walk/threshold=255,threshold_compare=2/ -- true 0 dtlb_walk/threshold=255,threshold_compare=2/ # Keeping comparison as >= but lowering the threshold to 1 makes the # count return. $ perf stat -e dtlb_walk/threshold=1,threshold_compare=2/ -- true 6329 dtlb_walk/threshold=1,threshold_compare=2/ James Clark (3): arm: perf: Include threshold control fields valid in PMEVTYPER mask arm64: perf: Add support for event counting threshold Documentation: arm64: Document the PMU event counting threshold feature Documentation/arch/arm64/perf.rst | 56 +++++++++++++++++++++ arch/arm/include/asm/arm_pmuv3.h | 3 ++ arch/arm64/include/asm/arm_pmuv3.h | 4 ++ arch/arm64/kvm/pmu-emul.c | 1 + arch/arm64/kvm/sys_regs.c | 1 + drivers/perf/arm_pmuv3.c | 79 +++++++++++++++++++++++++++++- include/linux/perf/arm_pmuv3.h | 4 +- 7 files changed, 146 insertions(+), 2 deletions(-) base-commit: 94f6f0550c625fab1f373bb86a6669b45e9748b3 -- 2.34.1