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 44D58C48260 for ; Thu, 8 Feb 2024 12:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mU9UpCApohtL06NbvFYvAXGR6Bh6hWTytJUCDKAkqZY=; b=F8RQGrtalupsvz O/w5XrLN19tBGK8c4UANpeZg1iyCFG4lchGoPxm096RvPfeHvb4z28RjhhX1gFNBLAt9jjj553Ao3 XvSg+U9hkfq5BuhNJalndHaPbKTDQqUoo3MMNtaw8yusTfNiFjSnjm4otSfQN8Q3RaELO+HxZ66YW rozzWwPBYyUWMSigfOusjyA6rsJ0ifvnXpTrY0Hf2ZHSFMXLsgjpuD1Ct5eVfhnl/mAQ2Pm8Wfgdh 1Nz5aRq8gb/UWmz1qmVGPYOHqo8CmI5/f+hWgnLw3p7xmKP0P2W+4rCiiO/9iQH4s16KAmJptXMk6 uyeMtFLduZUYBFhb8cog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY3Wm-0000000DitW-0W2E; Thu, 08 Feb 2024 12:29:16 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY3Wi-0000000Dit6-2X9c for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 12:29:14 +0000 Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TVx614rwNz6K98T; Thu, 8 Feb 2024 20:25:45 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id A3D611400D9; Thu, 8 Feb 2024 20:29:03 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 8 Feb 2024 12:29:03 +0000 Date: Thu, 8 Feb 2024 12:29:02 +0000 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , , Subject: Re: [PATCH 4/7] drivers/perf: hisi_pcie: Check the target filter properly Message-ID: <20240208122902.0000768f@Huawei.com> In-Reply-To: <20240204074527.47110-5-yangyicong@huawei.com> References: <20240204074527.47110-1-yangyicong@huawei.com> <20240204074527.47110-5-yangyicong@huawei.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240208_042912_994470_C20D93CC X-CRM114-Status: GOOD ( 26.80 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, 4 Feb 2024 15:45:24 +0800 Yicong Yang wrote: > From: Junhao He > > The PMU can monitor traffic of certain target Root Port or downstream > target Endpoint. User can specify the target filter by the "port" or > "bdf" option respectively. The PMU can only monitor the Root Port or > Endpoint on the same PCIe core so the value of "port" or "bdf" should > be valid and will be checked by the driver. > > Currently at least and only one of "port" and "bdf" option must be set. > If "port" filter is not set or is set explicitly to zero (default), > driver will regard the user specifies a "bdf" option since "port" option > is a bitmask of the target Root Ports and zero is not a valid > value. > > If user not explicitly set "port" or "bdf" filter, the driver uses "bdf" > default value (zero) to set target filter, but driver will skip the > check of bdf=0, although it's a valid value (meaning 0000:000:00.0). > Then the user just gets zero. > > Therefore, we need to check if both "port" and "bdf" are invalid, then > return failure and report warning. > > Testing: > before the patch: > 0 hisi_pcie0_core1/rx_mrd_flux/ > 0 hisi_pcie0_core1/rx_mrd_flux,port=0/ > 24,124 hisi_pcie0_core1/rx_mrd_flux,port=1/ > 0 hisi_pcie0_core1/rx_mrd_flux,bdf=0/ > hisi_pcie0_core1/rx_mrd_flux,bdf=1/ Nice to include an example that works for bdf hisi_pcie0_core1/rx_mrd_flux,bdf=1,port=0 or something like that? > > after the patch: > hisi_pcie0_core1/rx_mrd_flux/ > hisi_pcie0_core1/rx_mrd_flux,port=0/ > 24,153 hisi_pcie0_core1/rx_mrd_flux,port=1/ > hisi_pcie0_core1/rx_mrd_flux,bdf=0/ > hisi_pcie0_core1/rx_mrd_flux,bdf=1/ > > Signed-off-by: Junhao He > Signed-off-by: Yicong Yang Clearly the current situation is wrong, but perhaps we can have a more intuitive scheme (could be added as a follow up patch) and have the driver figure out which port the bdf lies below? Maybe that's a job for userspace tooling rather than the driver, but the driver already has verification code and it wouldn't be hard to not just check the rp is ours, but also set the filter to specify that rp, or maybe just set the mask to include them all? Jonathan > --- > drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c > index 83be3390686c..b91f03c02c57 100644 > --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c > +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c > @@ -306,10 +306,10 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, > if (hisi_pcie_get_trig_len(event) > HISI_PCIE_TRIG_MAX_VAL) > return false; > > - if (requester_id) { > - if (!hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) > - return false; > - } > + /* Need to explicitly set filter of "port" or "bdf" */ > + if (!hisi_pcie_get_port(event) && > + !hisi_pcie_pmu_valid_requester_id(pcie_pmu, requester_id)) > + return false; > > return true; > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel