From patchwork Wed Jan 8 14:28:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13931052 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 62CC8E77188 for ; Wed, 8 Jan 2025 14:32:56 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tGOb+QzXOCupJHbixt2wd4hm1wKT1vTFMOcKSfrV7BU=; b=HsWtGTzGV1fp2SQteDYAvHrFDI Ek+0P6FmeHrWH9fcrK2PAGyqQ+ddqnNEdXLF+rRhbnRFTrJhTNb+rGp7ArJHFsL/8UcAxuwhoDx6U /eZeZPXopYhY9kCeyAnsxPb0IAEv+VxSgrrJ/V7CXCgVElE9Xo3rV6fE/yGnKDNaZykOyO1x6StmG WCmN1me1GxDtG8/x7KFSHNv/yNe6IChKtFnUQdnuC04B4qQolxKhLHSlhxosiDbDUoCtF9Sjmbeyb FgjAp4shNdT2j4+XO/q76PMZSxDT2gnmolbnsaNoLV4kX+L5yMkLS4A0OEdM9JOCXT0bDSrXbiGgu I6fF5xzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVX6v-00000008nrb-04n3; Wed, 08 Jan 2025 14:32:41 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVX4Y-00000008nDm-3o7Y for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2025 14:30:16 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-436345cc17bso122176065e9.0 for ; Wed, 08 Jan 2025 06:30:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736346613; x=1736951413; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tGOb+QzXOCupJHbixt2wd4hm1wKT1vTFMOcKSfrV7BU=; b=cMxUjcF8RT2n4ml4eVzRq8NVhQELzu0YahWoWQ0wkOZbnv4iiMcsUjFDuzH0cABOil E7kXy4FA8GS9UX9zmWqkoLDXZgXzP+VN67/UPGRclk6ypmzqUOLmywVeBmHETrwe1kkL 8LXaMM0OI6JpjGZP3kGgsgDvfCumpR797R/x8IVT2Tpzm+DOsZceVk7+eTjAE4ly4Sfj 1LHqRuhCLuffRFJvNii6DZIpTWC3Sx/6yfcx4zVNdM6wwsD9UWVKLZYBSBQ0Ktj8B8uv XudUHRgNwlF0Wak3vZf9Ew3/y5w2ZBHAda4tdYsswjclQFRV2xWuVCYXVnJrtCB2NLlp wrlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736346613; x=1736951413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tGOb+QzXOCupJHbixt2wd4hm1wKT1vTFMOcKSfrV7BU=; b=tNpaeKNRSriBIIrUyEzhJXCSKItYEUTBbue4OFZGkvEFQ9TxkUbNbJ+gDR1xUtkZmt zAFu5OdcCb8TaRGkPKhYiLRDFPYjgy122Ng2ifU1kXDtTsAFQvaKDch2wqLYxCci+aSt 6sRf90Cqp7EOm2Hz0IciHuBqBiQNNvwx7Uf6ZLc/zD5r2JBUmd48PsQuz9V9fRDWa51l ZZ7nBh3lf63yR3CAgFSvL2s0/mqgQlelPb6rZkwN2iTbWHpFgVDYHiOvYYTSmwE4UP6B CTbKH0Rh1EiZhJZLyMdTrc+oVFp8nbcHC4iT6pBuD4s6LSS58rST1IjC0eWo0zOHjGu5 CR3A== X-Gm-Message-State: AOJu0Yw5yITLgJR7H60oymrqtcwp1+dNDBGMUMzUQ9tKAV9EOLS+nNZZ hYUFxssFJffDetosPhx9T0kgLfD18EgKMUzCBOTADROIIpiZIq/51RfEsXNY1Ft/ovoPqQA4L2h K X-Gm-Gg: ASbGnctCqWa7O1kyIkYFoezBoPPXcXBA0II7h9BKzT8S6s8LcFKO2ElK20UK8wv0lIY idkjEzx7XzqXhlM5CHbQHazyqcnCMddgDNzpQKo9rJDJwHoQn4JVyTMIqTd2CeB28+F4OR+neb4 xZsQpK8MdILdu058wX6ZWq9B/njaN+sOLA9ROsD0ZYIttBPJpUNSE8tKetsDmPHxZvPVkx0DmzC Bk2Akf6XL6mWQA0d7g7I1pCMjhPa6aHoUUkNCg/B7vW6pjTQKMvnlj5 X-Google-Smtp-Source: AGHT+IHN1A9cX6z/xhhtgrQjHkaDM0PpDq23z/ArfmpMTg/+JIa+MQk4qZUtvdK5AFfi/widPNwZ7g== X-Received: by 2002:a05:600c:1d07:b0:434:9934:575 with SMTP id 5b1f17b1804b1-436e26a8f4dmr28940535e9.16.1736346612923; Wed, 08 Jan 2025 06:30:12 -0800 (PST) Received: from pop-os.. ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2ddccf4sm22836965e9.19.2025.01.08.06.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 06:30:12 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com, namhyung@kernel.org, acme@kernel.org Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , Michael Petlan , Veronika Molnarova , Athira Rajeev , Thomas Richter , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 1/5] perf: arm_spe: Add format option for discard mode Date: Wed, 8 Jan 2025 14:28:56 +0000 Message-Id: <20250108142904.401139-2-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108142904.401139-1-james.clark@linaro.org> References: <20250108142904.401139-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_063014_947604_9C10B0C2 X-CRM114-Status: GOOD ( 19.85 ) 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 FEAT_SPEv1p2 (optional from Armv8.6) adds a discard mode that allows all SPE data to be discarded rather than written to memory. Add a format bit for this mode. If the mode isn't supported, the format bit isn't published and attempts to use it will result in -EOPNOTSUPP. Allocating an aux buffer is still allowed even though it won't be written to so that old tools continue to work, but updated tools can choose to skip this step. Signed-off-by: James Clark --- drivers/perf/arm_spe_pmu.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/perf/arm_spe_pmu.c b/drivers/perf/arm_spe_pmu.c index fd5b78732603..f5e6878db9d6 100644 --- a/drivers/perf/arm_spe_pmu.c +++ b/drivers/perf/arm_spe_pmu.c @@ -85,6 +85,7 @@ struct arm_spe_pmu { #define SPE_PMU_FEAT_LDS (1UL << 4) #define SPE_PMU_FEAT_ERND (1UL << 5) #define SPE_PMU_FEAT_INV_FILT_EVT (1UL << 6) +#define SPE_PMU_FEAT_DISCARD (1UL << 7) #define SPE_PMU_FEAT_DEV_PROBED (1UL << 63) u64 features; @@ -193,6 +194,9 @@ static const struct attribute_group arm_spe_pmu_cap_group = { #define ATTR_CFG_FLD_store_filter_CFG config /* PMSFCR_EL1.ST */ #define ATTR_CFG_FLD_store_filter_LO 34 #define ATTR_CFG_FLD_store_filter_HI 34 +#define ATTR_CFG_FLD_discard_CFG config /* PMBLIMITR_EL1.FM = DISCARD */ +#define ATTR_CFG_FLD_discard_LO 35 +#define ATTR_CFG_FLD_discard_HI 35 #define ATTR_CFG_FLD_event_filter_CFG config1 /* PMSEVFR_EL1 */ #define ATTR_CFG_FLD_event_filter_LO 0 @@ -216,6 +220,7 @@ GEN_PMU_FORMAT_ATTR(store_filter); GEN_PMU_FORMAT_ATTR(event_filter); GEN_PMU_FORMAT_ATTR(inv_event_filter); GEN_PMU_FORMAT_ATTR(min_latency); +GEN_PMU_FORMAT_ATTR(discard); static struct attribute *arm_spe_pmu_formats_attr[] = { &format_attr_ts_enable.attr, @@ -228,6 +233,7 @@ static struct attribute *arm_spe_pmu_formats_attr[] = { &format_attr_event_filter.attr, &format_attr_inv_event_filter.attr, &format_attr_min_latency.attr, + &format_attr_discard.attr, NULL, }; @@ -238,6 +244,9 @@ static umode_t arm_spe_pmu_format_attr_is_visible(struct kobject *kobj, struct device *dev = kobj_to_dev(kobj); struct arm_spe_pmu *spe_pmu = dev_get_drvdata(dev); + if (attr == &format_attr_discard.attr && !(spe_pmu->features & SPE_PMU_FEAT_DISCARD)) + return 0; + if (attr == &format_attr_inv_event_filter.attr && !(spe_pmu->features & SPE_PMU_FEAT_INV_FILT_EVT)) return 0; @@ -502,6 +511,12 @@ static void arm_spe_perf_aux_output_begin(struct perf_output_handle *handle, u64 base, limit; struct arm_spe_pmu_buf *buf; + if (ATTR_CFG_GET_FLD(&event->attr, discard)) { + limit = FIELD_PREP(PMBLIMITR_EL1_FM, PMBLIMITR_EL1_FM_DISCARD); + limit |= PMBLIMITR_EL1_E; + goto out_write_limit; + } + /* Start a new aux session */ buf = perf_aux_output_begin(handle, event); if (!buf) { @@ -743,6 +758,10 @@ static int arm_spe_pmu_event_init(struct perf_event *event) !(spe_pmu->features & SPE_PMU_FEAT_FILT_LAT)) return -EOPNOTSUPP; + if (ATTR_CFG_GET_FLD(&event->attr, discard) && + !(spe_pmu->features & SPE_PMU_FEAT_DISCARD)) + return -EOPNOTSUPP; + set_spe_event_has_cx(event); reg = arm_spe_event_to_pmscr(event); if (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT)) @@ -1027,6 +1046,9 @@ static void __arm_spe_pmu_dev_probe(void *info) if (FIELD_GET(PMSIDR_EL1_ERND, reg)) spe_pmu->features |= SPE_PMU_FEAT_ERND; + if (spe_pmu->pmsver >= ID_AA64DFR0_EL1_PMSVer_V1P2) + spe_pmu->features |= SPE_PMU_FEAT_DISCARD; + /* This field has a spaced out encoding, so just use a look-up */ fld = FIELD_GET(PMSIDR_EL1_INTERVAL, reg); switch (fld) { From patchwork Wed Jan 8 14:28:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13931053 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 AAF84E77188 for ; Wed, 8 Jan 2025 14:34:07 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=HNDoxPSzJiUeaCyFrkoL/spFd6 4WmNtwsEF4jupsIpubI51f+VCiIJFWM5jn5Vpozh79bWt6Tgoobmf6abuT8ZIKK/8elepCaQly6pZ cP4MEPlKkltFbGAQFhd1E7Ri3KL37Ypf0aAJY+iECV2YVTTQ9Rv0KF9eJQ4V1vw9c63Vx29x+qB9K LcNct4peD5T0F0xsiNZBpe9i+leukuYdbJibDTQFWu+JXRADo0pYXc9jdR+ePE2eblUPjEmt9wEhN VTIMB2tHymvdsBpF+Wkg+lshwR7AZ4xSsBz7KnBdJB1/DwV5zghkXrrkIhWsS8tDA61VpXbHi92el OFQbZe0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVX86-00000008oBG-2i7X; Wed, 08 Jan 2025 14:33:54 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVX4e-00000008nFP-02RV for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2025 14:30:21 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3862d161947so8015804f8f.3 for ; Wed, 08 Jan 2025 06:30:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736346618; x=1736951418; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=JaVUO1ic6wAp1AoTTt3FWzoeEQuUcMa+eGFBW28mDrX8WdfFkP4Y6MJdfLBVm+KHMb 4IqQz962DVjpFaBDhGoSdEt4+3XKlY4fqyjApSGT0l7QdfZTSyR886k7I7Jpt+Tpytnn s+XbryrBAUkePPxMfkgh9iHL6TfBdpkBlbk2ZlOWDOCDDNX7el9I94X6sbB5DRjdwO/W 1H1fk34dXqmOELPpzfXSV/RDyYGoJ86YNu1jvVilou6BM2W9r3U6HCLtHBLYKlfyrW2u aWk1vLG1YMmwUeFcI9+Q1BqDQTFHiDlC3foaMaX679sXeunzboxr5px939FPnLxEnJLu uc6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736346618; x=1736951418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BwyNoR0SnuVGySQmrh3vEyVb1ET66P1aG6x3YnivKGw=; b=BK8Xb3WzuZ0sc0m3aFtxE5+ipYgugio3OsxqtYlIZHHE9f0GZoJi9uylqcaYMcILCg fZEXGg3hfZfA33Rs3ZCBoJ/GCBne+kB+XY5LywE3L2nINmF1eRiqw9hslorG+yqMs/0c 3msO+kcJsyCGVJFbblXWmkBlyHzyzuLpyhUdt4B+p7DsW/u88IGEHjQodO8JL+ci8DVs xzy2ApaMWG6RrbPhAelu3rJU51vbAzwC/qLJ2TW6aotncjkIWOPpEc2+u+F8zKUhSilU YBdaegLlmNB7nEQQin0RueM71y5I/e2moNFzYKCay13tnWkPCKD2LNWtmxg5yCZLPeFv QBhw== X-Gm-Message-State: AOJu0YxBFN856he+kKwBG8zJD8rqqDIR7Lxqirmb4NWm6Rhrq3UUPLoD 3WSZYSSUNAw93bRIi8aJeX8HM8BqM70H/rBvUHRDRCiMdEfEOT3kLjHyXim92xCd/sQ0ItE9O3N 4 X-Gm-Gg: ASbGncuRsr4cAEg9hH63aHqpyqmZjkZYbt7S2BU1mdipKdh2NRxw+/997rIvD5//96h yJX+dEi6SmlgfavR34c/3ZTH8gCBGaZSp89kBgYgBAZwi5cKM0e6iDQbhUKESwqSlR6qhxpQo/C UDA/BfY8MIFA8kurxjnOKi4JkeDPr+kuWEe2P+uJHBs/iD3scS8BM6/1iB1/RJu274rUZSiQzcb 7dyUYh53zj2J1sfA3pIVeDZFsLWSGVcIgqQOlI1uLHZBQczPvEBOp67 X-Google-Smtp-Source: AGHT+IERlWXqo2ZT7VqdO/os7iGNqhnAktOupf4yL+hZB/qbP2byYeljw2KjaDqnGgNolCaFP0shlw== X-Received: by 2002:a05:6000:712:b0:388:da10:ff13 with SMTP id ffacd0b85a97d-38a87306e8bmr2608823f8f.21.1736346618097; Wed, 08 Jan 2025 06:30:18 -0800 (PST) Received: from pop-os.. ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2ddccf4sm22836965e9.19.2025.01.08.06.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 06:30:17 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com, namhyung@kernel.org, acme@kernel.org Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , Veronika Molnarova , Michael Petlan , Athira Rajeev , Thomas Richter , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 2/5] perf docs: arm_spe: Document new discard mode Date: Wed, 8 Jan 2025 14:28:57 +0000 Message-Id: <20250108142904.401139-3-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108142904.401139-1-james.clark@linaro.org> References: <20250108142904.401139-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_063020_047665_4C5D0923 X-CRM114-Status: GOOD ( 16.04 ) 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 Document the flag along with PMU events to hint what it's used for and give an example with other useful options to get minimal output. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/Documentation/perf-arm-spe.txt | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/perf/Documentation/perf-arm-spe.txt b/tools/perf/Documentation/perf-arm-spe.txt index de2b0b479249..37afade4f1b2 100644 --- a/tools/perf/Documentation/perf-arm-spe.txt +++ b/tools/perf/Documentation/perf-arm-spe.txt @@ -150,6 +150,7 @@ arm_spe/load_filter=1,min_latency=10/' pct_enable=1 - collect physical timestamp instead of virtual timestamp (PMSCR.PCT) - requires privilege store_filter=1 - collect stores only (PMSFCR.ST) ts_enable=1 - enable timestamping with value of generic timer (PMSCR.TS) + discard=1 - enable SPE PMU events but don't collect sample data - see 'Discard mode' (PMBLIMITR.FM = DISCARD) +++*+++ Latency is the total latency from the point at which sampling started on that instruction, rather than only the execution latency. @@ -220,6 +221,31 @@ Common errors Increase sampling interval (see above) +PMU events +~~~~~~~~~~ + +SPE has events that can be counted on core PMUs. These are prefixed with +SAMPLE_, for example SAMPLE_POP, SAMPLE_FEED, SAMPLE_COLLISION and +SAMPLE_FEED_BR. + +These events will only count when an SPE event is running on the same core that +the PMU event is opened on, otherwise they read as 0. There are various ways to +ensure that the PMU event and SPE event are scheduled together depending on the +way the event is opened. For example opening both events as per-process events +on the same process, although it's not guaranteed that the PMU event is enabled +first when context switching. For that reason it may be better to open the PMU +event as a systemwide event and then open SPE on the process of interest. + +Discard mode +~~~~~~~~~~~~ + +SPE related (SAMPLE_* etc) core PMU events can be used without the overhead of +collecting sample data if discard mode is supported (optional from Armv8.6). +First run a system wide SPE session (or on the core of interest) using options +to minimize output. Then run perf stat: + + perf record -e arm_spe/discard/ -a -N -B --no-bpf-event -o - > /dev/null & + perf stat -e SAMPLE_FEED_LD SEE ALSO -------- From patchwork Wed Jan 8 14:28:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13931071 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 92EFDE77188 for ; Wed, 8 Jan 2025 14:35:24 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=zmXynLlICIbbCcQhGOwO6HpkQP Fl0a1GZtlFuOHjfVAcYKR01pOZzM2eJLSrmPTeMVUJPmwtMaFbbETk+fIKnL/ukdDdbkL6/moT7Wi 2i9yv5SdWENS4Ia3KMInvyZgWt6osY2o70ITpehnhRXoWBkbaq21HAeK5t+5Q5RAYSnY9V7Sp/mQi 7n5byJT7fs1Ov5CJr8unGTmPakKRxHzL45AG626B53Ts63WAV5uqwwsGNKnhBpENji5pcZbnx5Oiq to4hCuC0Ya0xlYy2CYwfO7iNqU/sEziIhUObotW3aaaoXOqXOm9YTlJh9pnoYNHqNg4rd2gMJYDdk b30KzJhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVX9J-00000008oHu-3CHC; Wed, 08 Jan 2025 14:35:09 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVX4i-00000008nHB-3i6g for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2025 14:30:26 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-436a03197b2so67975035e9.2 for ; Wed, 08 Jan 2025 06:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736346623; x=1736951423; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=XikPvjTcA2yTQoN94U0dPq9jBucApivp9VmPsOaCQH6dZSliv7TTfcd/AzgOE5QkY3 QrDoNR6pW3RFuGex0pyW52cImMFIlA7DkkGVhRKVbh21fRwir6TUNm8OcsJc02ql78gx ZT8T2LP0QfGzQQ9EUI1UX2ooysPZhBM5kGggVIlhwoPfgFA5QFBURpUHjxVkgDCd8WtW S51kSgTmNoiFY0dokzYQvZfpPB5DlIZJzsh2LdzOZGTSPq8uEO62KC1r65EhBQjxC135 jTFq9N3rLJl4VGoZFVQW2IZlrAqy/grOunq/C1R2Ql7OAs/8u8vtV34wEJTt0Hu2Tu8T gVZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736346623; x=1736951423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=I2Qn39K4UzsLsLGtfNH0/R87UIS/L19Vs2Fn7/eQxwo=; b=UJDldrfEdUum7xo86k7nhCqAcjGR9ItrOppC0yv4oFqoLgfX8fm1VxTMdQlld3mciW RP53R0xEgPy7DFpbpAaC08t1LxQSrhotsTaEFoBMf7TRsSWEA5sfDndBYwo8SmekY8qL yLMM6vmNSF2FlP6fQbbQJSPOjpPgcIv4BlQYB3YncgqZrog8AaRoJCJfykYz+ygZdrpx Za6CM3CJKzyuHTeH2ezGtD1ZuMmFKRTG9qUifI/pEMXzCEOh696/6URW/cqG+PvjdlYL JEFOI+TGIxQZ0Q3DujlAel3B8SOHlZUlE7Ta9H0dkcXR+UqF4AXFkX5CEMJbkfTydZnX suKQ== X-Gm-Message-State: AOJu0YxCAh5pqTkASZF4BVloRbGiJGXgR7TgEefsZBddXH1+gZoZSwyT sKj985SDXMb8dgNDTXrDhg3jCJaPX+v46sR4amHpU4YhLwXIfstWriher52X8majpcYfw8HdBxh D X-Gm-Gg: ASbGncv+sJ1MD8CS/dmICvwXDhXnAU3xuBSItnK+otQxGwwEJkzJf/WopiEH0cxwK2R jOK5bAXB3u7Y1MOnGAoY2AbdLUrKBYBc1ngmt+CuK0KflOM4Q4x2xdWtR62RD6rX+oHKNHsGUix cxP0gpvOge1rxxbvenIVi86BNW91yk0LneTmw2oyRvm91fW4+SF0zefvJSK9hzOERz5CBSHp2GX TxnLgN9440XfRGOWpTXXtl4VC4mq0aesCTen3YA/FVyCC38jYbT1Fpz X-Google-Smtp-Source: AGHT+IHQgK8+Yd3JtaxOPOoCOGtnBLuVZ6/cDODvDBysXN7o1PBIvyAUjmPV1obXseFT3h2tmvjLfA== X-Received: by 2002:a05:600c:468a:b0:434:a968:89a3 with SMTP id 5b1f17b1804b1-436e26a78a4mr26241125e9.9.1736346623428; Wed, 08 Jan 2025 06:30:23 -0800 (PST) Received: from pop-os.. ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2ddccf4sm22836965e9.19.2025.01.08.06.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 06:30:23 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com, namhyung@kernel.org, acme@kernel.org Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , Michael Petlan , Veronika Molnarova , Athira Rajeev , Thomas Richter , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 3/5] perf tool: arm-spe: Pull out functions for aux buffer and tracking setup Date: Wed, 8 Jan 2025 14:28:58 +0000 Message-Id: <20250108142904.401139-4-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108142904.401139-1-james.clark@linaro.org> References: <20250108142904.401139-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_063024_943035_D0370E6A X-CRM114-Status: GOOD ( 16.76 ) 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 These won't be used in the next commit in discard mode, so put them in their own functions. No functional changes intended. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/arch/arm64/util/arm-spe.c | 83 +++++++++++++++++----------- 1 file changed, 51 insertions(+), 32 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 22b19dcc6beb..1b543855f206 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -274,33 +274,9 @@ static void arm_spe_setup_evsel(struct evsel *evsel, struct perf_cpu_map *cpus) evsel__set_sample_bit(evsel, PHYS_ADDR); } -static int arm_spe_recording_options(struct auxtrace_record *itr, - struct evlist *evlist, - struct record_opts *opts) +static int arm_spe_setup_aux_buffer(struct record_opts *opts) { - struct arm_spe_recording *sper = - container_of(itr, struct arm_spe_recording, itr); - struct evsel *evsel, *tmp; - struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; bool privileged = perf_event_paranoid_check(-1); - struct evsel *tracking_evsel; - int err; - - sper->evlist = evlist; - - evlist__for_each_entry(evlist, evsel) { - if (evsel__is_aux_event(evsel)) { - if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) { - pr_err("Found unexpected auxtrace event: %s\n", - evsel->pmu->name); - return -EINVAL; - } - opts->full_auxtrace = true; - } - } - - if (!opts->full_auxtrace) - return 0; /* * we are in snapshot mode. @@ -330,6 +306,9 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, pr_err("Failed to calculate default snapshot size and/or AUX area tracing mmap pages\n"); return -EINVAL; } + + pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, + opts->auxtrace_snapshot_size); } /* We are in full trace mode but '-m,xyz' wasn't specified */ @@ -355,14 +334,15 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, } } - if (opts->auxtrace_snapshot_mode) - pr_debug2("%sx snapshot size: %zu\n", ARM_SPE_PMU_NAME, - opts->auxtrace_snapshot_size); + return 0; +} - evlist__for_each_entry_safe(evlist, tmp, evsel) { - if (evsel__is_aux_event(evsel)) - arm_spe_setup_evsel(evsel, cpus); - } +static int arm_spe_setup_tracking_event(struct evlist *evlist, + struct record_opts *opts) +{ + int err; + struct evsel *tracking_evsel; + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; /* Add dummy event to keep tracking */ err = parse_event(evlist, "dummy:u"); @@ -388,6 +368,45 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, return 0; } +static int arm_spe_recording_options(struct auxtrace_record *itr, + struct evlist *evlist, + struct record_opts *opts) +{ + struct arm_spe_recording *sper = + container_of(itr, struct arm_spe_recording, itr); + struct evsel *evsel, *tmp; + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; + + int err; + + sper->evlist = evlist; + + evlist__for_each_entry(evlist, evsel) { + if (evsel__is_aux_event(evsel)) { + if (!strstarts(evsel->pmu->name, ARM_SPE_PMU_NAME)) { + pr_err("Found unexpected auxtrace event: %s\n", + evsel->pmu->name); + return -EINVAL; + } + opts->full_auxtrace = true; + } + } + + if (!opts->full_auxtrace) + return 0; + + evlist__for_each_entry_safe(evlist, tmp, evsel) { + if (evsel__is_aux_event(evsel)) + arm_spe_setup_evsel(evsel, cpus); + } + + err = arm_spe_setup_aux_buffer(opts); + if (err) + return err; + + return arm_spe_setup_tracking_event(evlist, opts); +} + static int arm_spe_parse_snapshot_options(struct auxtrace_record *itr __maybe_unused, struct record_opts *opts, const char *str) From patchwork Wed Jan 8 14:28:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13931072 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 EC62DE77199 for ; Wed, 8 Jan 2025 14:36:35 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=uREwfE3geZL8Sk+d0/4sDJ4YKT RCb9B60rPRrGSGM0jGxE5afVk/mHrxq6bS00PeW+d8NcL8YYevl7aU6fEnequ1td+WNELzZtjZrn/ 97ZU2npLsdoaHFI7pjZXMTxNTzHtuI7w+CukEpjSVcmRHqgKSfYv7YcuYC8lKHYGFvSzq6O7Xe9MP oeLSAxvNc6eefkYK7fsbq+8HLaJUVwhlXQFVwtUAfJJswnpMlSleGJJaEyBxrGULW2C3TI0WW4R/T ELWGaKHBJoFM3TV5OpddvX9ZSwMl5fe493cTSRnUOd+qaJZblhKSyDaMG3hJEkFMn2eCjSkc6tQp2 +qLDX+4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVXAV-00000008oXM-1jSU; Wed, 08 Jan 2025 14:36:23 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVX4o-00000008nIw-2RrJ for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2025 14:30:31 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-38a25d4b9d4so6465449f8f.0 for ; Wed, 08 Jan 2025 06:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736346629; x=1736951429; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=AwC5ow7fflttVjKBKU8tmKB4WkPjy/IU6ifHRzeAcHg9KloUF50BCWIOhihZVHqYYT lPpo1PaDiSFjdNW+f3wT/CL+D70Ey2i03KNDPTrkh7kB6nY2ZzTntVA3I1pLczbz6c+6 zMbZZgOph7BxrioGEr0GNjO3PeAP1bK3dnAoQ/lfQtMe/q0H03EVGPrfR5WpzUoeIaz1 rVYVA4M9mO4VE31VaZI26z/edgFk+2mQw0rifCMaupqQ29+lrdogo+sbZm81+MiVX86S FfO2a8seTnO2DEOKv6p1Dge37i87WVdOyNn19blnoxj7Zpbj38ZgYt7/DYRciwY/o0zC S1ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736346629; x=1736951429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wmWclsqjoRWfqPrE0WD8+jPpX9G+TTRqhb+EOtWuV1I=; b=k9rjqQDKIXAM72WyeEPRAipHtxnubqW/8TyFNwuIqQ9pc6UU50UoN4G8lBHY871fi0 /sTqHvBW9fT/uBUy8EOivWOD68McEY1j37RReJ179876hRuZq4kE//FbUYRHKy0UyZAd X/CFR0UNP4h93/Nuem+/Ka9Y9JdIVSukNG6SpWTPrHx/7LjgIAc8RJp/JUXmiv9gqASg TAN17DxEJBBEDcYixlJh4Ts8d/48Z1NwTX+jckMG9iMiue0TfPIiIZBpTxSHztzaOtZd lZm9h404JZa9D6L49uiQutA1PU/+7XSJ+/sEdPEdwLkSiygddSkpJ3+2sCgj1EBLLnF5 WGZA== X-Gm-Message-State: AOJu0YzLl3NOkHLZbDgWCMwt9h4Eus7sx7i11WQCP1h/JmsfMJBsfJb2 854tnG1fiTlWfnHC5wWDgrpNuFjB67PXf1iJzjJXQZjl+yFmw9NTgmBH5lhyTZyDtYPIatbbXCR 3 X-Gm-Gg: ASbGnctxo/gIlNRzr+YSD6/SpRMsNf/e2msrgACgAb2Y8gDsr6hQgBueC+RdGNyNrDq s8uWUQXlX/dXxYu53Tx6MoofVYh3gjdPG+2uUKEO42SlSdge/ObYiT5pnkQWh/UshQ5AHPy+XTs l4BYm1lXPo/b7YNr+zSEZtwxC87FLwqnrcT0orVjP545OfUwCK3nQQ2YJLOlH53RjZtmuT8xluf av+X7ZHeg9RTKCBmENx8FseVRXZacVwooxc2UjvZ3nxScvECjrZiDKw X-Google-Smtp-Source: AGHT+IFpLlgT8rIizotjQJSiOIRTNt4ClYlj0TJvrmATLoOgZqttqZSvaAwtMedep20NBlyPDrMhRg== X-Received: by 2002:a5d:5848:0:b0:385:f7a3:fea6 with SMTP id ffacd0b85a97d-38a872da433mr2572275f8f.13.1736346628653; Wed, 08 Jan 2025 06:30:28 -0800 (PST) Received: from pop-os.. ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2ddccf4sm22836965e9.19.2025.01.08.06.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 06:30:28 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com, namhyung@kernel.org, acme@kernel.org Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , Veronika Molnarova , Michael Petlan , Thomas Richter , Athira Rajeev , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 4/5] perf tool: arm-spe: Don't allocate buffer or tracking event in discard mode Date: Wed, 8 Jan 2025 14:28:59 +0000 Message-Id: <20250108142904.401139-5-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108142904.401139-1-james.clark@linaro.org> References: <20250108142904.401139-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_063030_613978_384BA67D X-CRM114-Status: GOOD ( 13.33 ) 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 The buffer will never be written to so don't bother allocating it. The tracking event is also not required. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/arch/arm64/util/arm-spe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/arm64/util/arm-spe.c b/tools/perf/arch/arm64/util/arm-spe.c index 1b543855f206..4301181b8e45 100644 --- a/tools/perf/arch/arm64/util/arm-spe.c +++ b/tools/perf/arch/arm64/util/arm-spe.c @@ -376,7 +376,7 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, container_of(itr, struct arm_spe_recording, itr); struct evsel *evsel, *tmp; struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; - + bool discard = false; int err; sper->evlist = evlist; @@ -396,10 +396,17 @@ static int arm_spe_recording_options(struct auxtrace_record *itr, return 0; evlist__for_each_entry_safe(evlist, tmp, evsel) { - if (evsel__is_aux_event(evsel)) + if (evsel__is_aux_event(evsel)) { arm_spe_setup_evsel(evsel, cpus); + if (evsel->core.attr.config & + perf_pmu__format_bits(evsel->pmu, "discard")) + discard = true; + } } + if (discard) + return 0; + err = arm_spe_setup_aux_buffer(opts); if (err) return err; From patchwork Wed Jan 8 14:29:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13931073 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 2CF12E77188 for ; Wed, 8 Jan 2025 14:37:54 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=FuIxGzPnPLi5/tgBvcocLcxxfH 6/8JV/aQSxEZmfp3XzIy8b/A1XaRcRJecYyaN4XwyfQvdPr+ffCLm3399m6cq9UZuPaavk2d0ieEA SIkYH0r9mqU066Ajoib+truxGkz9Z0HxQfSkSu/komYtPChiwVcYALpHHiize3GdFifXn5b+sj1Za +zA4/bowbLc+HK34O9LzWVmJnRnAl3S4shEbecbvcmaJ/cVrM3XRkQD/XQRArwWN6vj/FDPk+L0bx 9D2nXBDCT/AFfqay3xMweqVomAYifz6IXcDVvSSKagigdxLSz4IgXwPSvwdRJRSpoedA57g2dZvx5 gqfWyraA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tVXBi-00000008ohW-0EJO; Wed, 08 Jan 2025 14:37:38 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tVX4t-00000008nKa-2Uom for linux-arm-kernel@lists.infradead.org; Wed, 08 Jan 2025 14:30:36 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-436a39e4891so64972205e9.1 for ; Wed, 08 Jan 2025 06:30:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736346634; x=1736951434; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=z4GnqXSXyiRrYrflUb+WaxPBHPKV5zjojWWNnQYbRQ2A3b/S5Czf+vnM/9BP/Q3EZM /UDZDZds6iugbj/+IPzLhyNO6YKM6XxqzYCkEmmg3kGJmJ5XGlsN6mmAwQtQ+PtJf8n/ eNr2ExHdktZwYwZQtBgMtfGkX4Vpve2Kjci9namFtrJpaaHvTckVj1TrIBTSo2yk8UnX 3KthQqz1PuiE4+g/uIOh2dLDKwy2GCWfjKi58PmioQ58lHh87ybAsKzyq2JgcsJCyV1H 92M133XhzLpnOy20mCcAJ60xxif0OehEBMWRMRI+l1VCtatOG8VAHjOlWd1unNt/Y53W aTCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736346634; x=1736951434; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r1j+BIbB70BfH6p+H3D0C/f2KwCH22I9fsAuqIEouAI=; b=ZZu8+oqBJX5VlKAM/ZqvfRA+c39hRxFwKMrnnWBjSJ6tySuQ9ykNeqe2IwCQTk5jVR R5E3gYSf/K8n2Y7YMz2Erdsdu3E8jjdC6tlzZOTMYHiDQrdrdjVbctvkRJ1vDgeGk4JY cC5nBJThcJwvLM+xXaJyrKZihsbr3MdkG06MZcwfAs/HqYh9UiMH35CBMO1g0t27jycQ CX1cawqS8nlcqnbGL/ntc8z2CReOVXPDYTjGVxHZ32hhnD8ndTUifg52j0pBpkyyIu5Z VAaj0N3i0tFyim22AjTF8BtFIFntwn2sphoimRaGscR+QokJtXUwbFAyCBg2qd8y5rXm +V1A== X-Gm-Message-State: AOJu0YyuYnXKzCmZ8ugpHq8HTVsSLfb+ne4HGXXEAtBawJSu117CMq2f cUdp1s6T1yeWx0kED7lTYdZDDbJUftmFSuq7hT43mJIcmjBSK7DLxFCSYumkFJ4A2a/oaZ/ffmZ K X-Gm-Gg: ASbGncucU1NHjUrCG2S83vZWXwZATdjmtgufptjzbKXaae7bPm/gXZN+KuXpxrFCGXw x48ExWORY9fI5TkuTSXka/8nPhXT5Gq7CaNWtK1X7+uEaPXUAQGmQTVsNkIXETnJOw9QVWqNTb/ ic3m7ShcDWHq/AEv8mCAYfP5Cn6oXAQrO5OCDkfKGLsYcCAHXAq8ixLylFr0ap47eAXLPG55wLb 4pKSDOasJ8bJg1bY1B3V+CpAbC325ThNA0MEcTAMSUP9VtARK6GfLjv X-Google-Smtp-Source: AGHT+IGPG2fbcdAWI2kWNuJul9oexF8hk5Ad1KOrWrlN7IkVYSCPH+BLbdTguMj87I9RIg+5zb7CeQ== X-Received: by 2002:a5d:47a3:0:b0:38a:4184:2510 with SMTP id ffacd0b85a97d-38a872db629mr2716682f8f.23.1736346634083; Wed, 08 Jan 2025 06:30:34 -0800 (PST) Received: from pop-os.. ([145.224.90.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2ddccf4sm22836965e9.19.2025.01.08.06.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 06:30:33 -0800 (PST) From: James Clark To: linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, irogers@google.com, yeoreum.yun@arm.com, will@kernel.org, mark.rutland@arm.com, namhyung@kernel.org, acme@kernel.org Cc: robh@kernel.org, James Clark , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , "Liang, Kan" , John Garry , Mike Leach , Leo Yan , Graham Woodward , Veronika Molnarova , Michael Petlan , Thomas Richter , Athira Rajeev , linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH v3 5/5] perf test: arm_spe: Add test for discard mode Date: Wed, 8 Jan 2025 14:29:00 +0000 Message-Id: <20250108142904.401139-6-james.clark@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250108142904.401139-1-james.clark@linaro.org> References: <20250108142904.401139-1-james.clark@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250108_063035_628753_F24DEE38 X-CRM114-Status: GOOD ( 12.50 ) 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 Add a test that checks that there were no AUX or AUXTRACE events recorded when discard mode is used. Reviewed-by: Yeoreum Yun Signed-off-by: James Clark --- tools/perf/tests/shell/test_arm_spe.sh | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/perf/tests/shell/test_arm_spe.sh b/tools/perf/tests/shell/test_arm_spe.sh index 3258368634f7..a69aab70dd8a 100755 --- a/tools/perf/tests/shell/test_arm_spe.sh +++ b/tools/perf/tests/shell/test_arm_spe.sh @@ -107,7 +107,37 @@ arm_spe_system_wide_test() { arm_spe_report "SPE system-wide testing" $err } +arm_spe_discard_test() { + echo "SPE discard mode" + + for f in /sys/bus/event_source/devices/arm_spe_*; do + if [ -e "$f/format/discard" ]; then + cpu=$(cut -c -1 "$f/cpumask") + break + fi + done + + if [ -z $cpu ]; then + arm_spe_report "SPE discard mode not present" 2 + return + fi + + # Test can use wildcard SPE instance and Perf will only open the event + # on instances that have that format flag. But make sure the target + # runs on an instance with discard mode otherwise we're not testing + # anything. + perf record -o ${perfdata} -e arm_spe/discard/ -N -B --no-bpf-event \ + -- taskset --cpu-list $cpu true + + if perf report -i ${perfdata} --stats | grep 'AUX events\|AUXTRACE events'; then + arm_spe_report "SPE discard mode found unexpected data" 1 + else + arm_spe_report "SPE discard mode" 0 + fi +} + arm_spe_snapshot_test arm_spe_system_wide_test +arm_spe_discard_test exit $glb_err