@@ -145,9 +145,10 @@ static int mgts_show(struct seq_file *s, void *p)
unsigned long ctime_updates = get_mg_ctime_updates();
unsigned long ctime_swaps = get_mg_ctime_swaps();
unsigned long fine_stamps = get_mg_fine_stamps();
+ unsigned long floor_swaps = timekeeping_get_mg_floor_swaps();
- seq_printf(s, "%lu %lu %lu\n",
- ctime_updates, ctime_swaps, fine_stamps);
+ seq_printf(s, "%lu %lu %lu %lu\n",
+ ctime_updates, ctime_swaps, fine_stamps, floor_swaps);
return 0;
}
@@ -48,6 +48,7 @@ extern void ktime_get_coarse_real_ts64(struct timespec64 *ts);
/* Multigrain timestamp interfaces */
extern void ktime_get_coarse_real_ts64_mg(struct timespec64 *ts);
extern void ktime_get_real_ts64_mg(struct timespec64 *ts);
+extern unsigned long timekeeping_get_mg_floor_swaps(void);
void getboottime64(struct timespec64 *ts);
@@ -2478,6 +2478,7 @@ void ktime_get_real_ts64_mg(struct timespec64 *ts)
if (atomic64_try_cmpxchg(&mg_floor, &old, mono)) {
ts->tv_nsec = 0;
timespec64_add_ns(ts, nsecs);
+ timekeeping_inc_mg_floor_swaps();
} else {
/*
* Something has changed mg_floor since "old" was
@@ -17,6 +17,9 @@
#define NUM_BINS 32
+/* incremented every time mg_floor is updated */
+DEFINE_PER_CPU(unsigned long, timekeeping_mg_floor_swaps);
+
static unsigned int sleep_time_bin[NUM_BINS] = {0};
static int tk_debug_sleep_time_show(struct seq_file *s, void *data)
@@ -53,3 +56,13 @@ void tk_debug_account_sleep_time(const struct timespec64 *t)
(s64)t->tv_sec, t->tv_nsec / NSEC_PER_MSEC);
}
+unsigned long timekeeping_get_mg_floor_swaps(void)
+{
+ int i;
+ unsigned long sum = 0;
+
+ for_each_possible_cpu(i)
+ sum += per_cpu(timekeeping_mg_floor_swaps, i);
+ return sum < 0 ? 0 : sum;
+}
+
@@ -10,9 +10,18 @@
* timekeeping debug functions
*/
#ifdef CONFIG_DEBUG_FS
+DECLARE_PER_CPU(unsigned long, timekeeping_mg_floor_swaps);
+static inline void timekeeping_inc_mg_floor_swaps(void)
+{
+ this_cpu_inc(timekeeping_mg_floor_swaps);
+}
+
extern void tk_debug_account_sleep_time(const struct timespec64 *t);
#else
#define tk_debug_account_sleep_time(x)
+static inline void timekeeping_inc_mg_floor_swaps(void)
+{
+}
#endif
#ifdef CONFIG_CLOCKSOURCE_VALIDATE_LAST_CYCLE