LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Will Deacon <will@kernel.org>
To: Qi Liu <liuqi115@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, linuxarm@huawei.com,
	zhangshaokun@hisilicon.com
Subject: Re: [PATCH v9 2/2] drivers/perf: hisi: Add driver for HiSilicon PCIe PMU
Date: Tue, 24 Aug 2021 15:31:38 +0100	[thread overview]
Message-ID: <20210824143137.GA23146@willie-the-truck> (raw)
In-Reply-To: <20210818051246.29545-3-liuqi115@huawei.com>

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.

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.

Will

  reply	other threads:[~2021-08-24 14:31 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 [this message]
2021-08-25 11:52     ` liuqi (BA)

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=20210824143137.GA23146@willie-the-truck \
    --to=will@kernel.org \
    --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=liuqi115@huawei.com \
    --cc=mark.rutland@arm.com \
    --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).