add support for self monitoring
Subsystems (2)
RE: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs files
In reply to Tyler RetzlaffQuoted 15 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Wednesday, January 25, 2023 5:16 PM
To: Thomas Monjalon <[email protected]>
Cc: Tomasz Duszynski <[email protected]>; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs filesExternal Email
----------------------------------------------------------------------
Quoted 1 line · Thomas Monjalon
25/01/2023 11:33, Tomasz Duszynski:
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Reading strings from sysfs files is a re-occurring pattern hence add helper for doing that.
In general it would be to nice to clean sysfs parsing in libs and drivers, so they all use some functions from EAL.
maybe there should be a general utility library for dealing with sysfs separate from the core EAL that drivers / platform specific libs can share?
reading/writing of sysfs files is scattered around the codebase and this has been piling up with each and and every new pmd/lib that requires it. So generally a few simple utility functions in one place may be a good idea.
Would following make sense?
rte_sysfs_write_int()rte_sysfs_write_string()rte_sysfs_read_int()rte_sysfs_read_string()
Also seems that pattern where file gets opened once and keeps being written to until closed is reoccurring as well. So there might be some utils for that as well. Thoughts?
Re: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs files
Quoted 21 lines · Tomasz Duszynski
Quoted 21 lines
-----Original Message-----
From: Tyler Retzlaff <[email protected]>
Sent: Wednesday, January 25, 2023 5:16 PM
To: Thomas Monjalon <[email protected]>
Cc: Tomasz Duszynski <[email protected]>; [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs filesExternal Email
----------------------------------------------------------------------
Quoted 6 lines · Thomas Monjalon
25/01/2023 11:33, Tomasz Duszynski:
Quoted 2 lines
Reading strings from sysfs files is a re-occurring pattern hence add helper for doing that.
In general it would be to nice to clean sysfs parsing in libs and drivers, so they all use some functions from EAL.
Quoted 6 lines
Quoted 2 lines
maybe there should be a general utility library for dealing with sysfs separate from the core EAL that drivers / platform specific libs can share?
reading/writing of sysfs files is scattered around the codebase and this has been piling up with each and and every new pmd/lib that requires it. So generally a few simple utility functions in one place may be a good idea.
i'm an advocate of smaller libraries that tackle a subject area and do so well. even better if they can be unit tested without dragging in a lot of dependencies or bootstrapping other unrelated subsystems.
it is also in alignment with trying to de-bloat eal which i think there is increasing interest in.
Quoted 10 lines
Would following make sense?
rte_sysfs_write_int()rte_sysfs_write_string()rte_sysfs_read_int()rte_sysfs_read_string()Also seems that pattern where file gets opened once and keeps being written to until closed is reoccurring as well. So there might be some utils for that as well. Thoughts?
i guess the answer here is whatever makes a simple intuitive api for sysfs access, i don't contribute much on the linux side to dpdk so can't speak to what makes a good api here, but i imagine others can in review.
thanks
RE: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs files
In reply to Thomas MonjalonQuoted 12 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, January 25, 2023 11:40 AM
To: Tomasz Duszynski <[email protected]>
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH 1/2] lib: add helper to read strings from sysfs filesExternal Email
Quoted 8 lines
----------------------------------------------------------------------
25/01/2023 11:33, Tomasz Duszynski:Quoted 2 lines
Reading strings from sysfs files is a re-occurring pattern hence add helper for doing that.
In general it would be to nice to clean sysfs parsing in libs and drivers, so they all use some functions from EAL.
That's generally true. Here I wanted to avoid tree-wide changes caused by unrelated work i.e a new bus and do a cleanup, i.e use this read string util where applicable, later on.
PATCH 2/2 bus: add platform bus
In reply to Tomasz DuszynskiPlatform bus is a software bus under Linux that manages devices which generally do not have built-in discovery mechanisms. Linux normally learns about platform devices directly from device-tree during boot-up phase.
Up to this point, whenever some userspace app needed control over platform device or a range of thereof some sort of driver being a mixture of vdev/rawdev was required.
In order to simplify this task, provide an auto-probe experience and separate bus logic from the driver itself, add platform bus support.
Currently devices backed up by vfio-platform kernel driver are supported.
--- MAINTAINERS | 4 + doc/guides/rel_notes/release_23_03.rst | 5 + drivers/bus/meson.build | 1 + drivers/bus/platform/bus_platform_driver.h | 174 ++++++ drivers/bus/platform/meson.build | 16 + drivers/bus/platform/platform.c | 604 +++++++++++++++++++++ drivers/bus/platform/platform_params.c | 70 +++ drivers/bus/platform/private.h | 48 ++ drivers/bus/platform/version.map | 10 + 9 files changed, 932 insertions(+) create mode 100644 drivers/bus/platform/bus_platform_driver.h create mode 100644 drivers/bus/platform/meson.build create mode 100644 drivers/bus/platform/platform.c create mode 100644 drivers/bus/platform/platform_params.c create mode 100644 drivers/bus/platform/private.h create mode 100644 drivers/bus/platform/version.map
MAINTAINERS +4 -0
@@ -581,6 +581,10 @@ VDEV bus driver F: drivers/bus/vdev/ F: app/test/test_vdev.c +Platform bus driver +M: Tomasz Duszynski <[email protected]> +F: drivers/bus/platform + VMBUS bus driver M: Long Li <[email protected]> F: drivers/bus/vmbus/
doc/guides/rel_notes/release_23_03.rst +5 -0
@@ -57,6 +57,11 @@ New Features * **Added multi-process support for axgbe PMD.** +* **Added platform bus support.** + + A platform bus provides a way to use Linux platform devices which + are compatible with vfio-platform kernel driver. + * **Updated Corigine nfp driver.** * Added support for meter options.
drivers/bus/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'fslmc', 'ifpga', 'pci', + 'platform', 'vdev', 'vmbus', ]
drivers/bus/platform/bus_platform_driver.h new file +174 -0
174 lines not on this page · raw message
drivers/bus/platform/meson.build new file +16 -0
@@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(C) 2023 Marvell. +# + +if not is_linux + build = false + reason = 'only supported on Linux' + subdir_done() +endif + +deps += ['kvargs'] +sources = files( + 'platform_params.c', + 'platform.c', +) +driver_sdk_headers += files('bus_platform_driver.h')
drivers/bus/platform/platform.c new file +604 -0
604 lines not on this page · raw message
drivers/bus/platform/platform_params.c new file +70 -0
70 lines not on this page · raw message
drivers/bus/platform/private.h new file +48 -0
48 lines not on this page · raw message
drivers/bus/platform/version.map new file +10 -0
@@ -0,0 +1,10 @@ +DPDK_23 { + local: *; +}; + +INTERNAL { + global: + + rte_platform_register; + rte_platform_unregister; +};
Signature · 1 line
2.34.1
RE: [PATCH 0/2] add platform bus
In reply to Tomasz DuszynskiThis was mistakenly appended to this thread - ignore it. I've just sent the series again.
Quoted 46 lines
-----Original Message-----
From: Tomasz Duszynski <[email protected]>
Sent: Wednesday, January 25, 2023 11:33 AM
To: [email protected]
Cc: [email protected]; Jerin Jacob Kollanukkaran <[email protected]>; [email protected]; [email protected]; Tomasz Duszynski <[email protected]>
Subject: [PATCH 0/2] add platform busPlatform bus is a bus under Linux which manages devices that do not have any discovery-mechanism built in. Linux learns about platform devices directly from device-tree during boot-up phase.
Afterwards if userspace wants to use some particular device driver being usually a mixture of vdev/rawdev gets developed.
In order to simplify that introduce a DPDK platform bus which provides auto-probe experience and separates a bus logic from the driver itself.
Now only devices which are backed-by vfio-platform kernel driver are supported, though other options may be added if necessary.
Tomasz Duszynski (2):
lib: add helper to read strings from sysfs files
bus: add platform busMAINTAINERS | 4 + app/test/test_eal_fs.c | 108 +++- doc/guides/rel_notes/release_23_03.rst | 5 + drivers/bus/meson.build | 1 + drivers/bus/platform/bus_platform_driver.h | 174 ++++++ drivers/bus/platform/meson.build | 16 + drivers/bus/platform/platform.c | 604 +++++++++++++++++++++ drivers/bus/platform/platform_params.c | 70 +++ drivers/bus/platform/private.h | 48 ++ drivers/bus/platform/version.map | 10 + lib/eal/common/eal_filesystem.h | 6 + lib/eal/unix/eal_filesystem.c | 24 +- lib/eal/version.map | 1 + 13 files changed, 1053 insertions(+), 18 deletions(-) create mode 100644
drivers/bus/platform/bus_platform_driver.h
create mode 100644drivers/bus/platform/meson.buildcreate mode 100644drivers/bus/platform/platform.ccreate mode 100644drivers/bus/platform/platform_params.ccreate mode 100644drivers/bus/platform/private.hcreate mode 100644drivers/bus/platform/version.map--
2.34.1
PMU is kind of MSR. Precisely , that's MSR per core.
All MSR reading will lead to IPI(Please reference the kernel implementation of MSR driver). The IPI will disturb the DPDK application because the userspace/kernel context switch, which has impact to the tail latency.
PATCH v18 1/1 trace: add PMU
In reply to Tomasz DuszynskiFrom: Tomasz Duszynski <[email protected]>
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.
---
v17 was merged without this last patch.
It is largely rebased but not compiling.
Feel free to complete the work.
Impact on AMD and unsupported archs must be checked carefully.
--- 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 +++++++++++ doc/guides/rel_notes/release_25_07.rst | 2 + lib/eal/common/eal_common_trace.c | 5 +- lib/eal/common/eal_common_trace_pmu.c | 37 +++++++++++++ lib/eal/common/eal_common_trace_points.c | 5 ++ lib/eal/common/eal_trace.h | 4 ++ lib/eal/common/meson.build | 1 + lib/eal/include/rte_eal_trace.h | 12 +++++ lib/eal/meson.build | 3 ++ lib/meson.build | 2 +- lib/pmu/pmu.c | 69 +++++++++++++++++++++++- lib/pmu/rte_pmu.h | 24 +++++++++ 15 files changed, 207 insertions(+), 4 deletions(-) create mode 100644 lib/eal/common/eal_common_trace_pmu.c
MAINTAINERS +1 -0
@@ -1851,6 +1851,7 @@ F: doc/guides/prog_guide/eventdev/dispatcher_lib.rst PMU - EXPERIMENTAL M: Tomasz Duszynski <[email protected]> F: lib/pmu/ +F: lib/eal/common/eal_common_trace_pmu.c F: app/test/test_pmu.c Job statistics
app/test/test_trace_perf.c +10 -0
@@ -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_PMU_SUPPORTED +/* 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_PMU_SUPPORTED +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_PMU_SUPPORTED +run_test ("read_pmu" , worker_fn_READ_PMU, data, sz); +#endif rte_free (data);return TEST_SUCCESS ;
doc/guides/prog_guide/profile_app.rst +5 -0
@@ -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 ----------------
doc/guides/prog_guide/trace_lib.rst +31 -0
@@ -46,6 +46,7 @@ DPDK tracing library features trace format and is compatible with ``LTTng``. For detailed information, refer to `Common Trace Format <https://diamon.org/ctf/>`_. +- 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 -----------------
doc/guides/rel_notes/release_25_07.rst +2 -0
@@ -59,6 +59,8 @@ New Features Added a Performance Monitoring Unit (PMU) library which allows Linux applications to perform self monitoring activities without depending on external utilities like perf. + After integration with :doc:`../prog_guide/trace_lib`, data gathered from hardware counters + can be stored in CTF format for further analysis. * **Added Mucse rnp net driver.**
lib/eal/common/eal_common_trace.c +4 -1
@@ -75,8 +75,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 +94,7 @@ eal_trace_init(void)void eal_trace_fini (void ) { +trace_pmu_args_free ();trace_mem_free ();trace_metadata_destroy ();eal_trace_args_free ();
lib/eal/common/eal_common_trace_pmu.c new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(C) 2025 Marvell International Ltd. +*/ + +#include <rte_common.h> +#include <rte_pmu.h> + +#include "eal_trace.h" + +#ifdef RTE_PMU_SUPPORTED + +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 (); +} + +#else /* !RTE_PMU_SUPPORTED */ + +void trace_pmu_args_apply(const char *arg __rte_unused) { return; } +void trace_pmu_args_free (void ) {return ; } + +#endif /* RTE_PMU_SUPPORTED */
lib/eal/common/eal_common_trace_points.c +5 -0
@@ -119,3 +119,8 @@ RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_enable, lib.eal.intr.enable) RTE_TRACE_POINT_REGISTER(rte_eal_trace_intr_disable, lib.eal.intr.disable) + +#if defined(ALLOW_EXPERIMENTAL_API ) && defined(RTE_PMU_SUPPORTED ) +RTE_TRACE_POINT_REGISTER (rte_pmu_trace_read, + lib.pmu.read) +#endif
lib/eal/common/eal_trace.h +4 -0
@@ -104,6 +104,10 @@ int trace_epoch_time_save(void);void trace_mem_free (void );void trace_mem_per_thread_free (void ); +/* PMU wrappers */ +void trace_pmu_args_apply (const char *arg); +void trace_pmu_args_free (void ); +/* EAL interface */ int eal_trace_init (void );void eal_trace_fini (void );
lib/eal/common/meson.build +1 -0
@@ -28,6 +28,7 @@ sources += files( 'eal_common_tailqs.c', 'eal_common_thread.c', 'eal_common_timer.c', + 'eal_common_trace_pmu.c', 'eal_common_trace_points.c', 'eal_common_uuid.c', 'malloc_elem.c',
lib/eal/include/rte_eal_trace.h +12 -0
@@ -127,6 +127,18 @@ RTE_TRACE_POINT(#define RTE_EAL_TRACE_GENERIC_FUNC rte_eal_trace_generic_func(__func__) +#ifdef ALLOW_EXPERIMENTAL_API +#include <rte_pmu.h> +#ifdef RTE_PMU_SUPPORTED +RTE_TRACE_POINT_FP ( + rte_pmu_trace_read, + RTE_TRACE_POINT_ARGS(unsigned int index), + uint64_t val = rte_pmu_read(index); +rte_trace_point_emit_u64 (val); +) +#endif +#endif + #ifdef __cplusplus }#endif
lib/eal/meson.build +3 -0
@@ -15,6 +15,9 @@ subdir(exec_env) subdir(arch_subdir) deps += ['log', 'kvargs'] +if is_linux + deps += ['pmu'] +endif if not is_windows deps += ['telemetry'] endif
lib/meson.build +1 -1
@@ -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',
lib/pmu/pmu.c +67 -2
93 lines not on this page · raw message
lib/pmu/rte_pmu.h +24 -0
@@ -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(). */
@@ -148,6 +152,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. */
@@ -160,6 +166,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
@@ -187,6 +196,21 @@ rte_pmu_add_event(const char *name);#define __rte_pmu_read_userpage (pc) ({ RTE_SET_USED(pc); 0; })#endif +/** +* @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.
Signature · 1 line
2.47.1
PATCH 1/1 test/pmu: disable failing test
In reply to Tomasz DuszynskiThe PMU test is reported to fail on some platforms. Disabling until a fix is found.
--- app/test/test_pmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
app/test/test_pmu.c +4 -2
@@ -46,10 +46,12 @@ static struct unit_test_suite pmu_tests = { } }; -static int +static int __rte_unusedtest_pmu (void) {return unit_test_suite_runner (&pmu_tests); } -REGISTER_FAST_TEST (pmu_autotest, true, true, test_pmu); +/* disabled because of reported failures, waiting for a fix +* REGISTER_FAST_TEST(pmu_autotest, true, true, test_pmu); +*/
Signature · 1 line
2.47.1