linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Gowthami Thiagarajan <gthiagarajan@marvell.com>
Cc: <will@kernel.org>, <mark.rutland@arm.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <andrew@lunn.ch>,
	<sgoutham@marvell.com>, <lcherian@marvell.com>,
	<gcherian@marvell.com>
Subject: Re: [PATCH v8] perf/marvell: Marvell PEM performance monitor support
Date: Tue, 24 Sep 2024 17:40:46 +0100	[thread overview]
Message-ID: <20240924174046.0000242d@Huawei.com> (raw)
In-Reply-To: <20240924063126.460219-1-gthiagarajan@marvell.com>

On Tue, 24 Sep 2024 12:01:26 +0530
Gowthami Thiagarajan <gthiagarajan@marvell.com> wrote:

> PCI Express Interface PMU includes various performance counters
> to monitor the data that is transmitted over the PCIe link. The
> counters track various inbound and outbound transactions which
> includes separate counters for posted/non-posted/completion TLPs.
> Also, inbound and outbound memory read requests along with their
> latencies can also be monitored. Address Translation Services(ATS)events
> such as ATS Translation, ATS Page Request, ATS Invalidation along with
> their corresponding latencies are also supported.
> 
> The performance counters are 64 bits wide.
> 
> For instance,
> perf stat -e ib_tlp_pr <workload>
> tracks the inbound posted TLPs for the workload.
> 
> Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>

A few quick comments inline from a superficial look.

Jonathan


> diff --git a/drivers/perf/marvell_pem_pmu.c b/drivers/perf/marvell_pem_pmu.c
> new file mode 100644
> index 000000000000..d3aca94278fb
> --- /dev/null
> +++ b/drivers/perf/marvell_pem_pmu.c
> @@ -0,0 +1,427 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Marvell PEM(PCIe RC) Performance Monitor Driver
> + *
> + * Copyright (C) 2024 Marvell.
> + */
> +
> +#include <linux/acpi.h>
> +#include <linux/init.h>
> +#include <linux/io.h>
> +#include <linux/module.h>
> +#include <linux/perf_event.h>
> +#include <linux/platform_device.h>
> +
> +/*
> + * Each of these events maps to a free running 64 bit counter
> + * with no event control, but can be reset.
> + *

This blank line adds nothing. I'd drop it.

> + */
> +enum pem_events {
> +	IB_TLP_NPR,
> +	IB_TLP_PR,
> +	IB_TLP_CPL,
> +	IB_TLP_DWORDS_NPR,
> +	IB_TLP_DWORDS_PR,
> +	IB_TLP_DWORDS_CPL,
> +	IB_INFLIGHT,
> +	IB_READS,
> +	IB_REQ_NO_RO_NCB,
> +	IB_REQ_NO_RO_EBUS,
> +	OB_TLP_NPR,
> +	OB_TLP_PR,
> +	OB_TLP_CPL,
> +	OB_TLP_DWORDS_NPR,
> +	OB_TLP_DWORDS_PR,
> +	OB_TLP_DWORDS_CPL,
> +	OB_INFLIGHT,
> +	OB_READS,
> +	OB_MERGES_NPR,
> +	OB_MERGES_PR,
> +	OB_MERGES_CPL,
> +	ATS_TRANS,
> +	ATS_TRANS_LATENCY,
> +	ATS_PRI,
> +	ATS_PRI_LATENCY,
> +	ATS_INV,
> +	ATS_INV_LATENCY,
> +	PEM_EVENTIDS_MAX,

A comma after a MAX entry rarely makes sense. I'd drop it.

> +};



> +static int pem_pmu_offline_cpu(unsigned int cpu, struct hlist_node *node)
> +{
> +	struct pem_pmu *pmu = hlist_entry_safe(node, struct pem_pmu,
> +					       node);

Why wrap? It's under 80 chars anyway.

> +	unsigned int target;
> +
> +	if (cpu != pmu->cpu)
> +		return 0;
> +
> +	target = cpumask_any_but(cpu_online_mask, cpu);
> +	if (target >= nr_cpu_ids)
> +		return 0;
> +
> +	perf_pmu_migrate_context(&pmu->pmu, cpu, target);
> +	pmu->cpu = target;
> +	return 0;
> +}

> +
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id pem_pmu_acpi_match[] = {
> +	{"MRVL000E", 0},
> +	{},

No need for trailing comma.

> +};
> +MODULE_DEVICE_TABLE(acpi, pem_pmu_acpi_match);
> +#endif
> +
> +static struct platform_driver pem_pmu_driver = {
> +	.driver	= {
> +		.name   = "pem-pmu",
> +		.acpi_match_table = ACPI_PTR(pem_pmu_acpi_match),

Drop the ACPI_PTR() protection and the ifdefs.

They provide very little advantage and hurt readabilty.
Maybe make sense if the driver supports dt binding but this
one doesn't.

> +		.suppress_bind_attrs = true,
> +	},
> +	.probe		= pem_perf_probe,
> +	.remove		= pem_perf_remove,
> +};

> diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h
> index 9316c39260e0..254491a6d09b 100644
> --- a/include/linux/cpuhotplug.h
> +++ b/include/linux/cpuhotplug.h
> @@ -228,6 +228,7 @@ enum cpuhp_state {
>  	CPUHP_AP_PERF_ARM_APM_XGENE_ONLINE,
>  	CPUHP_AP_PERF_ARM_CAVIUM_TX2_UNCORE_ONLINE,
>  	CPUHP_AP_PERF_ARM_MARVELL_CN10K_DDR_ONLINE,
> +	CPUHP_AP_PERF_ARM_MRVL_PEM_ONLINE,

Silly question but which of the rules at: 
https://elixir.bootlin.com/linux/v6.11/source/include/linux/cpuhotplug.h#L45
means this can't use CPUHP_AP_ONLINE_DYN?

Quite a few recent PMU drivers have used that without issues.

>  	CPUHP_AP_PERF_POWERPC_NEST_IMC_ONLINE,
>  	CPUHP_AP_PERF_POWERPC_CORE_IMC_ONLINE,
>  	CPUHP_AP_PERF_POWERPC_THREAD_IMC_ONLINE,



      reply	other threads:[~2024-09-24 16:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24  6:31 [PATCH v8] perf/marvell: Marvell PEM performance monitor support Gowthami Thiagarajan
2024-09-24 16:40 ` Jonathan Cameron [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=20240924174046.0000242d@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=andrew@lunn.ch \
    --cc=gcherian@marvell.com \
    --cc=gthiagarajan@marvell.com \
    --cc=lcherian@marvell.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=sgoutham@marvell.com \
    --cc=will@kernel.org \
    /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).