From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D706546BE5; Tue, 22 Jul 2025 14:01:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 714A740665; Tue, 22 Jul 2025 14:01:02 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 585374066E for ; Tue, 22 Jul 2025 14:01:00 +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 56M72623010873; Tue, 22 Jul 2025 05:00:59 -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 BZumREjB4faLj9tdL2gzX47x6SBDNuN30mUT2QKibU=; b=epCWYwNJNq+QaWMUA 64v5UyObP8glTcJ5/bl44fHeaqxJRUCJ21pMIK2YFlNKHgfGAEfUTLJv/ILYiph7 esr/RW5ceKPb/6PHb2B9PTXfJd5WNqLhkSEiR9uJfEpdaUqMoXbEMTlIqfR3JOCp pIV8XEHBVBbf1zGUBMZoWa39/QO+xZ0wEGYO4V9wWKzOK9nBDyF0Zob/I8HBctgJ AE4LZBs2rBmUUxFXx6w91AlnwVfI7XQN3cKmqUhOGNfZbY0+PgFkXJ7OhjI7SVxM a4jwFhmOvrH4XHEKJMtKIwxJLxdAAzYjOBi62WYQJHmpDvc6h1Olrmm+wDQtBRh9 Go7UQ== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 481y91sbdn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Jul 2025 05:00:59 -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.4; Tue, 22 Jul 2025 05:00:58 -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.4 via Frontend Transport; Tue, 22 Jul 2025 05:00:58 -0700 Received: from cavium-optiplex-3070-BM15.. (unknown [10.28.34.39]) by maili.marvell.com (Postfix) with ESMTP id 9EE2D3F706C; Tue, 22 Jul 2025 05:00:55 -0700 (PDT) From: Tomasz Duszynski To: CC: , , , , , Subject: [PATCH v8 4/8] lib/pmu: do not try enabling perf counter access on arm64 Date: Tue, 22 Jul 2025 14:00:37 +0200 Message-ID: <20250722120041.2718227-5-tduszynski@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250722120041.2718227-1-tduszynski@marvell.com> References: <20250627154107.3405768-1-tduszynski@marvell.com> <20250722120041.2718227-1-tduszynski@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwNzIyMDA5OCBTYWx0ZWRfX3s6v/b5l7oo3 V+fzm656Finkw2ri49Kazyt/j2tdofUjHxZzOkNm2bmx3iyOs5lm8PpRhwmBe27378Sn1pcefWT lsiLGrjoRpQj6C3ChshlOIxUS30JOZULhdL5xKD6G2QHJx4ckw9+vEh9e2CfBNz/nGUnda7Dkgj 2obHS4COxMWI+D164vNImvh2sGDyRTyhYD5ZEZHo95QVLfPQhbC43MuHwvkM3I6zrmWElOT2zom 6XLUqLTrqkbMXhvy7F4nWp/Wht0i9b9OVdsmRPC35j+vpt8/dnwbmI6bsFGw/RHf3v3ocN+Z8xD QPjhXD1b9RtBp0Qz9cE6QLXqJmhdy/wO1OTg0KbsJwsHfbrNnhA1VSr7Z4S4kfjhuADvQ4FAvd9 OFCdtHgIhCuxAgZLhAPeyjhpZh0/0OLTZdS/XVCf23r8v5wgumEVCMedp41p3N8oeN/cPY4M X-Proofpoint-ORIG-GUID: jwMwCrDJR-iZZBzXLeKqg9qP3Tt61gQE X-Proofpoint-GUID: jwMwCrDJR-iZZBzXLeKqg9qP3Tt61gQE X-Authority-Analysis: v=2.4 cv=RfGQC0tv c=1 sm=1 tr=0 ts=687f7d7b cx=c_pps a=rEv8fa4AjpPjGxpoe8rlIQ==:117 a=rEv8fa4AjpPjGxpoe8rlIQ==:17 a=Wb1JkmetP80A:10 a=M5GUcnROAAAA:8 a=Oq_oc4OIQJrBT0az780A:9 a=OBjm3rFKGHvpk9ecZwUJ:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-07-22_02,2025-07-21_02,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 0709f5e58c..3cae29891c 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. */ -- 2.34.1