Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1764059rdb; Sat, 3 Feb 2024 23:49:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuTVzo4lm1vecY75PEh5j8ZeNLpcHUj5pwvku65k9/knh119nYAh4CYDfTnl7YDu/gnDUC X-Received: by 2002:a05:620a:2114:b0:783:b6bd:e3f8 with SMTP id l20-20020a05620a211400b00783b6bde3f8mr10866568qkl.55.1707032997304; Sat, 03 Feb 2024 23:49:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707032997; cv=pass; d=google.com; s=arc-20160816; b=puMIgLlGH8w4kWvRHISL5OHGytvR7UlNkvM8hZFXo2Czm403gQO6MjO7QJxIBEUYZs MwPPW2AXPEcxYZVfr268n+0OxPiWssHBmaCSJhAyafAzZagB+1mVOXFsSb1teWblnpEI QlcZ9tY33fstkiL60ua7y/BzYmUha3wHYVysb8n1NfhO6p6MVbdK2V8jrtcnVcjXOIyA Eu9s2n1jKA8CkZcR4Tt588FYk3r1STOEmnu+E9+C3oMpe0gpMA7ur34wuOEdET6b2C0B cog0WO9NF0UvHVhld5vzyRkArBIyUr/OmtAh0g8d1xTfKawolQq/CGyRfuZ3OgKVN/mf tgGw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HSh5NS8xK1NH3CXyW6IyI9yXtrR4rKYWu8fVs+402L8=; fh=pouZQOgiFLB7Fnwd/gZ1E8SxjUp0nMYRPZrQODndO1M=; b=TJ/QAh7JsnAyUkgvTAJY+bqwhqbtN4MVLZmgeqEIONTJ0qjxFz/o01YHs5FhPHhT9r 9Gc4qWx1lu6MbTvRvw+7A6auN36lOMErzsn0tkViXwUHcnlJkQ9nVXxEdvbFKy1elu8W HvUixCLHOEFyUBizybFDr0l8OgMGd4/8Nqvq7dIeDoNUIgSNC86kmzlIon/H5cJjQ2OZ 4XZwyHdhVXgDAISJ5zAjLeJIPMt6U2bKhOHwe86Q7Ee6xkr7WK1wvLlkyapSpMVXc+rO kOUbKprXTKa5S0RqMzhTGor8d8TdSrebLmnzxs68kzwmBoCEl4Zlu5z6mbJH/aeYy4KF dPnQ==; 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-51501-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51501-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com X-Forwarded-Encrypted: i=1; AJvYcCXJ87kFpOUEYzDw7sj/HvxOwoJoPFibpfqbrKCRnlTuES/XHWOjSNc9sahGwL43vlqAUb4vQkVb0nck4oTtB2sRfYo/ysHg267E45EJ0Q== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y8-20020a05620a44c800b007853f81e915si6327308qkp.86.2024.02.03.23.49.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 23:49:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51501-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-51501-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51501-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E97581C21411 for ; Sun, 4 Feb 2024 07:49:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DE98711197; Sun, 4 Feb 2024 07:49:40 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 441FBE57F for ; Sun, 4 Feb 2024 07:49:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707032980; cv=none; b=WHOkRuhUm5BJ9n9Bg5EJV/Quh+BNzQFq70y97UmolPm2k5v0KAx+aI+C8oXQu++FiKfEH5BlwyiiHMYcFK0PIjYZAZms9qPJ9sqEGuJyT3Kv7KEVyK9vIx30Wht139GWQ2s1K+xHQhp9Pn3KcaebLl5x5vPtR+Y6OINPSVeCyBw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707032980; c=relaxed/simple; bh=xVp6lLGeg/BVIYp5SFLX2aWAIILS7tlAKBQjN8FKhM8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AHrGIU8WJUwD2wN9rNmfc5xwJTzrjS9IXXccMTG0Q1QTzXBSSrhlk2EuJnZCF90s1vwG9bYo6Y22ieUdI2mkP8pMIrWMyn1wFN3AHy+8To7pJVuO+vp5lxHgIefic/v67AFUYERCyDJL6B5LSvWMCzRQAWd+gWJmGU6/4ryJWPg= 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=45.249.212.190 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.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TSM7z5Bgkz1xnCC; Sun, 4 Feb 2024 15:48:31 +0800 (CST) Received: from canpemm500009.china.huawei.com (unknown [7.192.105.203]) by mail.maildlp.com (Postfix) with ESMTPS id D72DD1404FC; Sun, 4 Feb 2024 15:49:35 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 4 Feb 2024 15:49:35 +0800 From: Yicong Yang To: , , , , , CC: , , , Subject: [PATCH 5/7] drivers/perf: hisi_pcie: Relax the check on related events Date: Sun, 4 Feb 2024 15:45:25 +0800 Message-ID: <20240204074527.47110-6-yangyicong@huawei.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20240204074527.47110-1-yangyicong@huawei.com> References: <20240204074527.47110-1-yangyicong@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500009.china.huawei.com (7.192.105.203) 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 stata -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 --- 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 b91f03c02c57..1b45aeb82859 100644 --- a/drivers/perf/hisilicon/hisi_pcie_pmu.c +++ b/drivers/perf/hisilicon/hisi_pcie_pmu.c @@ -408,14 +408,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; -- 2.24.0