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 ACBA9D1812B for ; Mon, 14 Oct 2024 15:35: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=qcKCGkpsRdE/acBak0k/QVIEjMrFdpPBPIn7iWIayCk=; b=fxPDWGw9uX5lPNSh7ADo8s/OhW qX/F6Q7QWMsbecnoY1lJR1XO8UaAdDUOQSawfCW+A35o/XnfhJrt4y0/eN/CfSKK5OYokTHXd1rBK WY7d0twE+rXElrH7WyBRWC0X2h8W2XNGWoPC856ozB8baqf+EEdpEhW4pptzlYofepNsoUNiHOYRE ZeYS7OsZ29Br6z/u+Yc+VA9wnuPd1eW1paB16xv8NLd/5O/ZojWsYIKdaJ2FNxK696TnD5SIeDI8v GVwB/IApT76H6ACpw8kYPPioZIKRRI+w9G4pjsqUJDI6FB3fQVbLnlBtg4AOVfwFPbPlbCC18grnw n01bp4mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0N5n-00000005feq-3pch; Mon, 14 Oct 2024 15:34:43 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t0L7v-00000005HOO-3vnX for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 13:28:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 3210EA41C4D; Mon, 14 Oct 2024 13:28:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4855DC4CEC3; Mon, 14 Oct 2024 13:28:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728912526; bh=IJC/r/I8ibvGLVsU2Qx09C27Zj6TxnkngFFKIcYbnnw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vENYb/E2rDJtJ21mQgAB845FLopbOAlQDyBka97Azx/VEzDHK1e4IcGlX/URWDbqh OIOsbNXlYR7Rc8Jtn/y7nAuOV/aOblvGeDNzVUqJEPVwszkA5PFF2eHBLB5RD7mDB8 k4Kga91MJoC9VHwO4bf3vjvZFD59FKDfTDEiwis4qLu6xJq8wZYQtc55dtGCSErw5w tSPEXgHV8jJeM1HwYkpLQ7ChqBJUZpszOlR2vI/h7q6jyea7+97bNkCpDiBAw+/cas DnQvFsJYFfNF2Yd0IEu8Sdgx/PJ8aKsEFnWZ9Q+D/Lrw56aDowVYxO9ofPnQ32UJ35 gFkZR19klhbQA== Date: Mon, 14 Oct 2024 14:28:41 +0100 From: Will Deacon To: Besar Wicaksono Cc: suzuki.poulose@arm.com, robin.murphy@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, treding@nvidia.com, jonathanh@nvidia.com, vsethi@nvidia.com, rwiley@nvidia.com, rknight@nvidia.com Subject: Re: [PATCH 3/3] perf: arm_cspmu: nvidia: enable NVLINK-C2C port filtering Message-ID: <20241014132839.GC17353@willie-the-truck> References: <20240918215846.1424282-1-bwicaksono@nvidia.com> <20240918215846.1424282-4-bwicaksono@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240918215846.1424282-4-bwicaksono@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_062848_132955_0F71C271 X-CRM114-Status: GOOD ( 22.42 ) 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, Sep 18, 2024 at 09:58:46PM +0000, Besar Wicaksono wrote: > Enable NVLINK-C2C port filtering to distinguish traffic from > different GPUs connected to NVLINK-C2C. > > Signed-off-by: Besar Wicaksono > --- > Documentation/admin-guide/perf/nvidia-pmu.rst | 32 +++++++++++++++++++ > drivers/perf/arm_cspmu/nvidia_cspmu.c | 7 ++-- > 2 files changed, 36 insertions(+), 3 deletions(-) > > diff --git a/Documentation/admin-guide/perf/nvidia-pmu.rst b/Documentation/admin-guide/perf/nvidia-pmu.rst > index 2e0d47cfe7ea..6d1d3206b4ad 100644 > --- a/Documentation/admin-guide/perf/nvidia-pmu.rst > +++ b/Documentation/admin-guide/perf/nvidia-pmu.rst > @@ -86,6 +86,22 @@ Example usage: > > perf stat -a -e nvidia_nvlink_c2c0_pmu_3/event=0x0/ > > +The NVLink-C2C has two ports that can be connected to one GPU (occupying both > +ports) or to two GPUs (one GPU per port). The user can use "port" bitmap > +parameter to select the port(s) to monitor. Each bit represents the port number, > +e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. The > +PMU will monitor both ports by default if not specified. > + > +Example for port filtering: > + > +* Count event id 0x0 from the GPU connected with socket 0 on port 0:: > + > + perf stat -a -e nvidia_nvlink_c2c0_pmu_0/event=0x0,port=0x1/ > + > +* Count event id 0x0 from the GPUs connected with socket 0 on port 0 and port 1:: > + > + perf stat -a -e nvidia_nvlink_c2c0_pmu_0/event=0x0,port=0x3/ > + > NVLink-C2C1 PMU > ------------------- > > @@ -116,6 +132,22 @@ Example usage: > > perf stat -a -e nvidia_nvlink_c2c1_pmu_3/event=0x0/ > > +The NVLink-C2C has two ports that can be connected to one GPU (occupying both > +ports) or to two GPUs (one GPU per port). The user can use "port" bitmap > +parameter to select the port(s) to monitor. Each bit represents the port number, > +e.g. "port=0x1" corresponds to port 0 and "port=0x3" is for port 0 and 1. The > +PMU will monitor both ports by default if not specified. > + > +Example for port filtering: > + > +* Count event id 0x0 from the GPU connected with socket 0 on port 0:: > + > + perf stat -a -e nvidia_nvlink_c2c1_pmu_0/event=0x0,port=0x1/ > + > +* Count event id 0x0 from the GPUs connected with socket 0 on port 0 and port 1:: > + > + perf stat -a -e nvidia_nvlink_c2c1_pmu_0/event=0x0,port=0x3/ > + > CNVLink PMU > --------------- > > diff --git a/drivers/perf/arm_cspmu/nvidia_cspmu.c b/drivers/perf/arm_cspmu/nvidia_cspmu.c > index d1cd9975e71a..cd51177347e5 100644 > --- a/drivers/perf/arm_cspmu/nvidia_cspmu.c > +++ b/drivers/perf/arm_cspmu/nvidia_cspmu.c > @@ -149,6 +149,7 @@ static struct attribute *pcie_pmu_format_attrs[] = { > > static struct attribute *nvlink_c2c_pmu_format_attrs[] = { > ARM_CSPMU_FORMAT_EVENT_ATTR, > + ARM_CSPMU_FORMAT_ATTR(port, "config1:0-1"), > NULL, > }; > > @@ -193,7 +194,7 @@ static u32 nv_cspmu_event_filter(const struct perf_event *event) > const struct nv_cspmu_ctx *ctx = > to_nv_cspmu_ctx(to_arm_cspmu(event->pmu)); > > - if (ctx->filter_mask == 0) > + if (ctx->filter_mask == 0 || event->attr.config1 == 0) > return ctx->filter_default_val; Isn't this a bit too broad? It looks like this filter function is used beyond the C2C PMU (i.e. the PCIe PMU) and you're also checking the whole of config1 rather than just the port field. Will