From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6249FCF9C6B for ; Tue, 24 Sep 2024 16:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:CC:To: From:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=b0Yw/jvEA3ekS3cu9nvUItd+/4ZslCWQ2hBtzx6S95A=; b=K5FNmCjaCZTBGSCBPXLKm91bi5 gI8NriNzvHO+xMoQnikcZNI+chqFBptm94xU/jnvCQ26cycf9V+nzLIxyn8k9/x9NqEUGEwqbQRKJ Kf1z6h2f3n/x7zTSR1L5KRlZa+kBDcTwUHAdyabFqCdBWeKlu5rLnmVXRINIFHYCtLOzOiX9icb5O 3sspu7jbYzwSY8JX2AEVWtj4ZM+oAuQolePhl6ebPGoXN+hQpqjjeBKnERQHRGrFllbw5FJ5J+QRN 4jPfvJ7Nxk4jOu149kVOwV2E1QsHs4xSiOiX2nCsuogo421Xo8BkikY35XSAOIHY2P9BmfTG9EuGI MqkWIVMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1st8c4-00000002s6V-0BzS; Tue, 24 Sep 2024 16:42:08 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1st8at-00000002ru7-1Phz for linux-arm-kernel@lists.infradead.org; Tue, 24 Sep 2024 16:40:57 +0000 Received: from mail.maildlp.com (unknown [172.18.186.231]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XClr35b8vz6L75c; Wed, 25 Sep 2024 00:36:51 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id 872211400D4; Wed, 25 Sep 2024 00:40:48 +0800 (CST) Received: from localhost (10.203.177.66) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 24 Sep 2024 18:40:48 +0200 Date: Tue, 24 Sep 2024 17:40:46 +0100 From: Jonathan Cameron To: Gowthami Thiagarajan CC: , , , , , , , Subject: Re: [PATCH v8] perf/marvell: Marvell PEM performance monitor support Message-ID: <20240924174046.0000242d@Huawei.com> In-Reply-To: <20240924063126.460219-1-gthiagarajan@marvell.com> References: <20240924063126.460219-1-gthiagarajan@marvell.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.203.177.66] X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To frapeml500008.china.huawei.com (7.182.85.71) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240924_094055_704465_E7531439 X-CRM114-Status: GOOD ( 23.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 24 Sep 2024 12:01:26 +0530 Gowthami Thiagarajan 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 > tracks the inbound posted TLPs for the workload. > > Signed-off-by: Gowthami Thiagarajan 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 > +#include > +#include > +#include > +#include > +#include > + > +/* > + * 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,