Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp126733lqe; Wed, 27 Mar 2024 00:20:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrBj62hbO+QQFEdgKKtcPkMXXlrowPA37bW5fsH0T1g6D/C5P6oEWgvQLudOCRXldedcbqnn/bKDPl2BYMLss0U/f753v07LpVUwVJwQ== X-Google-Smtp-Source: AGHT+IG7pTfhEF/jS2iRxYCcE9+m4pUqoqgsiEcQCzdLtT/XcZ2AlE4ZgUTK27IXvtMtxgoJqYnF X-Received: by 2002:a17:902:ec92:b0:1dd:8ed0:59d0 with SMTP id x18-20020a170902ec9200b001dd8ed059d0mr5679282plg.17.1711524036043; Wed, 27 Mar 2024 00:20:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711524036; cv=pass; d=google.com; s=arc-20160816; b=0bXUClWyuUdPi57KcHq3XZhWaxkKDZ4ZuJBtJppRUU3HRBmssNRs4RmJTpoPm+o9tV k2NyAX/D7u/sh5pZ/OIoCWso9JDvuWa0lCv3NxHHYmAL47y3GlY3c3W3VljhqXNZ77rr UO3acUrKFGEmCWcCu+gamrkmQ2WAsjOK1HI6A47aC6SpttAqfazt/St/t+UsSEJK3bxo IYdC8SCEAOHEKQBpN7eHXuxKYYacXNYRt5uJw0SC672x7bNAqVBFZs1K5Buyv4Lf1xkT /dpAM6aoCMrpsQMmjYruw8TuHIQm+0Kf7IJrETsCOAH1kG59P617jRyT812RzIUvUNsM RlJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Z/l/HMo+rs1PzPxqk7ImSDlkM44RFvo9y6uaZ84wbUw=; fh=1awGoXFQD/jPtnlqeOMVpXuOLzyNIUCdaHPFNO/p69Y=; b=GkFJP9+KsiihMQx8+0mpUowwbBRd9wpuouvads4KtUn6S1+wUNY40F9194IC47dvpi uTc6anEhipQpNpHy05DnLtvFdCoew+uBctSv2IDot8zesFNRwy+/wLIrjBN90z7a8brR CYVp6XpOWzK3OjWjhHJ9ep6PYXtDKNF4mE6uPihSJQV1Uv98fE7nIOQMV2yDZ2sGryXt Rd+0Exhkjsf9B4Z5n2udv/YvuNJp2GWU+OvusvqUQNwh/NJHen3PotWogcl3fgzyvS7i 8CRw42Rp/C/FuC8LpFCUhkivBKmZ9cIARhHMt/+7gbw8WxFc0ntlwRniormNnvrG39vD Rx3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=M7SGFJYk; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-120423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e7-20020a17090301c700b001dfcea2b477si9212475plh.59.2024.03.27.00.20.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 00:20:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-120423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=M7SGFJYk; arc=pass (i=1 spf=pass spfdomain=marvell.com dkim=pass dkdomain=marvell.com dmarc=pass fromdomain=marvell.com); spf=pass (google.com: domain of linux-kernel+bounces-120423-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-120423-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A304299111 for ; Wed, 27 Mar 2024 07:20:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC55D4C81; Wed, 27 Mar 2024 07:20:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="M7SGFJYk" Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66F4B2C694 for ; Wed, 27 Mar 2024 07:20:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.148.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711524007; cv=none; b=ehOJVWntZHCzfozQtmsRvI+7HU6zUMIKkY5nUzRArIsjad92Y/hEPV4Tog7Q9m8o48tXttx/2Fyqz7EprjOUBzg81nUWSuDjSEx9pBrXno+pWf23YOEBuWM2tjCZtJn/z1uu9oZMRwhgVuw9oXOZ31iAn7bKGmYlS81IOw4uWXI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711524007; c=relaxed/simple; bh=ZTq+4qNtCP1azUpNOB0zEmq/9GajT6vQsmv20g0qWQA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UScqfV7pEe7A5si7DGgkD5xdvuJVl93/Kz6sQ/qKqPPf9hXR0i9DQTFoBHMMEzF/Zjz+bBObS+jqoWR12nEbxxOh0uj+doEvjPRa+PvdoxbD+xV13KABz/pBG2sfq2IbhMupzm5/mQKN2SddrJwRnAUrWKJSngv25u7+tH+leCM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com; spf=pass smtp.mailfrom=marvell.com; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b=M7SGFJYk; arc=none smtp.client-ip=67.231.148.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=marvell.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=marvell.com Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 42R2R1Sl000794; Wed, 27 Mar 2024 00:19:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=Z/l/HMo+rs1PzPxqk7ImSDlkM44RFvo9y6uaZ84wbUw=; b=M7S GFJYkQhEEpFZV//M1gm4xcL0WWo9xvBwRA4CrafCKG6Y3IL97VT6Hj66QvEcj6z1 kc7hXYTFqYzmaNsEE81f1uG95C6Jn205M6YibLpaAIa30PdYwhERz0RAiYamaxWk dGuhfFDAg7bUmG1K9lEyoWHxzhW9HPrGcx4Mm6HFdRV60cRfSFU/KORgvSh0rdhO C9JwjqN6T04Utf9NZX6zZFfTvHxI6q+0p7ZmEgJiC10fgzmP5mpUz9hw3kV8nzsY cw11aIHci2QwlSVqYQ96ocihzWeBrIsB3XS73Dnfnzxw2sOvaU/cIGtxwDNEtWX5 peuxsIVcpOw+qS+yo6Q== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3x4ap80wum-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 27 Mar 2024 00:19:41 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 27 Mar 2024 00:19:40 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Wed, 27 Mar 2024 00:19:40 -0700 Received: from IPBU-BLR-SERVER1.marvell.com (IPBU-BLR-SERVER1.marvell.com [10.28.8.41]) by maili.marvell.com (Postfix) with ESMTP id B1EDE3F70BF; Wed, 27 Mar 2024 00:19:17 -0700 (PDT) From: Gowthami Thiagarajan To: , , , CC: , , , Gowthami Thiagarajan Subject: [RESEND PATCH v4 3/3] perf/marvell : Odyssey LLC-TAD performance monitor Date: Wed, 27 Mar 2024 12:48:32 +0530 Message-ID: <20240327071832.1556576-4-gthiagarajan@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240327071832.1556576-1-gthiagarajan@marvell.com> References: <20240327071832.1556576-1-gthiagarajan@marvell.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: RgNVzhONDei-Vo2_dyxPJ48RLMZVCjSD X-Proofpoint-ORIG-GUID: RgNVzhONDei-Vo2_dyxPJ48RLMZVCjSD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-27_04,2024-03-21_02,2023-05-22_02 Each TAD provides eight 64-bit counters for monitoring cache behavior.The driver always configures the same counter for all the TADs. The user would end up effectively reserving one of eight counters in every TAD to look across all TADs. The occurrences of events are aggregated and presented to the user at the end of running the workload. The driver does not provide a way for the user to partition TADs so that different TADs are used for different applications. The performance events reflect various internal or interface activities. By combining the values from multiple performance counters, cache performance can be measured in terms such as: cache miss rate, cache allocations, interface retry rate, internal resource occupancy, etc. Each supported counter's event and formatting information is exposed to sysfs at /sys/devices/tad/. Use perf tool stat command to measure the pmu events. For instance: perf stat -e tad_hit_ltg,tad_hit_dtg Signed-off-by: Gowthami Thiagarajan --- drivers/perf/marvell_cn10k_tad_pmu.c | 62 ++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c index fec8e82edb95..df6569f7a06f 100644 --- a/drivers/perf/marvell_cn10k_tad_pmu.c +++ b/drivers/perf/marvell_cn10k_tad_pmu.c @@ -37,6 +37,15 @@ struct tad_pmu { DECLARE_BITMAP(counters_map, TAD_MAX_COUNTERS); }; +enum mrvl_tad_pmu_version { + TAD_PMU_V1 = 1, + TAD_PMU_V2, +}; + +struct tad_pmu_data { + int id; +}; + static int tad_pmu_cpuhp_state; static void tad_pmu_event_counter_read(struct perf_event *event) @@ -214,6 +223,24 @@ static const struct attribute_group tad_pmu_events_attr_group = { .attrs = tad_pmu_event_attrs, }; +static struct attribute *ody_tad_pmu_event_attrs[] = { + TAD_PMU_EVENT_ATTR(tad_req_msh_in_exlmn, 0x3), + TAD_PMU_EVENT_ATTR(tad_alloc_dtg, 0x1a), + TAD_PMU_EVENT_ATTR(tad_alloc_ltg, 0x1b), + TAD_PMU_EVENT_ATTR(tad_alloc_any, 0x1c), + TAD_PMU_EVENT_ATTR(tad_hit_dtg, 0x1d), + TAD_PMU_EVENT_ATTR(tad_hit_ltg, 0x1e), + TAD_PMU_EVENT_ATTR(tad_hit_any, 0x1f), + TAD_PMU_EVENT_ATTR(tad_tag_rd, 0x20), + TAD_PMU_EVENT_ATTR(tad_tot_cycle, 0xFF), + NULL +}; + +static const struct attribute_group ody_tad_pmu_events_attr_group = { + .name = "events", + .attrs = ody_tad_pmu_event_attrs, +}; + PMU_FORMAT_ATTR(event, "config:0-7"); static struct attribute *tad_pmu_format_attrs[] = { @@ -252,8 +279,16 @@ static const struct attribute_group *tad_pmu_attr_groups[] = { NULL }; +static const struct attribute_group *ody_tad_pmu_attr_groups[] = { + &ody_tad_pmu_events_attr_group, + &tad_pmu_format_attr_group, + &tad_pmu_cpumask_attr_group, + NULL +}; + static int tad_pmu_probe(struct platform_device *pdev) { + const struct tad_pmu_data *dev_data; struct device *dev = &pdev->dev; struct tad_region *regions; struct tad_pmu *tad_pmu; @@ -261,6 +296,7 @@ static int tad_pmu_probe(struct platform_device *pdev) u32 tad_pmu_page_size; u32 tad_page_size; u32 tad_cnt; + int version; int i, ret; char *name; @@ -270,6 +306,13 @@ static int tad_pmu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, tad_pmu); + dev_data = device_get_match_data(&pdev->dev); + if (!dev_data) { + dev_err(&pdev->dev, "Error: No device match data found\n"); + return -ENODEV; + } + version = dev_data->id; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Mem resource not found\n"); @@ -319,7 +362,6 @@ static int tad_pmu_probe(struct platform_device *pdev) tad_pmu->pmu = (struct pmu) { .module = THIS_MODULE, - .attr_groups = tad_pmu_attr_groups, .capabilities = PERF_PMU_CAP_NO_EXCLUDE | PERF_PMU_CAP_NO_INTERRUPT, .task_ctx_nr = perf_invalid_context, @@ -332,6 +374,11 @@ static int tad_pmu_probe(struct platform_device *pdev) .read = tad_pmu_event_counter_read, }; + if (version == TAD_PMU_V1) + tad_pmu->pmu.attr_groups = tad_pmu_attr_groups; + else + tad_pmu->pmu.attr_groups = ody_tad_pmu_attr_groups; + tad_pmu->cpu = raw_smp_processor_id(); /* Register pmu instance for cpu hotplug */ @@ -362,16 +409,25 @@ static int tad_pmu_remove(struct platform_device *pdev) return 0; } +static const struct tad_pmu_data tad_pmu_data = { + .id = TAD_PMU_V1, +}; + +static const struct tad_pmu_data tad_pmu_v2_data = { + .id = TAD_PMU_V2, +}; + #ifdef CONFIG_OF static const struct of_device_id tad_pmu_of_match[] = { - { .compatible = "marvell,cn10k-tad-pmu", }, + { .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data }, {}, }; #endif #ifdef CONFIG_ACPI static const struct acpi_device_id tad_pmu_acpi_match[] = { - {"MRVL000B", 0}, + {"MRVL000B", (kernel_ulong_t)&tad_pmu_data}, + {"MRVL000D", (kernel_ulong_t)&tad_pmu_v2_data}, {}, }; MODULE_DEVICE_TABLE(acpi, tad_pmu_acpi_match); -- 2.25.1