DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tduszynski@marvell.com>
To: <tduszynski@marvell.com>
Cc: <bruce.richardson@intel.com>, <dev@dpdk.org>,
	<jerinj@marvell.com>, <mb@smartsharesystems.com>,
	<thomas@monjalon.net>, <david.marchand@redhat.com>
Subject: [PATCH v3 5/7] test/pmu: enable fast test
Date: Fri, 20 Jun 2025 14:05:49 +0200	[thread overview]
Message-ID: <20250620120551.613148-6-tduszynski@marvell.com> (raw)
In-Reply-To: <20250620120551.613148-1-tduszynski@marvell.com>

DPDK test suite provides much broader architecture coverage than
what can be tested locally so enable the test to help identify
potential issues.

Signed-off-by: Tomasz Duszynski <tduszynski@marvell.com>
---
 app/test/test_pmu.c | 44 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/app/test/test_pmu.c b/app/test/test_pmu.c
index 10513bf9c9..dd23046f59 100644
--- a/app/test/test_pmu.c
+++ b/app/test/test_pmu.c
@@ -2,10 +2,47 @@
  * Copyright(C) 2025 Marvell International Ltd.
  */
 
+#include <stdbool.h>
+#include <stdio.h>
+#include <unistd.h>
+
 #include <rte_pmu.h>
 
 #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,6 +61,9 @@ test_pmu_read(void)
 		return TEST_SKIPPED;
 	}
 
+	if (!perf_allowed_quirk())
+		return TEST_SKIPPED;
+
 	if (rte_pmu_init() < 0)
 		return TEST_FAILED;
 
@@ -52,6 +92,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);
-- 
2.34.1


  parent reply	other threads:[~2025-06-20 12:06 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16  6:53 [PATCH 0/6] lib/pmu: cleanups and trace integration Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 1/6] lib/pmu: quiesce rte_pmu_read deprecation warning in chkincs Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 2/6] lib/pmu: export only necessary arch headers Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 3/6] lib/pmu: reimplement per-arch ops as callbacks Tomasz Duszynski
2025-06-16  7:03   ` Thomas Monjalon
2025-06-16  9:54     ` Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 4/6] lib/pmu: use build system defined RTE_LIB_PMU macro Tomasz Duszynski
2025-06-16  7:08   ` Thomas Monjalon
2025-06-16 10:53     ` Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 5/6] test/pmu: enable fast test Tomasz Duszynski
2025-06-16  6:53 ` [PATCH 6/6] trace: add PMU Tomasz Duszynski
2025-06-16  7:13   ` Thomas Monjalon
2025-06-16  9:49     ` Tomasz Duszynski
2025-06-16 10:32       ` Bruce Richardson
2025-06-16 13:18       ` Morten Brørup
2025-06-18  6:56 ` [PATCH v2 0/6] lib/pmu: cleanups and trace integration Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 1/6] lib/pmu: quiesce rte_pmu_read deprecation warning in chkincs Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 2/6] lib/pmu: export only necessary arch headers Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 3/6] lib/pmu: reimplement per-arch ops as callbacks Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 4/6] lib/pmu: use build system defined RTE_LIB_PMU macro Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 5/6] test/pmu: enable fast test Tomasz Duszynski
2025-06-18  6:56   ` [PATCH v2 6/6] trace: add PMU Tomasz Duszynski
2025-06-18  7:16     ` Morten Brørup
2025-06-18  9:47       ` Thomas Monjalon
2025-06-18 10:28         ` Bruce Richardson
2025-06-18 11:30           ` Morten Brørup
2025-06-18 10:23       ` Tomasz Duszynski
2025-06-18 10:37         ` Morten Brørup
2025-06-20 12:05   ` [PATCH v3 0/7] lib/pmu: cleanups and trace integration Tomasz Duszynski
2025-06-20 12:05     ` [PATCH v3 1/7] lib/pmu: quiesce rte_pmu_read deprecation warning in chkincs Tomasz Duszynski
2025-06-20 12:05     ` [PATCH v3 2/7] lib/pmu: export only necessary arch headers Tomasz Duszynski
2025-06-20 12:05     ` [PATCH v3 3/7] lib/pmu: reimplement per-arch ops as callbacks Tomasz Duszynski
2025-06-20 12:05     ` [PATCH v3 4/7] lib/pmu: use build system defined RTE_LIB_PMU macro Tomasz Duszynski
2025-06-20 12:05     ` Tomasz Duszynski [this message]
2025-06-20 12:05     ` [PATCH v3 6/7] trace: add PMU Tomasz Duszynski
2025-06-20 12:05     ` [PATCH v3 7/7] lib/pmu: fix out-of-bound access Tomasz Duszynski

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=20250620120551.613148-6-tduszynski@marvell.com \
    --to=tduszynski@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=mb@smartsharesystems.com \
    --cc=thomas@monjalon.net \
    /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).