Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp228694rdb; Thu, 8 Feb 2024 04:31:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXAWJmDNtOk5h4k9iVA5EnI/YfhhJ1eSCHSG6+4ZkfbF1CamFgqVSETNtIrVMqGnLsWgve/PH21z1f+fjQdO3QXOad2l+JImw01TTXWlg== X-Google-Smtp-Source: AGHT+IGyJoaoX1jew3C71k/s5MWbKKSId/HyOLhpxqFmMv1IKK2mfXC7jNflu6be7h7Ox1w/bqEJ X-Received: by 2002:a05:6a20:a485:b0:19e:5e0c:3bb8 with SMTP id y5-20020a056a20a48500b0019e5e0c3bb8mr2989425pzk.7.1707395466111; Thu, 08 Feb 2024 04:31:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707395466; cv=pass; d=google.com; s=arc-20160816; b=Hrzz4AjMwFF38eFTkOTKKBTLaJbT25M7jyzLRIUbcvYLIBU80OQ82rY1H8OnPKgpsL uf8sdNuyZijXZvic0jjP80R7zhp6gopbWhDCPyMmNYZVyVBnyv+fdZszN3eRMKSwwbNu 4Sgum9TozZgVts56UDNf5zqJ70NHFMr05HXBfnvMHFllB+c/WN7U+vVrN9fwtsNWrsjT Px8J5BAktI+7fe2QEyaU6qkGnlp8ivK6DajMPcLNDWvwOSG8S98RSFt/bQNjaidS158V 0LkXUimurlf8kYCoMK6hgx6qoC9i4fsBvG+fXB1p9fQ12yma6POQ7oWP1VuhYxoTPnHy yGUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=isU0LTUapwbRKVnkzNeCCr3zIvowNoLycHwa+1tmXVk=; fh=uKbzvV5we7Tw/u2W5pmCW0vAVtVAp/XkGdZEkjVZtb0=; b=LaQPRIR8p1rF8AG8YFwQopls1dTtWm1ZTreiKZtxcptOANVTqpT8U7Xrv5WuXpYVd6 m6kSzBnVVM8Mb6ED2FSd7dMieSftmlsid4r+k/XOd16/LbJn3pfHZNzB1k/V+3L8kmqX Gg2lAfth1TLOwHtsmEBKKQqOMO6VfEY/MO7NWBtiqDOpHkqADOdbDSZnsLx++Wm3Y7+r qFWpDBU5CvtoKxDvhTjPK7LwpzQ5AAIDgMR5eTMxyFEMOMeepTJgrjF/irfdVsc+1WBp GD+ANGv60S/JRkHiKf0c+wruiMYfQV9bwcKm8YEKvL3/Vo+iU+YSwSVBZQw7TT/Etswj BW4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-58053-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58053-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=2; AJvYcCU62UeFyMJWzqQ55jgL/NiDiiRYwMPCJmbp/I9TfAwUZxQkCq1gKY6BIC3Axn3mA6bU3yput2lCNOF98Tea1mxI5gA+lrxD2tz/XLpq7w== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x23-20020a63b217000000b005ce025116bbsi3695978pge.858.2024.02.08.04.31.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:31:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58053-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-58053-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58053-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A3730284895 for ; Thu, 8 Feb 2024 12:29:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C8FE7318C; Thu, 8 Feb 2024 12:29:15 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16EF071B42 for ; Thu, 8 Feb 2024 12:29:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707395354; cv=none; b=up/U4HAgHBr0DeIoJrQfwpA9/M9vISEFSPOW5YpORTpBR9XD2OU/o08KOFetcen7sz7Zvk+sih6NVGtfI7T63mBf2slreVbEQyklNvZ2euq88K49i73yk0sq+O50lGIjS/suLAeRiJTWGALCMadulUKkTRn3IKu0DIgBvrsn28M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707395354; c=relaxed/simple; bh=/T5gwMhLhg9+ijzK45R5rq+3HpzHEmkJtwlkUz9BCFc=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l5Y4CGDOY7w38EmDekJwBubQQUWg6z5MzRfDeNiVMvq+d52QcWSf3LdT2QQzWbk9bGtk5Fr2lagk33T4GDpCXWt3Pto2GEscpWRdCaz+TYFV+0t6S6GaARO73cSMsAl+IZgzZAJdhUA2Dz0nhHjrVVSLRmsSm6WRS3o0H4nT07k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml100001.china.huawei.com (7.191.160.183) To lhrpeml500005.china.huawei.com (7.191.163.240) 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; > }