From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Yicong Yang <yangyicong@huawei.com>
Cc: <will@kernel.org>, <mark.rutland@arm.com>, <hejunhao3@huawei.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <yangyicong@hisilicon.com>,
<linuxarm@huawei.com>, <prime.zeng@hisilicon.com>,
<fanghao11@huawei.com>
Subject: Re: [PATCH v2 6/8] drivers/perf: hisi_pcie: Relax the check on related events
Date: Mon, 26 Feb 2024 15:16:52 +0000 [thread overview]
Message-ID: <20240226151652.00004e88@Huawei.com> (raw)
In-Reply-To: <20240223103359.18669-7-yangyicong@huawei.com>
On Fri, 23 Feb 2024 18:33:57 +0800
Yicong Yang <yangyicong@huawei.com> wrote:
> From: Junhao He <hejunhao3@huawei.com>
>
> 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 <hejunhao3@huawei.com>
> Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huwei.com>
> ---
> 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
next prev parent reply other threads:[~2024-02-26 15:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-23 10:33 [PATCH v2 0/8] drivers/perf: hisi_pcie: Several updates for HiSilicon PCIe PMU driver Yicong Yang
2024-02-23 10:33 ` [PATCH v2 1/8] drivers/perf: hisi_pcie: Rename hisi_pcie_pmu_{config,clear}_filter() Yicong Yang
2024-02-26 15:11 ` Jonathan Cameron
2024-02-23 10:33 ` [PATCH v2 2/8] drivers/perf: hisi_pcie: Introduce hisi_pcie_pmu_get_event_ctrl_val() Yicong Yang
2024-02-23 10:33 ` [PATCH v2 3/8] drivers/perf: hisi_pcie: Fix incorrect counting under metric mode Yicong Yang
2024-02-26 15:12 ` Jonathan Cameron
2024-02-23 10:33 ` [PATCH v2 4/8] drivers/perf: hisi_pcie: Add more events for counting TLP bandwidth Yicong Yang
2024-02-23 10:33 ` [PATCH v2 5/8] drivers/perf: hisi_pcie: Check the target filter properly Yicong Yang
2024-02-26 15:14 ` Jonathan Cameron
2024-02-23 10:33 ` [PATCH v2 6/8] drivers/perf: hisi_pcie: Relax the check on related events Yicong Yang
2024-02-26 15:16 ` Jonathan Cameron [this message]
2024-02-23 10:33 ` [PATCH v2 7/8] drivers/perf: hisi_pcie: Merge find_related_event() and get_event_idx() Yicong Yang
2024-02-26 15:18 ` Jonathan Cameron
2024-02-23 10:33 ` [PATCH v2 8/8] docs: perf: Update usage for target filter of hisi-pcie-pmu Yicong Yang
2024-02-26 15:20 ` Jonathan Cameron
2024-03-04 15:17 ` [PATCH v2 0/8] drivers/perf: hisi_pcie: Several updates for HiSilicon PCIe PMU driver Will Deacon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240226151652.00004e88@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=fanghao11@huawei.com \
--cc=hejunhao3@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mark.rutland@arm.com \
--cc=prime.zeng@hisilicon.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).