Re: [PATCH] PR32930 backends/: guard asm/perf_regs.h include

2025-05-06 Thread Serhei Makarov
On Tue, May 6, 2025, at 11:24 AM, Aaron Merey wrote: > So if the arch is not x86_64 or i386, then PERF_FRAME_REGISTERS_* will > be 0 and this signals to the backend to skip any unwinding. LGTM. Yep, will expand the #ifdef as more architectures are added. Committed. -- All the best, Serhei

[PATCH] PR32930 backends/: guard asm/perf_regs.h include

2025-05-05 Thread Serhei Makarov
asm/perf_regs.h is an arch-specific linux include, not present on architectures like hppa and m68k that lack perf_events support. Only one place we need to fix; others already guard the include by architecture, or use architecture-independent headers (e.g. linux/perf_events.h). * backends/libebl_

Re: [RFC v2] sketch of an unwinder cache interface for elfutils libdwfl

2025-04-29 Thread Serhei Makarov
On Thu, Mar 20, 2025, at 10:28 AM, Serhei Makarov wrote: > On Tue, Dec 10, 2024, at 4:42 PM, Serhei Makarov wrote: >> This email sketches an 'unwinder cache' interface for libdwfl, derived >> from recent eu-stacktrace code [1] and based on Christian Hergert's >

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

2025-04-25 Thread Serhei Makarov
On Fri, Apr 25, 2025, at 12:02 PM, Aaron Merey wrote: >> First patch of a series that reworks eu-stacktrace functionality >> into a library interface for other profiling tools. > > Thanks I've approved and merged this series with two changes: > Signed-off-by added to each commit message and a rw

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

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. 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

[PATCH v6 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * 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

[PATCH v6 12/12] eu-stacktrace [12/12]: use dwflst_perf_sample_getframes

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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_stacktrace/dwflst_perf_frame.c and dwflst

[PATCH v6 11/12] libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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

[PATCH v6 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * Initial minimal change to ensure dwflst_tracker_find_pid is tested. For now, we keep the additional dwfltab implementation in stacktrace.c, since it's being used to track statisti

[PATCH v6 08/12] libdwfl_stacktrace [8/12]: Dwfl* caching via Dwflst_Process_Tracker

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwflst_Process_Tracker also includes a dynamicsizehash cache which maps process id

[PATCH v6 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v5: - Bugfixes in dwflst_tracker_find_elf.c. Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes f

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

2025-04-25 Thread Serhei Makarov
Changes for v4: - Since __libdwfl_set_initial_registers_thread is now private to libdwfl, the modified code in this patch has been disabled. * * * Dummy commit to show how the sample_set_initial_registers callback in eu-stacktrace would use the proper libebl ebl_set_initial_registers_sample fu

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

2025-04-25 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * * src/Makefile.am (AM_CPPFLAGS): Include headers from ../libdwfl_stacktrace. * src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwflst_tracker_linux_proc_find_elf for caching. (sysprof_init_dwf

[PATCH v6 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-25 Thread Serhei Makarov
Changes for v5: - Separate ELFUTILS_0.193_EXPERIMENTAL namespace, mark library experimental. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Subsequent patches in the series

[PATCH v6 09/12] libdwfl_stacktrace [9/12]: add dwflst_tracker_find_pid

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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 t

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

2025-04-25 Thread Serhei Makarov
Changes for v6: - Minor fixes as requested. 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

Re: [PATCH v5 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-25 Thread Serhei Makarov
On Fri, Apr 25, 2025, at 1:57 AM, Aaron Merey wrote: > Also if you haven't done so already, please run any manual tests under > valgrind memcheck (and helgrind if you are able to test this with > multithreading). Ran eu-stacktrace through valgrind; the content of the cache is marked as 'leaked'

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

2025-04-25 Thread Serhei Makarov
On Fri, Apr 25, 2025, at 1:54 AM, Aaron Merey wrote: > This commit could probably be merged with 2 or 12 with the > sample_set_initial_registers design decisions explained in the commit > message. But this patch as-is is harmless so if you prefer to keep it > this way that's ok with me. I'm incl

[PATCH v5 11/12] libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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

Re: [PATCH v5 07/14] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-24 Thread Serhei Makarov
On Thu, Apr 24, 2025, at 5:47 PM, Serhei Makarov wrote: > Changes Sorry, this one (with 07/14 in the title) was accidentally mixed in with the v5 submission. It's from a draft copy generated with an earlier git send-email command, please ignore.

[PATCH v5 12/12] eu-stacktrace [12/12]: use dwflst_perf_sample_getframes

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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_stacktrace/dwflst_perf_frame.c and dwflst

[PATCH v5 08/12] libdwfl_stacktrace [8/12]: Dwfl* caching via Dwflst_Process_Tracker

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwflst_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwflst_tracker_dwfl_in

[PATCH v5 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-24 Thread Serhei Makarov
Changes for v5: - Bugfixes in dwflst_tracker_find_elf.c. Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes for v3: - Reworked elftab to incorporate dev/i

[PATCH v5 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-24 Thread Serhei Makarov
Changes for v5: - Separate ELFUTILS_0.193_EXPERIMENTAL namespace, mark library experimental. Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Subsequent patches in the series

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

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * * src/Makefile.am (AM_CPPFLAGS): Include headers from ../libdwfl_stacktrace. * src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwflst_tracker_linux_proc_find_elf for caching. (sysprof_init_dwf

[PATCH v5 09/12] libdwfl_stacktrace [9/12]: add dwflst_tracker_find_pid

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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 v

[PATCH v5 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * Initial minimal change to ensure dwflst_tracker_find_pid is tested. For now, we keep the additional dwfltab implementation in stacktrace.c, since it's being used to track statistics. In future follow-ups, it will be good to

[PATCH v5 07/14] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-24 Thread Serhei Makarov
Changes Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching module

[PATCH v5 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-24 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * 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

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

2025-04-24 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 v5 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-24 Thread Serhei Makarov
Changes for v4: - Since __libdwfl_set_initial_registers_thread is now private to libdwfl, the modified code in this patch has been disabled. * * * Dummy commit to show how the sample_set_initial_registers callback in eu-stacktrace would use the proper libebl ebl_set_initial_registers_sample fu

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

2025-04-24 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

[PATCH v4 06/12] libdwfl_stacktrace [6/12]: Elf* caching via dwflst_process_tracker

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. - dwfl_module_getdwarf.c now uses the dwflst_tracker_cache_elf() interface instead of editing the elftab directly. Changes for v3: - Reworked elftab to incorporate dev/ino into the caching key (to allow caching modules from di

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

2025-04-23 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 v4 10/12] eu-stacktrace [10/12]: use dwflst_tracker_find_pid

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * Initial minimal change to ensure dwflst_tracker_find_pid is tested. For now, we keep the additional dwfltab implementation in stacktrace.c, since it's being used to track statistics. In future follow-ups, it will be good to

[PATCH v4 04/12] libdwfl_stacktrace [4/12]: intro library, add dwflst_perf_sample_preferred_regs_mask

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v2: - guard the linux/perf_events.h include properly with an #if defined __linux__ * * * Subsequent patches in the series introduce a new library for tracking/caching Elf structs across multiple processes and wrapping

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

2025-04-23 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

[PATCH v4 12/12] eu-stacktrace [12/12]: use dwflst_perf_sample_getframes

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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_stacktrace/dwflst_perf_frame.c and dwflst

[PATCH v4 11/12] libdwfl_stacktrace [11/12]: add dwflst_perf_sample_getframes

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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

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

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * * src/Makefile.am (AM_CPPFLAGS): Include headers from ../libdwfl_stacktrace. * src/stacktrace.c (tracker): New global variable. (sample_callbacks): Use dwflst_tracker_linux_proc_find_elf for caching. (sysprof_init_dwf

[PATCH v4 09/12] libdwfl_stacktrace [9/12]: add dwflst_tracker_find_pid

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. 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 v

[PATCH v4 08/12] libdwfl_stacktrace [8/12]: Dwfl* caching via Dwflst_Process_Tracker

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwflst_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwflst_tracker_dwfl_in

[PATCH v4 05/12] libdwfl_stacktrace [5/12]: introduce Dwflst_Process_Tracker

2025-04-23 Thread Serhei Makarov
Changes for v4: - Separate out libdwfl_stacktrace, as requested. * * * 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

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

2025-04-23 Thread Serhei Makarov
Changes for v4: - Since __libdwfl_set_initial_registers_thread is now private to libdwfl, the modified code in this patch has been disabled. * * * Dummy commit to show how the sample_set_initial_registers callback in eu-stacktrace would use the proper libebl ebl_set_initial_registers_sample fu

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 6:26 PM, Frank Ch. Eigler wrote: > Hi - > >> CCLD libdw.so >> /usr/bin/ld: ../libdwfl/libdwfl_pic.a(dwfl_module_getdwarf.os): in function >> `open_elf': >> Calling a public function across the library boundary should be no problem, >> but we run into this -- circu

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 10:17 AM, Aaron Merey wrote: > dwfl_st or dwflst prefixes work for me. I think I slightly prefer > dwfl_st. As for where to define Dwfl_Process_tracker let's try to keep > it to the new dwfl_stacktraceP.h and if possible use forward > declarations to avoid circular depen

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 10:17 AM, Aaron Merey wrote: >> One question this raises re: the Dwfl_Process_Tracker structure and where >> its implementation should be located. In the patches, the Dwfl struct >> implementation includes a pointer to a Dwfl_Process_Tracker. I’m not sure if >> elfuti

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Tue, Apr 22, 2025, at 9:45 AM, Aaron Merey wrote: > Hi Serhei, > > On Tue, Apr 22, 2025 at 9:27 AM Serhei Makarov wrote: >> >> On Mon, Apr 21, 2025, at 12:29 AM, Aaron Merey wrote:. >> > >> > I know we're close to the next release and I do want th

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-04-22 Thread Serhei Makarov
On Mon, Apr 21, 2025, at 12:29 AM, Aaron Merey wrote:. > > I know we're close to the next release and I do want this work to be > included. My proposal is to move the current API out of libdwfl and > into a new library, as-is but clearly marked as experimental and > subject to possible API/ABI

[PATCH v3 08/12] libdwfl [8/12]: Dwfl* caching via dwfl_process_tracker

2025-04-18 Thread Serhei Makarov
Changes for v3: - Handle dwfl->process == NULL case in __libdwfl_remove_dwfl_from_tracker. * * * The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the t

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

[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

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

2025-04-15 Thread Serhei Makarov
On Tue, Apr 15, 2025, at 2:15 PM, Christian Hergert wrote: > On 4/15/25 09:12, Serhei Makarov wrote: >> Option 2: expose one function, treat file_name and fd as optional input >> parameters. >> >> // normal use case >> module_name = "/usr/lib/whatever.

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

2025-04-15 Thread Serhei Makarov
On Fri, Apr 4, 2025, at 5:04 PM, Serhei Makarov wrote: > Changes for v2: > > - Add locking for elftab. This is needed in addition to the > intrinsic locking in dynamicsizehash_concurrent to avoid > having cache_elf expose an incomplete dwfltracker_elf_info* > entry to o

[RFC v2] sketch of an unwinder cache interface for elfutils libdwfl

2025-04-05 Thread Serhei Makarov
On Tue, Dec 10, 2024, at 4:42 PM, Serhei Makarov wrote: > This email sketches an 'unwinder cache' interface for libdwfl, derived > from recent eu-stacktrace code [1] and based on Christian Hergert's > adaptation of eu-stacktrace as sysprof-live-unwinder [2]. The intent

Re: [PATCH 05/13] libdwfl [5/13]: introduce Dwfl_Process_Tracker

2025-04-05 Thread Serhei Makarov
On Thu, Mar 20, 2025, at 8:01 AM, Mark Wielaard wrote: > Hi Serhei, > > On Sun, 2025-03-16 at 19:14 -0400, Serhei Makarov wrote: > I am wondering whether this isn't too abstract. libdwfl Dwfl's are > already super abstract so they can be used for running processes and &

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

2025-04-04 Thread Serhei Makarov
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 verbose option as the relevant code is inside libdwfl now. (struct __sample_arg): Remove, handled by libdwfl/dwfl_perf_fram

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

2025-04-04 Thread Serhei Makarov
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 unwinding that doesn't require the Dwfl to be attached to a live process (via ptrace) or via corefile.

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

2025-04-04 Thread Serhei Makarov
Changes for v2: - Add locking for elftab. This is needed in addition to the intrinsic locking in dynamicsizehash_concurrent to avoid having cache_elf expose an incomplete dwfltracker_elf_info* entry to other threads while its data is being populated / replaced. - Tidy dwfl_process_tracker

[PATCH v2 08/12] libdwfl [8/12]: Dwfl* caching via dwfl_process_tracker

2025-04-04 Thread Serhei Makarov
The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the tracker are automatically added to it, and removed on dwfl_end(). * libdwfl/libdwflP.h (dwfltracker_

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

2025-04-04 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 v2 03/12] libebl [3/12]: eu-stacktrace: use new register handling api

2025-04-04 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 v2 04/12] libdwfl [4/12]: add dwfl_perf_sample_preferred_regs_mask

2025-04-04 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 v2 09/12] libdwfl [9/12]: add dwfl_process_tracker_find_pid

2025-04-04 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 v2 10/12] eu-stacktrace [10/12]: use dwfl_process_tracker_find_pid

2025-04-04 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 v2 05/12] libdwfl [5/12]: introduce Dwfl_Process_Tracker

2025-04-04 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 v2 02/12] libdwfl [2/12]: expose setfunc callback for libdwfl+libebl clients

2025-04-04 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 v2 01/12] libebl [1/12]: api for perf register handling, start with x86_64

2025-04-04 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

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

2025-04-04 Thread Serhei Makarov
On Thu, Apr 3, 2025, at 1:19 PM, Serhei Makarov wrote: > On Sun, Mar 16, 2025, at 7:15 PM, Serhei Makarov wrote: >> +/* The same callback, except this first attempts to look up a cached >> + Elf* and fd from the Dwfl_Module's Dwfl_Process_Tracker (if any). >> +

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

2025-04-03 Thread Serhei Makarov
On Sun, Mar 16, 2025, at 7:15 PM, Serhei Makarov wrote: > +/* The same callback, except this first attempts to look up a cached > + Elf* and fd from the Dwfl_Module's Dwfl_Process_Tracker (if any). > + If a new Elf* has to be created, this saves it to the cache. */

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

2025-04-01 Thread Serhei Makarov
On Wed, Mar 19, 2025, at 11:53 AM, Mark Wielaard wrote: > Also the libebl interface is very verbose for this mask. > Clearly copied from how frame_nregs is done. > So fine for now. But we might want to look into something simpler for > both of these. Both fetching frame_nregs and perf_frame_regs

Re: [PATCH 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-03-20 Thread Serhei Makarov
On Wed, Mar 19, 2025, at 5:36 PM, Mark Wielaard wrote: > Hi Serhei, > > On Sun, Mar 16, 2025 at 07:14:11PM -0400, Serhei Makarov wrote: >> Since libebl is a private interface, subsequent patches in the series >> introduce another api wrapping the libebl perf register handli

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

2025-03-18 Thread Serhei Makarov
On Tue, Mar 18, 2025, at 10:04 AM, Mark Wielaard wrote: > In some other situations that is "solved" with marking the function > arguments with __attribute__ ((unused)) (which isn't true for x86_64, > but the compiler is fine with that). The other hack (that I'd go with, if there's no style objec

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

2025-03-17 Thread Serhei Makarov
On Sun, Mar 16, 2025, at 7:12 PM, Serhei Makarov wrote: > +bool > +x86_64_set_initial_registers_sample (const Dwarf_Word *regs, uint32_t > n_regs, > + uint64_t regs_mask, uint32_t abi, > + ebl_tid_regis

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

2025-03-16 Thread Serhei Makarov
The Dwfl_Process_Tracker includes a dynamicsizehash cache which maps file paths to Elf * (or rather, dwfl_tracker_elf_info * storing fd and Elf *). We provide a dwfl_process_tracker_find_elf callback which checks the cache for an already-loaded Elf * and, if missing, populates the cache with the f

[PATCH 05/13] libdwfl [5/13]: introduce Dwfl_Process_Tracker

2025-03-16 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 03/13] libebl [3/13]: eu-stacktrace: use new register handling api

2025-03-16 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 13/13] eu-stacktrace [13/13]: use dwfl_perf_sample_getframes

2025-03-16 Thread Serhei Makarov
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 verbose option as the relevant code is inside libdwfl now. (struct __sample_arg): Remove, handled by libdwfl/dwfl_perf_fram

[PATCH 12/13] libdwfl [12/13]: add dwfl_perf_sample_getframes

2025-03-16 Thread Serhei Makarov
This is a new interface for unwinding that doesn't require the Dwfl to be attached to a live process (via ptrace) or via corefile. Instead, data from a perf_events stack sample is provided along with an Elf struct used to identify the architecture. Based on code from eu-stacktrace. * libdwfl/libdw

[PATCH 11/13] libebl [11/13]: provide access to register file pc, sp

2025-03-16 Thread Serhei Makarov
These additional libebl hooks are needed to extract the location of the stack frame in-memory from the perf_events register sample, when dwfl_perf_sample_getframes is implemented in the next patch. Implementing x86_64 for now, just as with the earlier ebl patches. * libebl/libebl.h (ebl_sample_ba

[PATCH 10/13] eu-stacktrace [10/13]: use dwfl_process_tracker_find_pid

2025-03-16 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 09/13] libdwfl [9/13]: add dwfl_process_tracker_find_pid

2025-03-16 Thread Serhei Makarov
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_find_pid): New function. * libdwfl/dwfl_process_tracke

[PATCH 08/13] libdwfl [8/13]: Dwfl* caching via dwfl_process_tracker

2025-03-16 Thread Serhei Makarov
The Dwfl_Process_Tracker also includes a dynamicsizehash cache which maps process ids to Dwfl * (or rather, dwfltracker_dwfl_info * allowing the table entry to be replaced). Dwfls created from the tracker are automatically added to it, and removed on dwfl_end(). * libdwfl/libdwflP.h (dwfltracker_

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

2025-03-16 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 04/13] libdwfl [4/13]: add dwfl_perf_sample_preferred_regs_mask

2025-03-16 Thread Serhei Makarov
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 set of registers that libdwfl would like to see to allow proper unwinding of stack sample data. * libdwfl

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

2025-03-16 Thread Serhei Makarov
Renaming to dwfl_set_initial_registers_thread. This callback was private to one file, but now that other tools (eu-stacktrace, sysprof via the dwfl_perf_sample_getframes) are invoking the ebl set_initial_registers_sample api, we need to expose it. Otherwise, clients would need to reimplement this

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

2025-03-16 Thread Serhei Makarov
First patch of a series that reworks eu-stacktrace functionality into a library interface for other profiling tools. * * * As it happens, Linux perf_events and DWARF can prescribe completely different layouts for the register file, requiring non-obvious code for translation. This makes sense to p

Re: [RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-13 Thread Serhei Makarov
On Wed, Dec 11, 2024, at 6:24 AM, Milian Wolff wrote: > On Dienstag, 10. Dezember 2024 22:42:25 Mitteleuropäische Normalzeit Serhei > Makarov wrote: >> This email sketches an 'unwinder cache' interface for libdwfl, derived from >> recent eu-stacktrace code [1] and

Re: [RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-11 Thread Serhei Makarov
On Wed, Dec 11, 2024, at 9:46 AM, William Cohen wrote: > Hi Serhei, > > The dwfl_report_proc_map() will handle when things are added to the > memory map. Is there anything to handle the inverse event when memory > is removed from the process memory map, such as a dlcose()? > Interestingly, li

[RFC] sketch of an unwinder cache interface for elfutils libdwfl

2024-12-10 Thread Serhei Makarov
This email sketches an 'unwinder cache' interface for libdwfl, derived from recent eu-stacktrace code [1] and based on Christian Hergert's adaptation of eu-stacktrace as sysprof-live-unwinder [2]. The intent is to remove the need for a lot of boilerplate code that would be identical among profil

  1   2   >