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 127E9C48BF6 for ; Mon, 26 Feb 2024 15:17:17 +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=7O8RDyqTw02t7LM57ppOXYBha2zcH9o8cpSugAiYOI0=; b=JiNFMdrNw6GQT5 SKmheM4brkSwekSLdfH1vcCVcvKE7EA1b/TVr0Ex2V1+TgjpyaUp7d6icnu4/pDdvn31M+whMNTfY hNrXYW5qfTIvG/unePC1sh6m0IEqSpImvWBjkWM3aeUIEe7brfJ+JH2VMmMVpixf/zJj5H+lxIvtv 4/3nmacfaPCmd3gvJNf39vUcoZFjbayNB39wg1VVurZs6503ZVbnJIyfCwTl+wRSsB5Q1lqWfUM2x I5exyl1ge+nX1aHu35MfYeOr23PhJ/Uo0mHlJuEs2ayBb8ct/6FKNs5jwXJkcdWOj/mANu6ytXXRU 03hWt8QR62vxrdYe7V1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1recj5-00000001NRK-0sIK; Mon, 26 Feb 2024 15:17:07 +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 1reciy-00000001NOV-2eo9 for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2024 15:17:04 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4Tk3yv26JLz6K8lH; Mon, 26 Feb 2024 23:13:11 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 91A05141ACB; Mon, 26 Feb 2024 23:16:54 +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_256_GCM_SHA384) id 15.1.2507.35; Mon, 26 Feb 2024 15:16:54 +0000 Date: Mon, 26 Feb 2024 15:16:52 +0000 From: Jonathan Cameron To: Yicong Yang CC: , , , , , , , , Subject: Re: [PATCH v2 6/8] drivers/perf: hisi_pcie: Relax the check on related events Message-ID: <20240226151652.00004e88@Huawei.com> In-Reply-To: <20240223103359.18669-7-yangyicong@huawei.com> References: <20240223103359.18669-1-yangyicong@huawei.com> <20240223103359.18669-7-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: lhrpeml100004.china.huawei.com (7.191.162.219) 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-20240226_071701_112571_DEF634E6 X-CRM114-Status: GOOD ( 24.21 ) 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 Fri, 23 Feb 2024 18:33:57 +0800 Yicong Yang wrote: > From: Junhao He > > If we use two events with the same filter and related event type > (see the following example), the driver check whether they are related > events and are in the same group, otherwise the function > hisi_pcie_pmu_find_related_event() return -EINVAL, then the 2nd event > cannot count but the 1st event is running, although the PCIe PMU has > other idle counters. > > In this case, The perf event scheduler will make the two events to > multiplex a counter, if the user use the formula > (1st event_value / 2nd event_value) to calculate the bandwidth, he/she > won't get the correct value, because they are not counting at the > same period. > > This patch tries to fix this by making the related events to use > different idle counters if they are not in the same event group. > > And finally, I'm going to say. The related events are best used in the > same group [1]. There are two ways to know if they are related events. > a) By event name, such as the latency events "xxx_latency, xxx_cnt" or > bandwidth events "xxx_flux, xxx_time". > b) By event type, such as "event=0xXXXX, event=0x1XXXX". > > Use group to count the related events: > [1] -e "{pmu_name/xxx_latency,port=1/,pmu_name/xxx_cnt,port=1/}" > > example: > 1st event: hisi_pcie0_core1/event=0x804,port=1 > 2nd event: hisi_pcie0_core1/event=0x10804,port=1 > > test cmd: > perf stat -e hisi_pcie0_core1/event=0x804,port=1/ \ > -e hisi_pcie0_core1/event=0x10804,port=1/ > > before patch: > 25,281 hisi_pcie0_core1/event=0x804,port=1/ (49.91%) > 470,598 hisi_pcie0_core1/event=0x10804,port=1/ (50.09%) > > after patch: > 24,147 hisi_pcie0_core1/event=0x804,port=1/ > 474,558 hisi_pcie0_core1/event=0x10804,port=1/ > > Signed-off-by: Junhao He > Signed-off-by: Yicong Yang Reviewed-by: Jonathan Cameron > --- > drivers/perf/hisilicon/hisi_pcie_pmu.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/drivers/perf/hisilicon/hisi_pcie_pmu.c b/drivers/perf/hisilicon/hisi_pcie_pmu.c > index b2dde7559639..5b15f3698188 100644 > --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c > +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c > @@ -409,14 +409,10 @@ static int hisi_pcie_pmu_find_related_event(struct hisi_pcie_pmu *pcie_pmu, > if (!sibling) > continue; > > - if (!hisi_pcie_pmu_cmp_event(sibling, event)) > - continue; > - > /* Related events must be used in group */ > - if (sibling->group_leader == event->group_leader) > + if (hisi_pcie_pmu_cmp_event(sibling, event) && > + sibling->group_leader == event->group_leader) > return idx; > - else > - return -EINVAL; > } > > return idx; _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel