> -----Original Message----- > From: Tomasz Duszynski <tduszyn...@marvell.com> > Sent: Monday, February 13, 2023 7:32 PM > To: dev@dpdk.org; tho...@monjalon.net; Tomasz Duszynski > <tduszyn...@marvell.com> > Cc: roret...@linux.microsoft.com; Ruifeng Wang <ruifeng.w...@arm.com>; > bruce.richard...@intel.com; jer...@marvell.com; mattias.ronnb...@ericsson.com; > m...@smartsharesystems.com; zhou...@loongson.cn; david.march...@redhat.com > Subject: [PATCH v10 1/4] lib: add generic support for reading PMU events > > Add support for programming PMU counters and reading their values in runtime > bypassing > kernel completely. > > This is especially useful in cases where CPU cores are isolated i.e run > dedicated tasks. > In such cases one cannot use standard perf utility without sacrificing > latency and > performance. > > Signed-off-by: Tomasz Duszynski <tduszyn...@marvell.com> > Acked-by: Morten Brørup <m...@smartsharesystems.com> > --- > MAINTAINERS | 5 + > app/test/meson.build | 2 + > app/test/test_pmu.c | 62 ++++ > doc/api/doxy-api-index.md | 3 +- > doc/api/doxy-api.conf.in | 1 + > doc/guides/prog_guide/profile_app.rst | 12 + > doc/guides/rel_notes/release_23_03.rst | 7 + > lib/meson.build | 1 + > lib/pmu/meson.build | 13 + > lib/pmu/pmu_private.h | 32 ++ > lib/pmu/rte_pmu.c | 460 +++++++++++++++++++++++++ > lib/pmu/rte_pmu.h | 212 ++++++++++++ > lib/pmu/version.map | 15 + > 13 files changed, 824 insertions(+), 1 deletion(-) create mode 100644 > app/test/test_pmu.c create mode 100644 lib/pmu/meson.build create mode > 100644 > lib/pmu/pmu_private.h create mode 100644 lib/pmu/rte_pmu.c create mode > 100644 > lib/pmu/rte_pmu.h create mode 100644 lib/pmu/version.map > > diff --git a/MAINTAINERS b/MAINTAINERS > index 3495946d0f..d37f242120 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -1697,6 +1697,11 @@ M: Nithin Dabilpuram <ndabilpu...@marvell.com> > M: Pavan Nikhilesh <pbhagavat...@marvell.com> > F: lib/node/ > > +PMU - EXPERIMENTAL > +M: Tomasz Duszynski <tduszyn...@marvell.com> > +F: lib/pmu/ > +F: app/test/test_pmu* > + > > Test Applications > ----------------- > diff --git a/app/test/meson.build b/app/test/meson.build index > f34d19e3c3..6b61b7fc32 > 100644 > --- a/app/test/meson.build > +++ b/app/test/meson.build > @@ -111,6 +111,7 @@ test_sources = files( > 'test_reciprocal_division_perf.c', > 'test_red.c', > 'test_pie.c', > + 'test_pmu.c', > 'test_reorder.c', > 'test_rib.c', > 'test_rib6.c', > @@ -239,6 +240,7 @@ fast_tests = [ > ['kni_autotest', false, true], > ['kvargs_autotest', true, true], > ['member_autotest', true, true], > + ['pmu_autotest', true, true], > ['power_cpufreq_autotest', false, true], > ['power_autotest', true, true], > ['power_kvm_vm_autotest', false, true], diff --git > a/app/test/test_pmu.c > b/app/test/test_pmu.c new file mode 100644 index 0000000000..a64564b5f5 > --- /dev/null > +++ b/app/test/test_pmu.c > @@ -0,0 +1,62 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(C) 2023 Marvell International Ltd. > + */ > + > +#include "test.h" > + > +#ifndef RTE_EXEC_ENV_LINUX > + > +static int > +test_pmu(void) > +{ > + printf("pmu_autotest only supported on Linux, skipping test\n"); > + return TEST_SKIPPED; > +} > + > +#else > + > +#include <rte_pmu.h> > + > +static int > +test_pmu_read(void) > +{ > + const char *name = NULL; > + int tries = 10, event; > + uint64_t val = 0; > + > + if (name == NULL) { > + printf("PMU not supported on this arch\n"); > + return TEST_SKIPPED; > + } > + > + if (rte_pmu_init() < 0) > + return TEST_FAILED;
Can we return TEST_SKIPPED here? On aarch64, this feature requires kernel version >= 5.17. CI setups doesn't meet this requirement will start to report failure when running fast_tests. > + > + event = rte_pmu_add_event(name); > + while (tries--) > + val += rte_pmu_read(event); > + > + rte_pmu_fini(); > + > + return val ? TEST_SUCCESS : TEST_FAILED; } > + > +static struct unit_test_suite pmu_tests = { > + .suite_name = "pmu autotest", > + .setup = NULL, > + .teardown = NULL, > + .unit_test_cases = { > + TEST_CASE(test_pmu_read), > + TEST_CASES_END() > + } > +}; > + <snip>