LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "liuqi (BA)" <liuqi115@huawei.com>
To: Will Deacon <will@kernel.org>, Linuxarm <linuxarm@huawei.com>
Cc: <mark.rutland@arm.com>, <bhelgaas@google.com>,
	<linux-pci@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <zhangshaokun@hisilicon.com>
Subject: Re: [PATCH v9 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU
Date: Wed, 25 Aug 2021 19:52:08 +0800	[thread overview]
Message-ID: <4050af8b-f9a7-6666-4a9d-d1c8f2b212e1@huawei.com> (raw)
In-Reply-To: <20210824143137.GA23146@willie-the-truck>


Hi, Will
On 2021/8/24 22:31, Will Deacon wrote:
> Hi,
> 
> On Wed, Aug 18, 2021 at 01:12:46PM +0800, Qi Liu wrote:
>> PCIe PMU Root Complex Integrated End Point(RCiEP) device is supported
>> to sample bandwidth, latency, buffer occupation etc.
>>
>> Each PMU RCiEP device monitors multiple Root Ports, and each RCiEP is
>> registered as a PMU in /sys/bus/event_source/devices, so users can
>> select target PMU, and use filter to do further sets.
>>
>> Filtering options contains:
>> event     - select the event.
>> port      - select target Root Ports. Information of Root Ports are
>>              shown under sysfs.
>> bdf       - select requester_id of target EP device.
>> trig_len  - set trigger condition for starting event statistics.
>> trig_mode - set trigger mode. 0 means starting to statistic when bigger
>>              than trigger condition, and 1 means smaller.
>> thr_len   - set threshold for statistics.
>> thr_mode  - set threshold mode. 0 means count when bigger than threshold,
>>              and 1 means smaller.
> 
> I think this is getting there now, thanks for sticking with it. Just a
> couple of comments below..
> 
>> +static bool hisi_pcie_pmu_validate_event_group(struct perf_event *event)
>> +{
>> +	struct perf_event *sibling, *leader = event->group_leader;
>> +	int counters = 1;
>> +
>> +	if (!is_software_event(leader)) {
>> +		if (leader->pmu != event->pmu)
>> +			return false;
>> +
>> +		if (leader != event)
>> +			counters++;
>> +	}
>> +
>> +	for_each_sibling_event(sibling, event->group_leader) {
>> +		if (is_software_event(sibling))
>> +			continue;
>> +
>> +		if (sibling->pmu != event->pmu)
>> +			return false;
>> +
>> +		counters++;
>> +	}
>> +
>> +	return counters <= HISI_PCIE_MAX_COUNTERS;
>> +}
> 
> Given that this function doesn't look at the event numbers, doesn't this
> over-provision the counter registers? For example, if I create a group
> containing 4 of the same event, then we'll allocate four counters but only
> use one. Similarly, if I create a group containing two events, one for the
> normal counter and one for the extended counter, then we'll again allocate
> two counters instead of one.
> 

Yes, we should add some check in hisi_pcie_pmu_validate_event_group() 
function to avoid over-provision. I'll use a array to record events and 
do this check.

Thanks for your review, I'll fix this.

> Have I misunderstood?
> 
>> +static int hisi_pcie_pmu_event_init(struct perf_event *event)
>> +{
>> +	struct hisi_pcie_pmu *pcie_pmu = to_pcie_pmu(event->pmu);
>> +	struct hw_perf_event *hwc = &event->hw;
>> +
>> +	event->cpu = pcie_pmu->on_cpu;
>> +
>> +	if (EXT_COUNTER_IS_USED(hisi_pcie_get_event(event)))
>> +		hwc->event_base = HISI_PCIE_EXT_CNT;
>> +	else
>> +		hwc->event_base = HISI_PCIE_CNT;
>> +
>> +	if (event->attr.type != event->pmu->type)
>> +		return -ENOENT;
>> +
>> +	/* Sampling is not supported. */
>> +	if (is_sampling_event(event) || event->attach_state & PERF_ATTACH_TASK)
>> +		return -EOPNOTSUPP;
>> +
>> +	if (!hisi_pcie_pmu_valid_filter(event, pcie_pmu)) {
>> +		pci_err(pcie_pmu->pdev, "Invalid filter!\n");
> 
> Please remove this message, as it's triggerable from userspace.
> 
got it, will remove this.

Thanks,
Qi
> Will
> .
> 


      reply	other threads:[~2021-08-25 11:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18  5:12 [PATCH v9 0/2] drivers/perf: hisi: Add support for " Qi Liu
2021-08-18  5:12 ` [PATCH v9 1/2] docs: perf: Add description for HiSilicon PCIe PMU driver Qi Liu
2021-08-18  5:12 ` [PATCH v9 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU Qi Liu
2021-08-24 14:31   ` Will Deacon
2021-08-25 11:52     ` liuqi (BA) [this message]

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=4050af8b-f9a7-6666-4a9d-d1c8f2b212e1@huawei.com \
    --to=liuqi115@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=will@kernel.org \
    --cc=zhangshaokun@hisilicon.com \
    --subject='Re: [PATCH v9 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU' \
    /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

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).