From patchwork Fri Oct 24 05:48:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158061 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C1B40489BE; Fri, 24 Oct 2025 07:48:47 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 963B5402AF; Fri, 24 Oct 2025 07:48:46 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 0E7AD402AC for ; Fri, 24 Oct 2025 07:48:44 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3rL4M005087; Thu, 23 Oct 2025 22:48:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=n Babk8fNuAZMuGhm3phyhr8A2mISUxwNbOp72Gm1nKE=; b=XNm99w9e24iDuHu8S v2nfkb1h/s7RuzsP7YVwQoP6nX78twnABSytt0zEvWoW3QH/L2A2m6F2GheJidRl RYw/QxFLZlAnrhzhHo0MxdkZGdeR2zsfgUzPm0EDpphOtA9M06qwgUJgPRYcI3B2 gRK4YJ961Tm178gyhGiW57LJv8Os+DIgit7GEDTsbA+jF2f5kWLI5oaELO5ccrCV zfzk3u3myqgiXD7/JJVPm1RNB1TV8/lDarNjO2gpOahSTQDmSqyG9L8urvN9mOj8 xONDPDw3PxnudX0IO+qHpvV8CoJT8cL2aqS6FZiixTByzbu4gkBBrC/+ihU4KbMW gPTyQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 4a01xn84st-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:48:42 -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.25; Thu, 23 Oct 2025 22:48:39 -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.25 via Frontend Transport; Thu, 23 Oct 2025 22:48:39 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 90CB53F7071; Thu, 23 Oct 2025 22:48:37 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski CC: , , , , , , , , , , , , Subject: [PATCH v11 1/9] pmu: quiesce chkincs warnings Date: Fri, 24 Oct 2025 07:48:22 +0200 Message-ID: <20251024054830.933910-2-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: cn5tqIko7Xo6CEYbKMtMx4G6MAxYnoT4 X-Proofpoint-GUID: cn5tqIko7Xo6CEYbKMtMx4G6MAxYnoT4 X-Authority-Analysis: v=2.4 cv=JfmxbEKV c=1 sm=1 tr=0 ts=68fb133a cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=S849gBgu0BXtzdSz8A8A:9 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI0MDAzMSBTYWx0ZWRfX8UawjQW5eLty AKK/dnfZlza6a4PUT3iv7PdCbzzgUCuhqeBWs9o/M+rliosQ55fnGLuq1QOParKPmfr+rKdODdG XRSbdLlXljEcRhuOrck6zZcHwt+IIBH0jWJC27585fRXyzr1cG2E+PlBaoVwtl8guxqc8DL6lme BsYKGOOEvqofKdb9Qw32c2jwycUmpInIxFHM8jPpEtzZ/o0UA8mzNBD1FxWnBSEfWLbQSpw5vQb GuE71l3UNrRwiToKdtxQkv3W6lkKQ7Yxea/G8lXHjwg+VTKO0Tvz7qnwqmzb8ZiYiEChLPrabCn qDQrsplylEQxDkO9rD4kljUvh5PZCg4eJcAO5PTiyFEWEYupAt6dGNkNoJSNttRI3OOlk6pNRO2 hDfDEGJ/OWt+mLKgNuV404SQQapMwg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org chkincs tool produces warnings if internal functions are called directly. There are multiple ways to quiesce these warnings but common pattern now is excluding experimental code from build and triggering abort in runtime. Follow that pattern here. Signed-off-by: Tomasz Duszynski --- lib/pmu/rte_pmu.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/pmu/rte_pmu.h b/lib/pmu/rte_pmu.h index 57b634ecd8..fcf125a908 100644 --- a/lib/pmu/rte_pmu.h +++ b/lib/pmu/rte_pmu.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #define RTE_PMU_SUPPORTED @@ -181,12 +182,6 @@ __rte_experimental int rte_pmu_add_event(const char *name); -/* quiesce warnings produced by chkincs caused by calling internal functions directly */ -#ifndef ALLOW_EXPERIMENTAL_API -#define __rte_pmu_enable_group(group) ({ RTE_SET_USED(group); 0; }) -#define __rte_pmu_read_userpage(pc) ({ RTE_SET_USED(pc); 0; }) -#endif - /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. @@ -211,6 +206,7 @@ __rte_experimental static __rte_always_inline uint64_t rte_pmu_read(unsigned int index) { +#ifdef ALLOW_EXPERIMENTAL_API unsigned int lcore_id = rte_lcore_id(); struct rte_pmu_event_group *group; @@ -231,6 +227,10 @@ rte_pmu_read(unsigned int index) } return __rte_pmu_read_userpage(group->mmap_pages[index]); +#else + RTE_SET_USED(index); + RTE_VERIFY(false); +#endif } #ifdef __cplusplus From patchwork Fri Oct 24 05:48:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158062 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 94DB9489BE; Fri, 24 Oct 2025 07:48:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C035E402D3; Fri, 24 Oct 2025 07:48:51 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id EE064402D2 for ; Fri, 24 Oct 2025 07:48:49 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D2Rh027349; Thu, 23 Oct 2025 22:48:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=5 0brCj+l/gjNzeC15cZNjAOM6wTNM8pGoalrVuInMe8=; b=S1pqQl3PWWVbh3wDG PEeAV9bQFCMEgqhzA7wyNOZ/NGHisQVTJcEjj2BneRUjiQK8AxiC7DOlARXt6INU N2oDwzFMJM56kd0fhal4UDw48sBNiZEd1EDFBlsxna3I6TUFju0+ZLlUbGKSw7N0 QLabkpVtLfzSSlrqkKpmhGjJVBY3IMTuN9FUrAf4koR71ikAsKyBRhePuDfoAyD+ ElSmn7HcwvKO3zA4jstKvtyW7lEWPN6cYYqOudLJFKgZsg3Z5t+dO4ZqlPdV3PWe 2bQDR1hLWxAPGq0VUhg9Xxs9pTgkMiTIpdhlFw1GSxvzJYDrv+N0FZ3cbKlyI6VR EGyTA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 49yx9prh7n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:48:47 -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.25; Thu, 23 Oct 2025 22:48:44 -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.25 via Frontend Transport; Thu, 23 Oct 2025 22:48:44 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 148973F7071; Thu, 23 Oct 2025 22:48:41 -0700 (PDT) From: Tomasz Duszynski To: Jerin Jacob , Sunil Kumar Kori , Tyler Retzlaff CC: , , , , , , , , , , , Tomasz Duszynski Subject: [PATCH v11 2/9] trace: change scope of conditional block Date: Fri, 24 Oct 2025 07:48:23 +0200 Message-ID: <20251024054830.933910-3-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 5xX_ysVvptXgLbiIspWxETi7gwQYWzS6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNyBTYWx0ZWRfX7OKCEGfiqzKJ g+K9+S8+U0liwGqdKrjx2NAk4w+rKUkq1QVYYf4TqICS9W0NVb+lnMRXL6/csK/U4+bReAQhs7+ ZgTSKZiBvDvnzXg99ebRicmTGnwaDjOp8Ar/SDtv3dBhHwJfh0Jhi6gESoWV1WdwfVZb9985JZt 7rMbn2RleYOFJJMTzs1chctw87r0nLnKmrBnies+ZiSztzV3Av1N1BqN01qm4ekQ2xOJ68ob/SP zbHT3Szvdsed1rm+jPVe6kb9iVC6Y7bhyijcgVs0GjOzX7ArWuigtRSc2atuaQ9+KLSi9CWExQ4 wNZ0BBNF/URScoNOE2ezRFAHLdJ94Bb+Oz3U3cJKB8n0gMPe4NWepH/QfTNvno7KQr0dDYHMe+T GX6RmpQXp4s+JA4gOPK1BPBJxZCsWg== X-Proofpoint-GUID: 5xX_ysVvptXgLbiIspWxETi7gwQYWzS6 X-Authority-Analysis: v=2.4 cv=Wvom8Nfv c=1 sm=1 tr=0 ts=68fb133f cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=mkB43dQOfHrW3UneyFcA:9 a=zZCYzV9kfG8A:10 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If ALLOW_EXPERIMENTAL_API isn't defined warnings should show up but build itself should not fail (unless -Dwerror=true). In order to avoid build failures change the scope of conditional block. Signed-off-by: Tomasz Duszynski --- lib/eal/include/rte_trace_point.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h index c0ebf1ce13..394b2619c5 100644 --- a/lib/eal/include/rte_trace_point.h +++ b/lib/eal/include/rte_trace_point.h @@ -289,7 +289,6 @@ int __rte_trace_point_register(rte_trace_point_t *trace, const char *name, #ifndef __DOXYGEN__ #ifndef _RTE_TRACE_POINT_REGISTER_H_ -#ifdef ALLOW_EXPERIMENTAL_API #define __RTE_TRACE_EVENT_HEADER_ID_SHIFT (48) @@ -314,6 +313,8 @@ struct __rte_trace_header { uint8_t mem[]; }; +#ifdef ALLOW_EXPERIMENTAL_API + RTE_DECLARE_PER_LCORE(void *, trace_mem); static __rte_always_inline void * From patchwork Fri Oct 24 05:48:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158063 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CABE4489BE; Fri, 24 Oct 2025 07:48:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6203B402EB; Fri, 24 Oct 2025 07:48:56 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 01BCA40608 for ; Fri, 24 Oct 2025 07:48:54 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3rdXA007308; Thu, 23 Oct 2025 22:48:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=Y sEDkKW1iDJMGMekH2u76KGFzXdnHq2XbYLlXIOm2/8=; b=A1ZQXFR1cFW0l4wdt 1Zk/rQLsBtHYB7w36mi4kw3fbiKT+CGHmPrXxDHpyyTo1SVtDcJKqEUUaBTBjmbq A8CEvcRe8dAPBdp+GztjfwviJ9mSfa8zB6hLTkVCX0uipSO//WzrHlHaQA0G19E7 Q/BR8TiT3m7Xfm//enbgI+OhDxuHTtFhdsOveOl1QUQW5OlqKvmbC0fELr0D0uvC HteLxXIPS3k3kc1CLPD7WdwT4uasSuHoZnTjz1KEzQMx1zZFKj/cgc+34RbZic4B IPV5JLm1mrnjpJdVdb+iFZwAo6c91P0dNeyfhHzpMYY0mbYTIcJGxIxNwpqsvmx1 fq95Q== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 4a01xn84u5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:48:51 -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.25; Thu, 23 Oct 2025 22:48:48 -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.25 via Frontend Transport; Thu, 23 Oct 2025 22:48:48 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id D5A023F7071; Thu, 23 Oct 2025 22:48:46 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski CC: , , , , , , , , , , , , Subject: [PATCH v11 3/9] lib/pmu: export only necessary arch headers Date: Fri, 24 Oct 2025 07:48:24 +0200 Message-ID: <20251024054830.933910-4-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 44PKMIeSRfsZMMv9IGBNjIwEsQhzIAPU X-Proofpoint-GUID: 44PKMIeSRfsZMMv9IGBNjIwEsQhzIAPU X-Authority-Analysis: v=2.4 cv=JfmxbEKV c=1 sm=1 tr=0 ts=68fb1343 cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=r8mbcy_HfW-B3KRPtLcA:9 a=zZCYzV9kfG8A:10 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDI0MDAzMSBTYWx0ZWRfX7Ax0ww4yCk9k zBWxgN7/vp71UsCCwo6UvJqCW8s4pJZ4XbJChnMbpE+os4tHvvT+hxiItPTqfcXAy1lpMP2+RKk r1Y7PmpYV9/KfVyldaBIgjdWO7H5GtA/fClrIobFShozHCzXlkQq9ZT61j4/Wjwk2IrJjgnj3Sa VNNgwCaGN9v/Vi8xTnNKPPY1rh6K2uWQWx25stNy+StyY1q69X2Y5IsCR5FBq9TK7IhfSWvR+/U PElNIswJNY0HnPyDetJvMjZ338ybaIyNlgGfrCpi0HB3mcLx+hbxdpnUoQuCqgCcp6CEGxdOjNy ggxA6S0WUzZwRetkul+eG54Y4GI8NBYLI6bp/HVQOzsxznyPDBZNsguKkyoPVm4QtB1d2+gi0l2 CoJjxDFsleDQIYc0h5e4UtTddID3qA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Install only architecture specific headers to avoid header pollution. Signed-off-by: Tomasz Duszynski --- lib/pmu/meson.build | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/pmu/meson.build b/lib/pmu/meson.build index bcb6d10f1a..53013d0ed6 100644 --- a/lib/pmu/meson.build +++ b/lib/pmu/meson.build @@ -10,13 +10,13 @@ endif headers = files('rte_pmu.h') sources = files('pmu.c') -indirect_headers += files( - 'rte_pmu_pmc_arm64.h', - 'rte_pmu_pmc_x86_64.h', -) - if dpdk_conf.has('RTE_ARCH_ARM64') + indirect_headers += files('rte_pmu_pmc_arm64.h') sources += files('pmu_arm64.c') endif +if dpdk_conf.has('RTE_ARCH_X86_64') + indirect_headers += files('rte_pmu_pmc_x86_64.h') +endif + deps += ['log'] From patchwork Fri Oct 24 05:48:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158064 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 29B83489BE; Fri, 24 Oct 2025 07:49:05 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9DAB940615; Fri, 24 Oct 2025 07:49:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 2DAAB402D2 for ; Fri, 24 Oct 2025 07:49:01 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D3nS007572; Thu, 23 Oct 2025 22:48:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=x Q+mwGFtcjQ9tfcGSbfzlVq6mjLI1OUaTQNclfw7Bpw=; b=h+6YxG3Quq/E+q12P WzmkikzXaE1n7ZNp5eTuRNxqv+SJNrCAydtECip0NtFWJ4GwlBkwxhSDc1OPlqKF YAq7YgRMQ0ncnKgUqBjb8xeERUVmvwriYm8TmB1r1B27Y6tsu3TJAdJncW+CBrH4 xmZZ5HESTOO0L/8qQtDwdexhr4uDgUH3EV+98R1yW/aLcb6IgCxrtsj7ZP9IrT1q +ofeaaY4EmoRfpGsb6IQmE7FlnymhThtn4kI18QUtXYzst2W71J2ljvQNbXVC4Lh TkCP3+Zodhgeixvi0t2BY6Y32xNE4XSW3yI1mvvo02zwNS8z3VEaKmQpfQ/mQ65e VFQBg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 49yx2krjas-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:48:56 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Thu, 23 Oct 2025 22:49:05 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Thu, 23 Oct 2025 22:49:05 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 62C373F7071; Thu, 23 Oct 2025 22:48:51 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski , Wathsala Vithanage CC: , , , , , , , , , , , Subject: [PATCH v11 4/9] lib/pmu: reimplement per-arch ops as callbacks Date: Fri, 24 Oct 2025 07:48:25 +0200 Message-ID: <20251024054830.933910-5-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNCBTYWx0ZWRfX3S2ZqzqkxGBE sQi++gNQh9pHmnK9nc9CPhXpfdUXCKHnztTfZ/4Dgr5WL3DSwbwNj1y2BFuYdW2nus4A6REp3kB SRy17cQNEgyLx0DfmYg1cLBMkAgeJMgDNeT0LD948an8OdCwDeJHzamE/WFPdjcpB9/FStR3hi/ VijpGz+LTcWXsFTwkD5XIT3dQaw5qHydmOnVu6EkkvvjLDe7UFabsdoo6mUZNAHJ1WXFy2k9hrJ 3xUpLJFs7LRjR+Fj9WIqmYbVQT+TDND7P5JezIctFYUcht0UmWttak05WJcS3WiUxI9p+Ns6LUV 8UMzUYROT5KygYn3VV0lJmfNuTrHhs9/Kbm2ks2Yk89plc+7FOgHZzlR0OOq9iwSyJk0op5vckX H20s8ATyrYcaBAthqECp/Yg1xysJGw== X-Authority-Analysis: v=2.4 cv=bdBmkePB c=1 sm=1 tr=0 ts=68fb1348 cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=C4pt3Q8vb_h7C6Lo94IA:9 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-ORIG-GUID: 3GgXBxx-J6UW9YSdzHo_cHlWDcKsX7mS X-Proofpoint-GUID: 3GgXBxx-J6UW9YSdzHo_cHlWDcKsX7mS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Replace static per-architecture ops with a callback-based ops structure. This makes architecture-specific PMU implementations more modular and easier to extend. Signed-off-by: Tomasz Duszynski --- lib/pmu/pmu.c | 17 +---------------- lib/pmu/pmu_arm64.c | 19 +++++++++++++------ lib/pmu/pmu_private.h | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 51 insertions(+), 28 deletions(-) diff --git a/lib/pmu/pmu.c b/lib/pmu/pmu.c index 4c7271522a..d8212ca898 100644 --- a/lib/pmu/pmu.c +++ b/lib/pmu/pmu.c @@ -40,22 +40,7 @@ struct rte_pmu_event { RTE_EXPORT_INTERNAL_SYMBOL(rte_pmu) struct rte_pmu rte_pmu; -/* Stubs for arch-specific functions */ -#if !defined(RTE_PMU_SUPPORTED) || defined(RTE_ARCH_X86_64) -int -pmu_arch_init(void) -{ - return 0; -} -void -pmu_arch_fini(void) -{ -} -void -pmu_arch_fixup_config(uint64_t __rte_unused config[3]) -{ -} -#endif +const struct pmu_arch_ops *arch_ops; static int get_term_format(const char *name, int *num, uint64_t *mask) diff --git a/lib/pmu/pmu_arm64.c b/lib/pmu/pmu_arm64.c index a23f1864df..3f4f5fa297 100644 --- a/lib/pmu/pmu_arm64.c +++ b/lib/pmu/pmu_arm64.c @@ -62,8 +62,8 @@ write_attr_int(const char *path, int val) return 0; } -int -pmu_arch_init(void) +static int +pmu_arm64_init(void) { int ret; @@ -78,17 +78,24 @@ pmu_arch_init(void) return write_attr_int(PERF_USER_ACCESS_PATH, 1); } -void -pmu_arch_fini(void) +static void +pmu_arm64_fini(void) { write_attr_int(PERF_USER_ACCESS_PATH, restore_uaccess); } -void -pmu_arch_fixup_config(uint64_t config[3]) +static void +pmu_arm64_fixup_config(uint64_t config[3]) { /* select 64 bit counters */ config[1] |= RTE_BIT64(0); /* enable userspace access */ config[1] |= RTE_BIT64(1); } + +static const struct pmu_arch_ops arm64_ops = { + .init = pmu_arm64_init, + .fini = pmu_arm64_fini, + .fixup_config = pmu_arm64_fixup_config, +}; +PMU_SET_ARCH_OPS(arm64_ops) diff --git a/lib/pmu/pmu_private.h b/lib/pmu/pmu_private.h index 3db1cb242b..d74f7f4092 100644 --- a/lib/pmu/pmu_private.h +++ b/lib/pmu/pmu_private.h @@ -5,20 +5,47 @@ #ifndef PMU_PRIVATE_H #define PMU_PRIVATE_H +/** + * Structure describing architecture specific PMU operations. + */ +struct pmu_arch_ops { + int (*init)(void); + void (*fini)(void); + void (*fixup_config)(uint64_t config[3]); +}; + +extern const struct pmu_arch_ops *arch_ops; + +#define PMU_SET_ARCH_OPS(ops) \ + RTE_INIT(libpmu_set_arch_ops) \ + { \ + arch_ops = &(ops); \ + } + /** * Architecture-specific PMU init callback. * * @return * 0 in case of success, negative value otherwise. */ -int -pmu_arch_init(void); +static inline int +pmu_arch_init(void) +{ + if (arch_ops != NULL && arch_ops->init != NULL) + return arch_ops->init(); + + return 0; +} /** * Architecture-specific PMU cleanup callback. */ -void -pmu_arch_fini(void); +static inline void +pmu_arch_fini(void) +{ + if (arch_ops != NULL && arch_ops->fini != NULL) + arch_ops->fini(); +} /** * Apply architecture-specific settings to config before passing it to syscall. @@ -27,7 +54,11 @@ pmu_arch_fini(void); * Architecture-specific event configuration. * Consult kernel sources for available options. */ -void -pmu_arch_fixup_config(uint64_t config[3]); +static inline void +pmu_arch_fixup_config(uint64_t config[3]) +{ + if (arch_ops != NULL && arch_ops->fixup_config != NULL) + arch_ops->fixup_config(config); +} #endif /* PMU_PRIVATE_H */ From patchwork Fri Oct 24 05:48:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158065 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 94B47489BE; Fri, 24 Oct 2025 07:49:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A187640613; Fri, 24 Oct 2025 07:49:05 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id B174040648 for ; Fri, 24 Oct 2025 07:49:03 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D5DG027374; Thu, 23 Oct 2025 22:49:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=5 kyEZwZ+A8KNcbnEbh5JbLOUWkOgZIOwPgUdm/ie7w0=; b=cTs4sK+Q/R+pjRUhC HxeUoc6lwZVV0KUQgvNNWokt+N1MWMVFCViUbfY6flu2BeJ4AcQPHTDDjHvgIPTF KW99fqqwTRKnF3FkumCZvsm3pIDmEMP0F6pabu88dAUTB/GuxDh1ZNje81CCAul+ xGFf18LxjjZpDGF/IOxO+A6Bb+dwI8R7BrD2agt4j9FRoV4gmRxqxLJj3vXPAQj/ IbK24ZtHzIIF7ypPLAQEAOz+sVsKXd5XBYQkgM5Ly5OgcSNdNzmjgVmcuYedwsh+ JnPSP6sa1qI4Gj+D9v9twUZbESKLV+r1TfP0NaksoWuBtxp2Vp9a5XzPeS9WTigh gTTjQ== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 49yx9prh86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:49:00 -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.25; Thu, 23 Oct 2025 22:48:58 -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.25 via Frontend Transport; Thu, 23 Oct 2025 22:48:58 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id DE0653F7071; Thu, 23 Oct 2025 22:48:55 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski , Wathsala Vithanage CC: , , , , , , , , , , , Subject: [PATCH v11 5/9] lib/pmu: do not try enabling perf counter access on arm64 Date: Fri, 24 Oct 2025 07:48:26 +0200 Message-ID: <20251024054830.933910-6-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: R3oQuna342RQb6Ydg1N3MHjjIi7dg2XS X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNyBTYWx0ZWRfXzsUCH87JQWC8 /TpjvI0HXBPkhdeLB8IYHGzEmSQRdTMZokXv21SevkeKXk1eodC8P+DZdbvYCIEVFnnoSchia1S WJ2CQ6sHCJwouQNMo0c2lppTeVcowTbWLvH3uDm+2+6KmX5+WrE9Jra80Lk7EviX/GxcxAhI8R2 tiKmyVQFtfWoSO6AxjjCqqbCmBA+q0ejjAkkSesZnzxB9QOfWe2wl7sI/EkXYjc7k6D8ktyt6i/ ydkVceuj6jYpBBM4eqs3F0Q3BbuwUQYtHKgVRmjqWez7MomTmwcTpLzEhOA4/xhAsAYD9FrJGn5 ljOHqDGdeZONTkMPT6//QQewzvkILjVsfKkwy7nnaPTLGNnXHxAGykw0D/AQQJSQJcqz/e+1TWx iiAGzwXsgRKT2KRF2tsoKgtZJSfr0w== X-Proofpoint-GUID: R3oQuna342RQb6Ydg1N3MHjjIi7dg2XS X-Authority-Analysis: v=2.4 cv=Wvom8Nfv c=1 sm=1 tr=0 ts=68fb134c cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=Oq_oc4OIQJrBT0az780A:9 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org /proc/sys/kernel/perf_user_access attribute allow user process to access perf counters. Though in order to change it binary requires elevated capabilities or must be run as root. If that's not the case counter access remains disabled. Hence to avoid confusion log message that that warns user about that. Signed-off-by: Tomasz Duszynski --- lib/pmu/pmu.c | 4 ---- lib/pmu/pmu_arm64.c | 39 +++++++-------------------------------- lib/pmu/pmu_private.h | 8 ++++++++ 3 files changed, 15 insertions(+), 36 deletions(-) diff --git a/lib/pmu/pmu.c b/lib/pmu/pmu.c index d8212ca898..e4d4f146d1 100644 --- a/lib/pmu/pmu.c +++ b/lib/pmu/pmu.c @@ -25,10 +25,6 @@ #define FIELD_PREP(m, v) (((uint64_t)(v) << (rte_ffs64(m) - 1)) & (m)) RTE_LOG_REGISTER_DEFAULT(rte_pmu_logtype, INFO) -#define RTE_LOGTYPE_PMU rte_pmu_logtype - -#define PMU_LOG(level, ...) \ - RTE_LOG_LINE(level, PMU, ## __VA_ARGS__) /* A structure describing an event */ struct rte_pmu_event { diff --git a/lib/pmu/pmu_arm64.c b/lib/pmu/pmu_arm64.c index 3f4f5fa297..2c40b5f702 100644 --- a/lib/pmu/pmu_arm64.c +++ b/lib/pmu/pmu_arm64.c @@ -14,8 +14,6 @@ #define PERF_USER_ACCESS_PATH "/proc/sys/kernel/perf_user_access" -static int restore_uaccess; - static int read_attr_int(const char *path, int *val) { @@ -39,49 +37,26 @@ read_attr_int(const char *path, int *val) return 0; } -static int -write_attr_int(const char *path, int val) -{ - char buf[BUFSIZ]; - int num, ret, fd; - - fd = open(path, O_WRONLY); - if (fd == -1) - return -errno; - - num = snprintf(buf, sizeof(buf), "%d", val); - ret = write(fd, buf, num); - if (ret == -1) { - close(fd); - - return -errno; - } - - close(fd); - - return 0; -} - static int pmu_arm64_init(void) { - int ret; + int uaccess, ret; - ret = read_attr_int(PERF_USER_ACCESS_PATH, &restore_uaccess); + ret = read_attr_int(PERF_USER_ACCESS_PATH, &uaccess); if (ret) return ret; - /* user access already enabled */ - if (restore_uaccess == 1) - return 0; + if (uaccess != 1) + PMU_LOG(WARNING, "access to perf counters disabled, " + "run 'echo 1 > %s' to enable", + PERF_USER_ACCESS_PATH); - return write_attr_int(PERF_USER_ACCESS_PATH, 1); + return ret; } static void pmu_arm64_fini(void) { - write_attr_int(PERF_USER_ACCESS_PATH, restore_uaccess); } static void diff --git a/lib/pmu/pmu_private.h b/lib/pmu/pmu_private.h index d74f7f4092..82118df8b3 100644 --- a/lib/pmu/pmu_private.h +++ b/lib/pmu/pmu_private.h @@ -5,6 +5,14 @@ #ifndef PMU_PRIVATE_H #define PMU_PRIVATE_H +#include + +extern int rte_pmu_logtype; +#define RTE_LOGTYPE_PMU rte_pmu_logtype + +#define PMU_LOG(level, ...) \ + RTE_LOG_LINE(level, PMU, ## __VA_ARGS__) + /** * Structure describing architecture specific PMU operations. */ From patchwork Fri Oct 24 05:48:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158066 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id F3141489BE; Fri, 24 Oct 2025 07:49:15 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97B6240612; Fri, 24 Oct 2025 07:49:11 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id C34A7402D3 for ; Fri, 24 Oct 2025 07:49:09 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D0bL022962; Thu, 23 Oct 2025 22:49:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=c hyCDoCAt+EPv0mBMXf4rRHl7BNmnOiieHAlgK+Vibo=; b=c81rhqatZcj4T6Vok pNaqO48CN/lS9FC5A5ZJZC4VQThCi1ftCtGwEa5RwIRZH5B4W9K2wvoDzHJn8+J/ bonhzIRmWwjf9Uwd9dNQEP7cTop8LgM7S89sHmLmNnsinErOttjBR63q3nUBlgs6 Gh1eAJufSgBggrbF0Ekv28MGODAxQcWR3SdlctX1GbO/9iU/WMmF9bOwWEuPUQTm X4FtzinW1AjqpMVAnPSaBMz3pSzjZSE1g/xfkwfrHQTbsY0xx1oMPFBMxLxeRjEd kjwsYijo/pOuz+m9JRr2aqmnDhgcjMmtSohrgELyvGL5hvrZbNTVVg8x4BOBmBbo UZ0AA== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 49yx2j0jg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:49:05 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Thu, 23 Oct 2025 22:49:15 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Thu, 23 Oct 2025 22:49:15 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 8A6BE3F7071; Thu, 23 Oct 2025 22:49:00 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski CC: , , , , , , , , , , , , Subject: [PATCH v11 6/9] lib/pmu: use build system defined RTE_LIB_PMU macro Date: Fri, 24 Oct 2025 07:48:27 +0200 Message-ID: <20251024054830.933910-7-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNCBTYWx0ZWRfX2ZQ5bd8In2nZ LfiVOgUAkxRprKfm88DTsFpYMj/yDNtHMDDUbWL0KwSpO9SETA24n7KPlzSNaK0HdhXRlNg9Ba3 //MHoSKnv/RTFiRCpeOLdSgt3ugqGFSsc3lE3PO5XrrPKuMIfm8WGNF5TiVBrcS2GMRIH2tcvsZ sn/9emcBI57/+ucr3a8/l+iU2325+1KSzpgH9VLRr1JwNebNXa8M9NcbcRosVsNJFdL/3zJ03Fh b108VF3m51apu7WLllz6CpOSKwe0l5P/S2Iq8yP2uW9bEdDGJwVhQwHBfwsziuu24ijfN0P9eOj 7VEmwk4gT7W/gmf+wlblmR+v1mcDAKU/AtPQCR5gH12ovcIVAm0qA+YcREpOb7r/OCnW2jVI9u2 0/5im1AZzIqK32igefa+1y9jlPVLwg== X-Proofpoint-GUID: wzNHx5mPVzz6k195wNEorgy4GvAjMQd- X-Proofpoint-ORIG-GUID: wzNHx5mPVzz6k195wNEorgy4GvAjMQd- X-Authority-Analysis: v=2.4 cv=Rs7I7SmK c=1 sm=1 tr=0 ts=68fb1351 cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=4ao0HVNFi0lqQHF77aQA:9 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org RTE_LIB_PMU is defined by build system automatically if DPDK is build for Linux. Otherwise it's missing. That said all cases where conditional compilation is required can be handled without introducing other macros. Signed-off-by: Tomasz Duszynski --- lib/pmu/rte_pmu.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/pmu/rte_pmu.h b/lib/pmu/rte_pmu.h index fcf125a908..2e3678d966 100644 --- a/lib/pmu/rte_pmu.h +++ b/lib/pmu/rte_pmu.h @@ -34,13 +34,10 @@ #include #include -#define RTE_PMU_SUPPORTED #if defined(RTE_ARCH_ARM64) #include "rte_pmu_pmc_arm64.h" #elif defined(RTE_ARCH_X86_64) #include "rte_pmu_pmc_x86_64.h" -#else -#undef RTE_PMU_SUPPORTED #endif #ifdef __cplusplus From patchwork Fri Oct 24 05:48:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158067 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4FFB0489BE; Fri, 24 Oct 2025 07:49:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B23B240654; Fri, 24 Oct 2025 07:49:15 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 746AF40652 for ; Fri, 24 Oct 2025 07:49:14 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D0bM022962; Thu, 23 Oct 2025 22:49:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=r lB74WJL7+wVWpaBdJtsljjKKk/CXUnZkpuxEeMOG/E=; b=H074p2bL5sviNffLb MDNMgfF69brsd6d3zia5rxUdrzuU/g/eyr6cxlg47PxSI4MiisYeMkKV/EMg5JZA 4RI8nMW7urZOPjBgIVnxrg4qRBTV0DjyWqk2tG05M5+wu4VFwIpZ0LkshHD+OjC9 Wg9MVpRKos/z6eIOrhCvIYXNm2TGUrEi8wumPGngbnigBigB5T9ntzfcNqjYEHd9 qdWWwqLEh7KyLilhc95DYlMClbpYpSwUe2fSRixM9oMG8k+dyBAi3atKN7EiCLxJ L/37nk48rjaAYKNXh4ibIZOQSOp1N0vYAos1pfijFSrreFzmqhsMxtGGyuvCTSzP i6+3w== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 49yx2j0jg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:49:10 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Thu, 23 Oct 2025 22:49:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Thu, 23 Oct 2025 22:49:20 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 8AACF3F7071; Thu, 23 Oct 2025 22:49:05 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski CC: , , , , , , , , , , , , Subject: [PATCH v11 7/9] test/pmu: enable test Date: Fri, 24 Oct 2025 07:48:28 +0200 Message-ID: <20251024054830.933910-8-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNCBTYWx0ZWRfX15jiC1RzGMU0 NGfZGwQbbG/F7IOXqBrgCuwU1qUQMHTlXg+OGRfHlf0OKBbOcc1JorT5OoaHOEwTG90FLJlH/Mx Npo8hjaOz6zol1fjII/oWRUem82RjprDw1bhP8Hu5X5YQx2rt5siI86AtZEeFNTxBluDgIsrtA7 TEYtdUZHZc5hywo431M9wWEEV2WWwKjwEpC32HsB43Cpv/t/jmPHoIJrvcG7zUzQdnPJ5fYzhgW ryLrSIvnDl6Fy+ydNxbWP99GWgpiKL9kCmHFBS4eE7wcXjTY/ZrnMqm0TMBL+zLotvFhRiBGgR5 /Sc5zr5LNougbuB3YCpvhDY3afrgXBxMxwbPAbSwXXEwH5Ts2QmHEh+vuso+KqiZM9TdMP0bFI3 kpsXdF/EKAHgvl4WqcSCaF+KjYBklQ== X-Proofpoint-GUID: Y6uuskI3nYxDcsiY2QgvBBf1S8H466yK X-Proofpoint-ORIG-GUID: Y6uuskI3nYxDcsiY2QgvBBf1S8H466yK X-Authority-Analysis: v=2.4 cv=Rs7I7SmK c=1 sm=1 tr=0 ts=68fb1356 cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=IkcTkHD0fZMA:10 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=VwQbUJbxAAAA:8 a=1XWaLZrsAAAA:8 a=M5GUcnROAAAA:8 a=8HUT6ekSxiGaV7mw7QIA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Enable test to allow users to verify basic functionality. Due to varying configuration options across distributions and kernels user should ensure that all requirements are satisfied before starting test. Signed-off-by: Tomasz Duszynski --- app/test/test_pmu.c | 60 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 6 deletions(-) diff --git a/app/test/test_pmu.c b/app/test/test_pmu.c index 10513bf9c9..7f450b3566 100644 --- a/app/test/test_pmu.c +++ b/app/test/test_pmu.c @@ -2,10 +2,48 @@ * Copyright(C) 2025 Marvell International Ltd. */ +#include +#include +#include +#include + #include #include "test.h" +#define PERF_EVENT_PARANOID_PATH "/proc/sys/kernel/perf_event_paranoid" + +static bool perf_allowed_quirk(void) +{ + int level, ret; + FILE *fp; + + fp = fopen(PERF_EVENT_PARANOID_PATH, "r"); + if (!fp) + return false; + + ret = fscanf(fp, "%d", &level); + fclose(fp); + if (ret != 1) + return false; + + /* On vanilla Linux the default perf_event_paranoid level is 2, which allows non-privileged + * processes to access performance counters. + * + * Debian / Ubuntu and their derivatives apply patches that introduce + * additional paranoia levels: + * + * - Debian adds level 3, which restricts access to perf_event_open() for + * monitoring other processes, but still allows unprivileged self-monitoring. + * See: https://lore.kernel.org/all/1469630746-32279-1-git-send-email-jeffv@google.com/ + * - Ubuntu adds level 4 (which is also the default), completely disabling perf_event_open() + * for unprivileged users—effectively disabling self-monitoring. + * + * That said, check below should be sufficient to enable this test on most kernels. + */ + return level < 4; +} + static int test_pmu_read(void) { @@ -24,8 +62,15 @@ test_pmu_read(void) return TEST_SKIPPED; } - if (rte_pmu_init() < 0) - return TEST_FAILED; + if ((getuid() != 0) && !perf_allowed_quirk()) { + printf("self-monitoring disabled\n"); + return TEST_SKIPPED; + } + + if (rte_pmu_init() < 0) { + printf("PMU not initialized\n"); + return TEST_SKIPPED; + } event = rte_pmu_add_event(name); while (tries--) @@ -33,7 +78,12 @@ test_pmu_read(void) rte_pmu_fini(); - return val ? TEST_SUCCESS : TEST_FAILED; + /* rte_pmu_read() returns zero if it can't read perf counter. Thus series of zeros doesn't + * necessarily mean the counter is actually zero. It might just signal a problem with setup + * itself. So skip test to avoid testing failure and leave it to user to interpret this + * outcome. + */ + return val ? TEST_SUCCESS : TEST_SKIPPED; } static struct unit_test_suite pmu_tests = { @@ -52,6 +102,4 @@ test_pmu(void) return unit_test_suite_runner(&pmu_tests); } -/* disabled because of reported failures, waiting for a fix - * REGISTER_FAST_TEST(pmu_autotest, true, true, test_pmu); - */ +REGISTER_FAST_TEST(pmu_autotest, true, true, test_pmu); From patchwork Fri Oct 24 05:48:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158068 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E8E0A489BE; Fri, 24 Oct 2025 07:49:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3E98940652; Fri, 24 Oct 2025 07:49:21 +0200 (CEST) Received: from mx0a-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 27CC24060F for ; Fri, 24 Oct 2025 07:49:19 +0200 (CEST) Received: from pps.filterd (m0431384.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3D0v7022946; Thu, 23 Oct 2025 22:49:16 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=C yndawOcdnYWCUhGjD0xm917VhdOsYpYkho5g0VIzmA=; b=gn4Zh8zz+TeyjTtZP d2tShL8Vga3BkeXStl4AmEiJHMZB+h0LwqGXEbrYg8kH7nXzQxH65zFpqJ9AHDVg /35yTJQ81utOXs0uSRvqcS+4oxf5SYAsM7jE/3ZWfv5kqYxfuAvyoRUYct6ryUGl k1shI3hOkt6doaOqWsmh6OmHBkhcPrraaBlQcf0ipgmi2KlIegkoeIA6mDLv1zZn iwYcxtIoZS9yqgxpsi2usf95Cet4RTfIOuIvHAxYgxtfj4774Aa1tiIwWP/e2QhN G4p+wPDQOjMFfFYnEXPN9C+Ku+BaMyDPa+pWwI5A6M0A7sJa8VU2hWdlv54i3E6H DmChg== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 49yx2j0jga-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:49:16 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.25; Thu, 23 Oct 2025 22:49:26 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.25 via Frontend Transport; Thu, 23 Oct 2025 22:49:26 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id C8A103F7071; Thu, 23 Oct 2025 22:49:10 -0700 (PDT) From: Tomasz Duszynski To: Thomas Monjalon , Jerin Jacob , Sunil Kumar Kori , Tyler Retzlaff , Tomasz Duszynski CC: , , , , , , , , , Subject: [PATCH v11 8/9] trace: add PMU Date: Fri, 24 Oct 2025 07:48:29 +0200 Message-ID: <20251024054830.933910-9-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNCBTYWx0ZWRfX7sxm8iCQnJXK O+gWIF4S256xoOHXidlbz8HD/J2rBdeT4A4ARwXU0hlNZTpLuAHaFlKLgCNjLjjf6e242py68E+ vzwQ7LJk4rOTPz2SnqTSSUDg8kil/Ty4doZ6dDNkZsilsVenmwJpRgtxoVOWSSWus0+OFXVopO/ nnOWO7uQYCLftq1nSnjWo73yM/6hrgHvpSezjb+UfAcp9iEOU2kR0AWBGC3H3zbSrgfffAQHzJo W3NJfij5cT9Y9D3CtfSCEEVyaBMcT2AFWWNfv96tb1rQzvv1n6YwKtipoum3G2d0cwr3I6rF2Te Scl9uIO8euQrHccOhtP6fJ9H/6Dl9ks6aOzShmY180Ip0Rkm8Z0EUXjpkJM2WkCUSmmYAEkVFfH 8YBIiBvo2gEFbP2pnD4WqicCMrTspw== X-Proofpoint-GUID: o03WgSn2K91Z8LOL5qEbAF7cfj7eZMg2 X-Proofpoint-ORIG-GUID: o03WgSn2K91Z8LOL5qEbAF7cfj7eZMg2 X-Authority-Analysis: v=2.4 cv=Rs7I7SmK c=1 sm=1 tr=0 ts=68fb135c cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=DnJVbuqOAAAA:8 a=M5GUcnROAAAA:8 a=U0nTHEwFv1Fjkjgwc9cA:9 a=Sz6ghim2xQgRqd81wKBx:22 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org In order to profile app, one needs to store significant amount of samples somewhere for an analysis later on. Since trace library supports storing data in a CTF format, lets take advantage of that and add a dedicated PMU tracepoint. Signed-off-by: Tomasz Duszynski --- MAINTAINERS | 1 + app/test/test_trace_perf.c | 10 ++++ doc/guides/prog_guide/profile_app.rst | 5 ++ doc/guides/prog_guide/trace_lib.rst | 31 ++++++++++ lib/eal/common/eal_common_trace.c | 6 +- lib/eal/common/eal_common_trace_pmu.c | 45 ++++++++++++++ lib/eal/common/eal_trace_pmu.h | 12 ++++ lib/eal/common/meson.build | 1 + lib/eal/include/rte_eal_trace.h | 23 +++++++ lib/eal/include/rte_trace_point.h | 7 +++ lib/eal/include/rte_trace_point_register.h | 2 + lib/eal/meson.build | 3 + lib/meson.build | 2 +- lib/pmu/pmu.c | 70 +++++++++++++++++++++- lib/pmu/rte_pmu.h | 24 ++++++++ 15 files changed, 238 insertions(+), 4 deletions(-) create mode 100644 lib/eal/common/eal_common_trace_pmu.c create mode 100644 lib/eal/common/eal_trace_pmu.h diff --git a/MAINTAINERS b/MAINTAINERS index 3b71ed8b46..956f586d1c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1869,6 +1869,7 @@ F: doc/guides/prog_guide/eventdev/dispatcher_lib.rst PMU - EXPERIMENTAL M: Tomasz Duszynski F: lib/pmu/ +F: lib/eal/common/eal_common_trace_pmu.c F: app/test/test_pmu.c Job statistics diff --git a/app/test/test_trace_perf.c b/app/test/test_trace_perf.c index 8257cc02be..28f908ce40 100644 --- a/app/test/test_trace_perf.c +++ b/app/test/test_trace_perf.c @@ -114,6 +114,10 @@ worker_fn_##func(void *arg) \ #define GENERIC_DOUBLE rte_eal_trace_generic_double(3.66666) #define GENERIC_STR rte_eal_trace_generic_str("hello world") #define VOID_FP app_dpdk_test_fp() +#ifdef RTE_LIB_PMU +/* 0 corresponds first event passed via --trace= */ +#define READ_PMU rte_pmu_trace_read(0) +#endif WORKER_DEFINE(GENERIC_VOID) WORKER_DEFINE(GENERIC_U64) @@ -122,6 +126,9 @@ WORKER_DEFINE(GENERIC_FLOAT) WORKER_DEFINE(GENERIC_DOUBLE) WORKER_DEFINE(GENERIC_STR) WORKER_DEFINE(VOID_FP) +#ifdef RTE_LIB_PMU +WORKER_DEFINE(READ_PMU) +#endif static void run_test(const char *str, lcore_function_t f, struct test_data *data, size_t sz) @@ -174,6 +181,9 @@ test_trace_perf(void) run_test("double", worker_fn_GENERIC_DOUBLE, data, sz); run_test("string", worker_fn_GENERIC_STR, data, sz); run_test("void_fp", worker_fn_VOID_FP, data, sz); +#ifdef RTE_LIB_PMU + run_test("read_pmu", worker_fn_READ_PMU, data, sz); +#endif rte_free(data); return TEST_SUCCESS; diff --git a/doc/guides/prog_guide/profile_app.rst b/doc/guides/prog_guide/profile_app.rst index 2f47680d5d..362fd20143 100644 --- a/doc/guides/prog_guide/profile_app.rst +++ b/doc/guides/prog_guide/profile_app.rst @@ -42,6 +42,11 @@ Current implementation imposes certain limitations: * EAL lcores must not share a CPU. * Each EAL lcore measures the same group of events. +Alternatively tracing library can be used, +which offers dedicated tracepoint ``rte_pmu_trace_read()``. + +Refer to :doc:`../prog_guide/trace_lib` for more details. + Profiling on x86 ---------------- diff --git a/doc/guides/prog_guide/trace_lib.rst b/doc/guides/prog_guide/trace_lib.rst index d9b17abe90..97158cce37 100644 --- a/doc/guides/prog_guide/trace_lib.rst +++ b/doc/guides/prog_guide/trace_lib.rst @@ -46,6 +46,7 @@ DPDK tracing library features trace format and is compatible with ``LTTng``. For detailed information, refer to `Common Trace Format `_. +- Support reading PMU events on ARM64 and x86-64 (Intel) How to add a tracepoint? ------------------------ @@ -139,6 +140,36 @@ the user must use ``RTE_TRACE_POINT_FP`` instead of ``RTE_TRACE_POINT``. ``RTE_TRACE_POINT_FP`` is compiled out by default and it can be enabled using the ``enable_trace_fp`` option for meson build. +PMU tracepoint +-------------- + +Performance Monitoring Unit (PMU) event values can be read from hardware registers +using the predefined ``rte_pmu_read`` tracepoint. + +Tracing is enabled via ``--trace`` EAL option by passing both expression +matching PMU tracepoint name i.e ``lib.eal.pmu.read`` +and expression ``e=ev1[,ev2,...]`` matching particular events:: + + --trace='.*pmu.read\|e=cpu_cycles,l1d_cache' + +Event names are available under ``/sys/bus/event_source/devices/PMU/events`` directory, +where ``PMU`` is a placeholder for either a ``cpu`` or a directory containing ``cpus``. + +In contrary to other tracepoints this does not need any extra variables +added to source files. +Instead, caller passes index +which follows the order of events specified via ``--trace`` parameter. +In the following example, index ``0`` corresponds to ``cpu_cyclces``, +while index ``1`` corresponds to ``l1d_cache``. + +.. code-block:: c + + rte_pmu_trace_read(0); + rte_pmu_trace_read(1); + +PMU tracing support must be explicitly enabled +using the ``enable_trace_fp`` option for Meson build. + Event record mode ----------------- diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c index be041c45bb..c05d812a6b 100644 --- a/lib/eal/common/eal_common_trace.c +++ b/lib/eal/common/eal_common_trace.c @@ -16,6 +16,7 @@ #include #include "eal_trace.h" +#include "eal_trace_pmu.h" RTE_EXPORT_EXPERIMENTAL_SYMBOL(per_lcore_trace_point_sz, 20.05) RTE_DEFINE_PER_LCORE(volatile int, trace_point_sz); @@ -75,8 +76,10 @@ eal_trace_init(void) goto free_meta; /* Apply global configurations */ - STAILQ_FOREACH(arg, &trace.args, next) + STAILQ_FOREACH(arg, &trace.args, next) { trace_args_apply(arg->val); + trace_pmu_args_apply(arg->val); + } rte_trace_mode_set(trace.mode); @@ -92,6 +95,7 @@ eal_trace_init(void) void eal_trace_fini(void) { + trace_pmu_args_free(); trace_mem_free(); trace_metadata_destroy(); eal_trace_args_free(); diff --git a/lib/eal/common/eal_common_trace_pmu.c b/lib/eal/common/eal_common_trace_pmu.c new file mode 100644 index 0000000000..534a2452af --- /dev/null +++ b/lib/eal/common/eal_common_trace_pmu.c @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2025 Marvell International Ltd. + */ + +#include + +#include "eal_trace_pmu.h" + +#ifdef RTE_LIB_PMU + +#include +#include +#include +#include + +void +trace_pmu_args_apply(const char *arg) +{ + static bool once; + + if (!once) { + if (rte_pmu_init()) + return; + once = true; + } + + rte_pmu_add_events_by_pattern(arg); +} + +void +trace_pmu_args_free(void) +{ + rte_pmu_fini(); +} + +RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_pmu_trace_read, 25.11) +RTE_TRACE_POINT_REGISTER(rte_pmu_trace_read, + lib.pmu.read) + +#else /* !RTE_LIB_PMU */ + +void trace_pmu_args_apply(const char *arg __rte_unused) { return; } +void trace_pmu_args_free(void) { return; } + +#endif /* RTE_LIB_PMU */ diff --git a/lib/eal/common/eal_trace_pmu.h b/lib/eal/common/eal_trace_pmu.h new file mode 100644 index 0000000000..27e890edea --- /dev/null +++ b/lib/eal/common/eal_trace_pmu.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2025 Marvell International Ltd. + */ + +#ifndef __EAL_TRACE_PMU_H +#define __EAL_TRACE_PMU_H + +/* PMU wrappers */ +void trace_pmu_args_apply(const char *arg); +void trace_pmu_args_free(void); + +#endif /* __EAL_TRACE_PMU_H */ diff --git a/lib/eal/common/meson.build b/lib/eal/common/meson.build index e273745e93..463c8f74db 100644 --- a/lib/eal/common/meson.build +++ b/lib/eal/common/meson.build @@ -48,6 +48,7 @@ if not is_windows 'eal_common_hypervisor.c', 'eal_common_proc.c', 'eal_common_trace.c', + 'eal_common_trace_pmu.c', 'eal_common_trace_ctf.c', 'eal_common_trace_utils.c', 'hotplug_mp.c', diff --git a/lib/eal/include/rte_eal_trace.h b/lib/eal/include/rte_eal_trace.h index 9ad2112801..e7294b47f6 100644 --- a/lib/eal/include/rte_eal_trace.h +++ b/lib/eal/include/rte_eal_trace.h @@ -127,6 +127,29 @@ RTE_TRACE_POINT( #define RTE_EAL_TRACE_GENERIC_FUNC rte_eal_trace_generic_func(__func__) +#ifdef RTE_LIB_PMU +#include +#include +RTE_TRACE_POINT_FP( + rte_pmu_trace_read, + RTE_TRACE_POINT_ARGS(unsigned int index), + /* Embedded code should only execute in runtime so cut it out during registration in order + * to avoid compilation issues because rte_pmu_trace_read_register(void) does not provide + * any context. + */ + RTE_TRACE_POINT_EMBED_CODE( + uint64_t val; +#ifdef ALLOW_EXPERIMENTAL_API + val = rte_pmu_read(index); +#else + RTE_SET_USED(index); + RTE_VERIFY(false); +#endif + ) + rte_trace_point_emit_u64(val); +) +#endif + #ifdef __cplusplus } #endif diff --git a/lib/eal/include/rte_trace_point.h b/lib/eal/include/rte_trace_point.h index 394b2619c5..6d6ec8e46d 100644 --- a/lib/eal/include/rte_trace_point.h +++ b/lib/eal/include/rte_trace_point.h @@ -46,6 +46,13 @@ typedef RTE_ATOMIC(uint64_t) rte_trace_point_t; */ #define RTE_TRACE_POINT_ARGS +/** + * Macro to define the tracepoint code in RTE_TRACE_POINT, RTE_TRACE_POINT_FP macros. + + * @see RTE_TRACE_POINT, RTE_TRACE_POINT_FP + */ +#define RTE_TRACE_POINT_EMBED_CODE(...) __VA_ARGS__ + /** @internal Helper macro to support RTE_TRACE_POINT and RTE_TRACE_POINT_FP */ #define __RTE_TRACE_POINT(_mode, _tp, _args, ...) \ extern rte_trace_point_t __##_tp; \ diff --git a/lib/eal/include/rte_trace_point_register.h b/lib/eal/include/rte_trace_point_register.h index b036121959..81c28cdb5b 100644 --- a/lib/eal/include/rte_trace_point_register.h +++ b/lib/eal/include/rte_trace_point_register.h @@ -45,6 +45,8 @@ RTE_DECLARE_PER_LCORE(volatile int, trace_point_sz); #define RTE_TRACE_POINT_ARGS(...) \ (RTE_TRACE_POINT_ARGS_(RTE_TRACE_POINT_ARGS_COUNT(0, __VA_ARGS__), __VA_ARGS__)) +#define RTE_TRACE_POINT_EMBED_CODE(...) + #define __RTE_TRACE_POINT(_mode, _tp, _args, ...) \ extern rte_trace_point_t __##_tp; \ static __rte_always_inline void _tp _args { } \ diff --git a/lib/eal/meson.build b/lib/eal/meson.build index f9fcee24ee..95aa66c791 100644 --- a/lib/eal/meson.build +++ b/lib/eal/meson.build @@ -15,6 +15,9 @@ subdir(exec_env) subdir(arch_subdir) deps += ['argparse', 'kvargs'] +if is_linux and dpdk_conf.has('RTE_LIB_PMU') + deps += ['pmu'] +endif if not is_windows deps += ['telemetry'] endif diff --git a/lib/meson.build b/lib/meson.build index c8f4270868..2f7deef4e1 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -13,7 +13,7 @@ libraries = [ 'kvargs', # eal depends on kvargs 'argparse', 'telemetry', # basic info querying - 'pmu', + 'pmu', # trace depends on pmu 'eal', # everything depends on eal 'ptr_compress', 'ring', diff --git a/lib/pmu/pmu.c b/lib/pmu/pmu.c index e4d4f146d1..4bce48c359 100644 --- a/lib/pmu/pmu.c +++ b/lib/pmu/pmu.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -371,6 +372,7 @@ static void free_event(struct rte_pmu_event *event) { free(event->name); + event->name = NULL; free(event); } @@ -417,13 +419,77 @@ rte_pmu_add_event(const char *name) return event->index; } +static int +add_events(const char *pattern) +{ + char *token, *copy, *tmp; + int ret = 0; + + copy = strdup(pattern); + if (copy == NULL) + return -ENOMEM; + + token = strtok_r(copy, ",", &tmp); + while (token) { + ret = rte_pmu_add_event(token); + if (ret < 0) + break; + + token = strtok_r(NULL, ",", &tmp); + } + + free(copy); + + return ret >= 0 ? 0 : ret; +} + +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmu_add_events_by_pattern, 25.11) +int +rte_pmu_add_events_by_pattern(const char *pattern) +{ + regmatch_t rmatch; + char buf[BUFSIZ]; + unsigned int num; + regex_t reg; + int ret; + + /* events are matched against occurrences of e=ev1[,ev2,..] pattern */ + ret = regcomp(®, "e=([_[:alnum:]-],?)+", REG_EXTENDED); + if (ret) { + PMU_LOG(ERR, "Failed to compile event matching regexp"); + return -EINVAL; + } + + for (;;) { + if (regexec(®, pattern, 1, &rmatch, 0)) + break; + + num = rmatch.rm_eo - rmatch.rm_so; + if (num > sizeof(buf)) + num = sizeof(buf); + + /* skip e= pattern prefix */ + memcpy(buf, pattern + rmatch.rm_so + 2, num - 2); + buf[num - 2] = '\0'; + ret = add_events(buf); + if (ret) + break; + + pattern += rmatch.rm_eo; + } + + regfree(®); + + return ret; +} + RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_pmu_init, 25.07) int rte_pmu_init(void) { int ret; - if (rte_pmu.initialized) + if (rte_pmu.initialized && ++rte_pmu.initialized) return 0; ret = scan_pmus(); @@ -457,7 +523,7 @@ rte_pmu_fini(void) struct rte_pmu_event_group *group; unsigned int i; - if (!rte_pmu.initialized) + if (!rte_pmu.initialized || --rte_pmu.initialized) return; RTE_TAILQ_FOREACH_SAFE(event, &rte_pmu.event_list, next, tmp_event) { diff --git a/lib/pmu/rte_pmu.h b/lib/pmu/rte_pmu.h index 2e3678d966..9970282c76 100644 --- a/lib/pmu/rte_pmu.h +++ b/lib/pmu/rte_pmu.h @@ -21,6 +21,10 @@ * * rte_pmu_init() * rte_pmu_add_event() + * rte_pmu_add_event() [or rte_pmu_add_events_by_pattern()] + * + * Note that if -Denable_trace_fp=True was passed to Meson, + * rte_pmu_init() gets called automatically. * * Afterwards all threads can read events by calling rte_pmu_read(). */ @@ -146,6 +150,8 @@ __rte_pmu_enable_group(struct rte_pmu_event_group *group); * * Initialize PMU library. * + * It's safe to call it multiple times. + * * @return * 0 in case of success, negative value otherwise. */ @@ -158,6 +164,9 @@ rte_pmu_init(void); * @b EXPERIMENTAL: this API may change without prior notice. * * Finalize PMU library. + * + * Number of calls must match number of times rte_pmu_init() was called. + * Otherwise memory won't be freed properly. */ __rte_experimental void @@ -179,6 +188,21 @@ __rte_experimental int rte_pmu_add_event(const char *name); +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Add events matching pattern to the group of enabled events. + * + * @param pattern + * Pattern e=ev1[,ev2,...] matching events + * listed under /sys/bus/event_source/devices/pmu/events, + * where evX and PMU are placeholders for respectively an event and an event source. + */ +__rte_experimental +int +rte_pmu_add_events_by_pattern(const char *pattern); + /** * @warning * @b EXPERIMENTAL: this API may change without prior notice. From patchwork Fri Oct 24 05:48:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 158069 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 69F7B489BE; Fri, 24 Oct 2025 07:49:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 539F240661; Fri, 24 Oct 2025 07:49:26 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 1151B4065A for ; Fri, 24 Oct 2025 07:49:23 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 59O3Cr48027234; Thu, 23 Oct 2025 22:49:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=m fwEi04863q4LgF63EjjDOs8IMAGRT2SZazX/BK0GsQ=; b=EG7K7ZG8Mh7QVnVTa nxiamO3ZtQRBRztIAF7bdtaWTBZjomjpqPWKpch5Xelv6hSq2WZeIuaZVjs9mRnV nmcN6D96wR6W8zpNOMdSNUqcBEykS92ar8SmIziBdaCXaKPgdfoQx66ukoxbyeei thmhSrlOmo6UZjQDeK67DHEEMyec5nBqZ97nSGaT1sOb+vNlFjCW/T3j10k+GoDP 54gwiXo/RZ2+ggtHyHP3C7hIMhaaZ5o5r680TRuc4vk9syyMe/w9L+B/nosh5PiH VGzM7yahQkwSC41M8vOBP5OPS4tYi8rL0uk8VA1X7nVCv27ZkvyBkQLTl2WPQR08 n+40A== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 49yx9prh90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 23 Oct 2025 22:49:21 -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.25; Thu, 23 Oct 2025 22:49:18 -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.25 via Frontend Transport; Thu, 23 Oct 2025 22:49:18 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 444BF3F70E0; Thu, 23 Oct 2025 22:49:16 -0700 (PDT) From: Tomasz Duszynski To: Tomasz Duszynski , Wathsala Vithanage CC: , , , , , , , , , , , Subject: [PATCH v11 9/9] lib/pmu: fix out-of-bound access Date: Fri, 24 Oct 2025 07:48:30 +0200 Message-ID: <20251024054830.933910-10-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20251024054830.933910-1-tduszynski@marvell.com> References: <20250801102109.3544901-1-tduszynski@marvell.com> <20251024054830.933910-1-tduszynski@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: rTBX0QU-rS6ZlZLJhXYesAtAKcFGzRgD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMDIzMDIxNyBTYWx0ZWRfX2N+WcbOZwnTv Su3FfYksG0JJvqpY+as84WQOOZ8xPNMFEf5wyz4YLh0WDj/0XFT7oJewnucxjChE62X5jzG0DCH PCWTSRViXJxOqJqm2u5tk7ieuTKVQBdg1yoRbQpLGf0ZzaEKo6Wk83oj5AomsooPeqFxNqkLqh8 PDj3h9hlOHSUQ8oh/m7nMs/BM/yMkfLtTzdKRjQssN1PnsaGZxzksKR9HjLqps3xfU7pxQ5EEht VtnXxLvTtjXgpuyk2Ed6mMZ568isNtKtdz0sd6K1kcRvo7MhcitvGwFbgtpLEAT4eQKzG3gFxTc E2YwaEWS2uh0JQncrUS8Wbrxw/oMMPvKO2Zi5hykAJkHk+fBKVFq2HiclDMVQ3+AjASId9T68wL TeNjquZblm76bYrYxkxIgxfZahJ7aw== X-Proofpoint-GUID: rTBX0QU-rS6ZlZLJhXYesAtAKcFGzRgD X-Authority-Analysis: v=2.4 cv=Wvom8Nfv c=1 sm=1 tr=0 ts=68fb1361 cx=c_pps a=gIfcoYsirJbf48DBMSPrZA==:117 a=gIfcoYsirJbf48DBMSPrZA==:17 a=x6icFKpwvdMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=M5GUcnROAAAA:8 a=rsDlWQ7q-kAZFu0dnB0A:9 a=OBjm3rFKGHvpk9ecZwUJ:22 a=cPQSjfK2_nFv0Q5t_7PE:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-10-23_03,2025-10-22_01,2025-03-28_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Make sure that out-of-bound access does not happen by saving one byte in buffer for NUL terminator. Fixes: a8926a65ad1d ("pmu: support Arm") Fixes: 960c43184c4d ("pmu: introduce library for reading PMU events") Cc: tduszynski@marvell.com Signed-off-by: Tomasz Duszynski --- lib/pmu/pmu.c | 2 +- lib/pmu/pmu_arm64.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pmu/pmu.c b/lib/pmu/pmu.c index 4bce48c359..c14128addd 100644 --- a/lib/pmu/pmu.c +++ b/lib/pmu/pmu.c @@ -126,7 +126,7 @@ get_event_config(const char *name, uint64_t config[3]) if (fp == NULL) return -errno; - ret = fread(buf, 1, sizeof(buf), fp); + ret = fread(buf, 1, sizeof(buf) - 1, fp); if (ret == 0) { fclose(fp); diff --git a/lib/pmu/pmu_arm64.c b/lib/pmu/pmu_arm64.c index 2c40b5f702..f3a817b42f 100644 --- a/lib/pmu/pmu_arm64.c +++ b/lib/pmu/pmu_arm64.c @@ -24,12 +24,13 @@ read_attr_int(const char *path, int *val) if (fd == -1) return -errno; - ret = read(fd, buf, sizeof(buf)); + ret = read(fd, buf, sizeof(buf) - 1); if (ret == -1) { close(fd); return -errno; } + buf[ret] = '\0'; *val = strtol(buf, NULL, 10); close(fd);