Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp223863rdb; Thu, 8 Feb 2024 04:21:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUE0xoSoWTgwMdxG3nJMNDu4ewxI8UG4HD9H6PBv1ajOA7PGAGQcrOvV7nQEbnGOV0FgPJI+X6huPb2cHmJ6oFYV27IWM4ywBrkkleXsQ== X-Google-Smtp-Source: AGHT+IH55RaYOCSutEM9kLM8UXjXNi/euC+Z2lDNxNg5+lP9j0ocOkWmZMCIXL3azMxWPZD238Fx X-Received: by 2002:a05:6a00:2294:b0:6e0:465e:cdd5 with SMTP id f20-20020a056a00229400b006e0465ecdd5mr7289848pfe.23.1707394899711; Thu, 08 Feb 2024 04:21:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707394899; cv=pass; d=google.com; s=arc-20160816; b=PGorAqqtZq1F91/WNj4av2PuUmmzCgEMP6zEebEaMYzv3WGo5DYvseo5NVEX9UXidG 4+vplGScbXkf7nBCWR8+jiWA5NnlHjnC07gVCLFfESDgw17bneI584O4H8AJoT3tlULk 58duUzb3VCxefVL9dyyznkT+PcnLgI+IrmGcXeHlPZA18yym2MLBo9PjizBtNOPfWf8k OJWY0VoedJ2mSb5DPgGTZZcRKHlZP2PS1gO1/VzbVXDer9Atn3gP3+Gncn+EpiZq7U/K EonZJwb3cNNvF9asNrfIf2D4ilGS5Mbfx1AnP0gbyUJunofeA99lEzWvY17O2e6r6GWd 0Sdw== 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=LDGoGWMFxhmsS95oXgPKnTe4KKc3KRXASdiIg/RmuAY=; fh=jWqZswaH9pgBpXLxXWTpVwi/XnzsjkdjuS+4FDnX36U=; b=hdu3yL8iHd3Zi4djEN3f28I/vUv8DHU98AfkmaW16IbAs19Ja7jeT2nB4WfnPIHDIN BVfRZcfSPd/22wTmLbj2150wyhgGN2GnpJxRmArZK7E7SBJyFcJXL69XueIZu9AlT1P7 4DrUxJicMmHKvhNF9jegZquzQCBUNVApOGl38MJTeDvn/wbjFcnTrQlMjvLi+8ZSo+Mz 5OGRA3L5kLyUUqtTmLOEA/Cu2Vgk7XaUZPwlUEp9MqvnROU4GedzzWCnKgSs/Iew8Xym XPtjY2j+ZL9iHsXpPXA27lg1QXNustfJVSQrMd4GAaSxsd5Ff2aSonpWR69JzjvA+kyE +emA==; 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-58040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58040-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; AJvYcCU4sM/Ey8pMkjRsE6ZTB8hYPBjig4gUOT8aYO5fqK1iD7AOuCh38tYG/Q5rXjFZpj4XPCzLlG5Gb553qjQvNKgdvmYer2GfaCQcX7gsYA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m29-20020a63711d000000b005cdd60a42f5si3530158pgc.838.2024.02.08.04.21.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 04:21:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; 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-58040-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58040-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 DC67A286F13 for ; Thu, 8 Feb 2024 12:19:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B41D71B50; Thu, 8 Feb 2024 12:19:19 +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 62D8771B30 for ; Thu, 8 Feb 2024 12:19:16 +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=1707394758; cv=none; b=AsCEqDhV3ivJiOtDvBDGElcc0WrQVOvvRNF4W/S+xAq/S7BW4swBtXZp6sKaubTwutiSvjUch3T6BN4nmwrw1KXlKn9HVZDkj4UABcJ3fHnAHHFt6kgKbtSye8C56C1st/KusFKU880y2zI2REfpFdFumSTtEd941uiCwmr4158= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707394758; c=relaxed/simple; bh=RSoYju6jhoejnA/9NGmI8rc3Aj7wlru6fJ0M6DLzgRw=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V9r/8FF5PG6bUaPBfUgAqpCa+2A2+0Ts9eS+2bVMGkHm7JsNxtDznsla1ylq+iIVjJgxkNhILETh8JiKWxtLUgrvZlrL27F+0Fw80IDPyJzyCLq3Z691DEK/KBsnWJIMhQGsXrBgqIO6uodxxYR0klk12MCvK2HcrryRdfLe8WU= 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.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4TVwtc1yxbz6K64G; Thu, 8 Feb 2024 20:15:52 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id C9E59140136; Thu, 8 Feb 2024 20:19:13 +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:19:13 +0000 Date: Thu, 8 Feb 2024 12:19:12 +0000 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , , Subject: Re: [PATCH 2/7] drivers/perf: hisi_pcie: Fix incorrect counting under metric mode Message-ID: <20240208121912.00001fd7@Huawei.com> In-Reply-To: <20240204074527.47110-3-yangyicong@huawei.com> References: <20240204074527.47110-1-yangyicong@huawei.com> <20240204074527.47110-3-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:22 +0800 Yicong Yang wrote: > From: Yicong Yang > > The metric counting shows incorrect results if the events in the > metric group using the same event but different filter options. > This is because we only judge the event code to decide whether > the event in the metric group should share the same hardware > counter, but ignore the settings of the filter. > > For example, on a platform of 2 ports 0x1 and 0x2 but only port > 0x1 has a downstream PCIe NVME device. The metric counting > shows both ports have the same counts because we misassign these > two events to one same hardware counter: > [root@localhost perf-iostat]# ./perf stat -e '{hisi_pcie0_core1/event=0x0104,port=0x2/,hisi_pcie0_core1/event=0x0104,port=0x1/}' > > Performance counter stats for 'system wide': > > 7907484924 hisi_pcie0_core1/event=0x0104,port=0x2/ > 7907484924 hisi_pcie0_core1/event=0x0104,port=0x1/ > > 10.153863691 seconds time elapsed > > Fix this by using the whole config rather than the event only > to judge whether two events are the same and should share the > same hardware counter. With this patch, the metric counting in > the above case tends to be corrected: > > [root@localhost perf-iostat]# ./perf stat -e '{hisi_pcie0_core1/event=0x0104,port=0x2/,hisi_pcie0_core1/event=0x0104,port=0x1/}' > > Performance counter stats for 'system wide': > > 0 hisi_pcie0_core1/event=0x0104,port=0x2/ > 8123122077 hisi_pcie0_core1/event=0x0104,port=0x1/ > > 10.152875631 seconds time elapsed > > Fixes: 8404b0fbc7fb ("drivers/perf: hisi: Add driver for HiSilicon PCIe PMU") > Signed-off-by: Yicong Yang > --- > drivers/perf/hisilicon/hisi_pcie_pmu.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c > index 11a819cd07f2..9623bed93876 100644 > --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c > +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c > @@ -314,10 +314,15 @@ static bool hisi_pcie_pmu_valid_filter(struct perf_event *event, > return true; > } > > +/* > + * Check Whether two events share the same config. The same config means not > + * only the event code, but also the filter settings of the two events are > + * the same. > + */ > static bool hisi_pcie_pmu_cmp_event(struct perf_event *target, > struct perf_event *event) > { > - return hisi_pcie_get_real_event(target) == hisi_pcie_get_real_event(event); > + return hisi_pcie_pmu_get_filter(target) == hisi_pcie_pmu_get_filter(event); This is why I looked more closely at what get_filter() was doing in previous patch. Not obvious from the naming here that this compares the event + filters rather than now just comparing the filters. > } > > static bool hisi_pcie_pmu_validate_event_group(struct perf_event *event)