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 5EF00C48260 for ; Thu, 8 Feb 2024 12:19:28 +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=Y1AQA/rlszRmVLx6ZQFgWS33IVE8tE+UB6p3yayvDho=; b=aDBO8/T+Z6EQGr AOt9qvmg2WenmSCQ24DyjKbUF+QjJ4eHllP1AWVy5YGbyLgKtqTkwDorLZtkN+PIHFX1/eZP8NViD Mq9KW93Pkf21keji7mkxUffh4xMKDvz+z+UJI6HKxtT6lufJaWfanpaqJU/w6qwaj9jHBzMiEKyI1 8vuso8Z2G1wOx542K3ED7xbYju+fZNrtD/BvXJLjNI+VYXa9WRePouCVL6evLpz3CyDGHFepX89d+ yHBjJh+7sQBCOYYmgQNt9pR5ujYbCe0imVUTWjBnLd0us61fL8M50Xwv6mxPOSJWLC8CVSMzk4AzJ 4gajlGfnu/Io3KNZZuaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rY3N8-0000000DhJO-3xCV; Thu, 08 Feb 2024 12:19:18 +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 1rY3N5-0000000DhIv-2BJN for linux-arm-kernel@lists.infradead.org; Thu, 08 Feb 2024 12:19:16 +0000 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) 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_041915_906478_8FAC25AB X-CRM114-Status: GOOD ( 24.10 ) 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: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) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel