@@ -47,7 +47,8 @@ const DDPROF_STATS s_cycled_stats[] = {
4747const long k_clock_ticks_per_sec = sysconf(_SC_CLK_TCK);
4848
4949// / Remove all structures related to
50- DDRes worker_pid_free (DDProfContext &ctx, pid_t el);
50+ DDRes worker_pid_free (DDProfContext &ctx, pid_t el,
51+ PerfClock::time_point timestamp);
5152
5253DDRes clear_unvisited_pids (DDProfContext &ctx);
5354
@@ -231,7 +232,7 @@ DDRes ddprof_unwind_sample(DDProfContext &ctx, perf_event_sample *sample,
231232 if (us->_dwfl_wrapper && us->_dwfl_wrapper ->_inconsistent ) {
232233 // Loaded modules were inconsistent, assume we should flush everything.
233234 LG_WRN (" (Inconsistent DWFL/DSOs)%d - Free associated objects" , us->pid );
234- DDRES_CHECK_FWD (worker_pid_free (ctx, us->pid ));
235+ DDRES_CHECK_FWD (worker_pid_free (ctx, us->pid , PerfClock::now () ));
235236 }
236237 return res;
237238}
@@ -303,19 +304,21 @@ DDRes aggregate_live_allocations(DDProfContext &ctx) {
303304 return {};
304305}
305306
306- DDRes worker_pid_free (DDProfContext &ctx, pid_t el) {
307+ DDRes worker_pid_free (DDProfContext &ctx, pid_t el,
308+ PerfClock::time_point timestamp) {
307309 DDRES_CHECK_FWD (aggregate_live_allocations_for_pid (ctx, el));
308310 UnwindState *us = ctx.worker_ctx .us ;
309- unwind_pid_free (us, el);
311+ unwind_pid_free (us, el, timestamp );
310312 ctx.worker_ctx .live_allocation .clear_pid (el);
311313 return {};
312314}
313315
314316DDRes clear_unvisited_pids (DDProfContext &ctx) {
315317 UnwindState *us = ctx.worker_ctx .us ;
316318 const std::vector<pid_t > pids_remove = us->dwfl_hdr .get_unvisited ();
319+ const PerfClock::time_point now = PerfClock::now ();
317320 for (pid_t const el : pids_remove) {
318- DDRES_CHECK_FWD (worker_pid_free (ctx, el));
321+ DDRES_CHECK_FWD (worker_pid_free (ctx, el, now ));
319322 }
320323 us->dwfl_hdr .reset_unvisited ();
321324 return {};
@@ -584,21 +587,21 @@ void ddprof_pr_lost(DDProfContext &ctx, const perf_event_lost *lost,
584587}
585588
586589DDRes ddprof_pr_comm (DDProfContext &ctx, const perf_event_comm *comm,
587- int watcher_pos) {
590+ int watcher_pos, PerfClock::time_point timestamp ) {
588591 // Change in process name (assuming exec) : clear all associated dso
589592 if (comm->header .misc & PERF_RECORD_MISC_COMM_EXEC) {
590593 LG_DBG (" <%d>(COMM)%d -> %s" , watcher_pos, comm->pid , comm->comm );
591- DDRES_CHECK_FWD (worker_pid_free (ctx, comm->pid ));
594+ DDRES_CHECK_FWD (worker_pid_free (ctx, comm->pid , timestamp ));
592595 }
593596 return {};
594597}
595598
596599DDRes ddprof_pr_fork (DDProfContext &ctx, const perf_event_fork *frk,
597- int watcher_pos) {
600+ int watcher_pos, PerfClock::time_point timestamp ) {
598601 LG_DBG (" <%d>(FORK)%d -> %d/%d" , watcher_pos, frk->ppid , frk->pid , frk->tid );
599602 if (frk->ppid != frk->pid ) {
600603 // Clear everything and populate at next error or with coming samples
601- DDRES_CHECK_FWD (worker_pid_free (ctx, frk->pid ));
604+ DDRES_CHECK_FWD (worker_pid_free (ctx, frk->pid , timestamp ));
602605 ctx.worker_ctx .us ->dso_hdr .pid_fork (frk->pid , frk->ppid );
603606 }
604607 return {};
@@ -745,8 +748,11 @@ DDRes ddprof_worker_process_event(const perf_event_header *hdr, int watcher_pos,
745748 break ;
746749 case PERF_RECORD_COMM:
747750 if (wpid->pid ) {
748- DDRES_CHECK_FWD (ddprof_pr_comm (
749- ctx, reinterpret_cast <const perf_event_comm *>(hdr), watcher_pos));
751+ auto timestamp = perf_clock_time_point_from_timestamp (
752+ hdr_time (hdr, watcher->sample_type ));
753+ DDRES_CHECK_FWD (
754+ ddprof_pr_comm (ctx, reinterpret_cast <const perf_event_comm *>(hdr),
755+ watcher_pos, timestamp));
750756 }
751757 break ;
752758 case PERF_RECORD_EXIT:
@@ -757,8 +763,11 @@ DDRes ddprof_worker_process_event(const perf_event_header *hdr, int watcher_pos,
757763 break ;
758764 case PERF_RECORD_FORK:
759765 if (wpid->pid ) {
760- DDRES_CHECK_FWD (ddprof_pr_fork (
761- ctx, reinterpret_cast <const perf_event_fork *>(hdr), watcher_pos));
766+ auto timestamp = perf_clock_time_point_from_timestamp (
767+ hdr_time (hdr, watcher->sample_type ));
768+ DDRES_CHECK_FWD (
769+ ddprof_pr_fork (ctx, reinterpret_cast <const perf_event_fork *>(hdr),
770+ watcher_pos, timestamp));
762771 }
763772
764773 break ;
0 commit comments