@@ -574,6 +574,40 @@ typedef struct _drx_time_scale_t {
574
574
uint timeout_scale ;
575
575
} drx_time_scale_t ;
576
576
577
+ /** Application action types for #drx_time_scale_stat_t. */
578
+ typedef enum {
579
+ DRX_SCALE_ITIMER , /**< Any of the 3 itimers. */
580
+ DRX_SCALE_POSIX_TIMER , /**< Any POSIX timer. */
581
+ DRX_SCALE_SLEEP , /**< Any sleep system call. */
582
+ DRX_SCALE_STAT_TYPES , /**< Count of stat types. */
583
+ } drx_time_scale_type_t ;
584
+
585
+ /**
586
+ * Statistics on scaling attempts for one application action type.
587
+ */
588
+ typedef struct _drx_time_scale_stat_t {
589
+ /* Since dr_atomic_add64_return_sum() is not supported for 32-bit, we make
590
+ * the counters match the bitwidth.
591
+ * An alternative would be to use thread-local counters, but we have no
592
+ * simple way to aggregate all threads prior to exit time.
593
+ */
594
+ /**
595
+ * Count of the instances that might need scaling.
596
+ * For timers, this counts the initial value and the interval separately.
597
+ * If #count_failed and #count_nop are subtracted from this, the result
598
+ * is the count that were successfully scaled to a larger duration.
599
+ */
600
+ ptr_int_t count_attempted ;
601
+ /**
602
+ * Count of the instances where scaling was attempted but failed.
603
+ */
604
+ ptr_int_t count_failed ;
605
+ /**
606
+ * Count of the instances ignored (disabled timers, sleep of 0, scale of 1, etc.).
607
+ */
608
+ ptr_int_t count_nop ;
609
+ } drx_time_scale_stat_t ;
610
+
577
611
/**
578
612
* Priorities of drmgr instrumentation passes used for time scaling. Users can use these
579
613
* priorities in the #drmgr_priority_t "priority" field or the associated names
@@ -622,6 +656,15 @@ DR_EXPORT
622
656
bool
623
657
drx_unregister_time_scaling ();
624
658
659
+ DR_EXPORT
660
+ /**
661
+ * Returns a pointer to an array with #DRX_SCALE_STAT_TYPES entries, with the entry
662
+ * at index "i" containing statistics on scaling for the #drx_time_scale_type_t with
663
+ * value equal to "i".
664
+ */
665
+ bool
666
+ drx_get_time_scaling_stats (drx_time_scale_stat_t * * stats_array );
667
+
625
668
/**@}*/ /* end doxygen group */
626
669
627
670
#ifdef __cplusplus
0 commit comments