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 <tduszyn...@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-je...@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

Reply via email to