Re: [PATCH v2 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-17 Thread Serhei Makarov
On Tue, Apr 15, 2025, at 3:32 PM, Serhei Makarov wrote: > it should not necessary to duplicate the FD on the Sysprof side, > unless Sysprof wants to use the FD for its own purposes independently > of what Elfutils is doing with it. Updated the Sysprof side of the code again to match v3 of the el

[PATCH v3 05/12] libdwfl [5/12]: introduce Dwfl_Process_Tracker

2025-04-17 Thread Serhei Makarov
New data structure to coordinate caching Elf data among multiple Dwfl structs attached to different processes. Meant to reduce the overhead for profilers that use elfutils for unwinding. The caching is well-justified, as the prior approach (e.g. in eu-stacktrace, sysprof-live-unwinder) of creating

[PATCH v3 12/12] eu-stacktrace [12/12]: use dwfl_perf_sample_getframes

2025-04-17 Thread Serhei Makarov
Changes for v3: - Fix initialization of elf in sysprof_init_dwfl (previously triggered -Wmaybe-uninitialized). * * * Remove the code from src/stacktrace.c that is now covered by libdwfl/dwfl_perf_frame.c and dwfl_perf_sample_getframes. * src/stacktrace.c (show_memory_reads): Remove this verbo

[PATCH v3 06/12] libdwfl [6/12]: Elf* caching via dwfl_process_tracker

2025-04-17 Thread Serhei Makarov
Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching modules from different filesystems e.g. a main filesystem and a container filesystem) and guard more carefully against collisions. - Add external API for implementing a custom find_elf callback

[PATCH v3 07/12] eu-stacktrace [7/12]: use Dwfl_Process_Tracker for Elf * caching

2025-04-17 Thread Serhei Makarov
* src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwfl_process_tracker_find_elf for caching. (sysprof_init_dwfl): Use dwfl_begin_with_tracker. (main): Initialize and clean up tracker. --- src/stacktrace.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions

[PATCH v3 11/12] libdwfl [11/12]: add dwfl_perf_sample_getframes

2025-04-17 Thread Serhei Makarov
Changes for v3: - use const void *stack, not void *, to allow users to pass a const stack sample Changes for v2: - use renamed __libdwfl_set_initial_registers_thread - oops, should use provided sample_arg->perf_regs_mask in sample_set_initial registers * * * This is a new interface for un

[PATCH v3 04/12] libdwfl [4/12]: add dwfl_perf_sample_preferred_regs_mask

2025-04-17 Thread Serhei Makarov
Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Since libebl is a private interface, subsequent patches in the series introduce another api wrapping the libebl perf register handling. In this patch, add an interface to access the preferred se

[PATCH v3 10/12] eu-stacktrace [10/12]: use dwfl_process_tracker_find_pid

2025-04-17 Thread Serhei Makarov
Initial minimal change to ensure dwfl_process_tracker_find_pid is tested. For now, we keep the additional dwfltab code in stacktrace.c, since it's used to track statistics. In future follow-ups, it will be good to switch to storing eu-stacktrace statistics in dwfl->process->callbacks_arg. This req

[PATCH v3 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-17 Thread Serhei Makarov
Change the sample_set_initial_registers callback in eu-stacktrace to use the proper libebl ebl_set_initial_registers_sample function. * src/Makefile.am (stacktrace_LDADD): Add libebl. * src/stacktrace.c (sample_registers_cb): New function, though identical to pid_thread_state_registers_cb. (sa

[PATCH v3 09/12] libdwfl [9/12]: add dwfl_process_tracker_find_pid

2025-04-17 Thread Serhei Makarov
Changes for v2: - Add locking for dwfltab. * * * New function that retrieves the Dwfl for a particular PID, or, if the Dwfl is absent, creates it via a provided callback and adds it to the table later, when the PID is confirmed via dwfl_attach_state. * libdwfl/libdwfl.h (dwfl_process_tracker_fi

[PATCH v3 02/12] libdwfl [2/12]: expose setfunc callback for libdwfl+libebl clients

2025-04-17 Thread Serhei Makarov
Changes for v2: - No longer exposing this in public libdwfl.h api. * * * Renaming pid_set_initial_registers to __libdwfl_set_initial_registers_thread and adding to libdwflP.h. This callback was private to one file, but now we need to access it from the perf_events sampling code as well. * libd

[PATCH v3 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-17 Thread Serhei Makarov
Changes for v2: - Merged commit 11 into commit 1 (both sample_base_addr/sample_pc and set_initial_registers_sample make sense to introduce in the same commit). - Added i386 backend and factored out common code. * * * First patch of a series that reworks eu-stacktrace functionality into a li