On Mittwoch, 11. Dezember 2024 15:58:32 Mitteleuropäische Normalzeit Serhei Makarov wrote: > 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, linux/perf/tools/design.txt mentions an 'munmap' field in > struct perf_event_attr, but it doesn't seem to have made it into the actual > kernel implementation of perf_events. I'll have to do some more digging to > find out what happened with that idea between design and implementation. > > If we have reason to believe that the process mappings are changing too > drastically to get sensible results with incremental updates, > sysprof-live-unwinder's current quick solution (i.e. re-scan the proc > mappings from scratch) is a feasible fallback. We just need a threshold for > doing that which is 'sensible, but not too frequent'. Even a time threshold > might be worth experimenting with for this. The main high-overhead case > we're trying to avoid is when a process loads then does mmap, mmap, mmap, > and the profiler is following this process from the start and reloading the > Dwfl each time.
The way we handle this in perfparser is by not actually reporting anything until the time when we actually need it. I.e. we store the mmap events from perf in a way that we can use for fast lookups. Then during unwinding we ensure that the IP for whatever we are about to access is reported e.g. from the `memory_read` callback or for every IP we found before symbolication / inline frame resolution. When we receive more perf mmap events we check whether they invalidate old mappings (i.e. overlapping an existing region), we invalidate our caches,and unreport the modules from dwfl, and start the process anew. I don't think it's a good idea to report all modules all the time to elfutils - esp. in large applications with compressed debug information it can often be that you only need a fraction of the loaded shared symbols e.g. Also consider debuginfod - you don't want to download everything (such as GDB would be doing), you only want to download what's needed. Cheers -- Milian Wolff m...@milianw.de http://milianw.de
signature.asc
Description: This is a digitally signed message part.