[2/3] x86/tsc: Add set_tsc_system_counterval
Commit Message
From: Kan Liang <kan.liang@linux.intel.com>
The perf_event subsystem wants to convert a TSC of a PEBS record to a
monotonic clock. Introduce a new function to provide both the TSC
value and TSC clocksource information with the format required by the
callback function from the timekeeping code.
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
---
arch/x86/include/asm/tsc.h | 1 +
arch/x86/kernel/tsc.c | 6 ++++++
2 files changed, 7 insertions(+)
@@ -29,6 +29,7 @@ static inline cycles_t get_cycles(void)
extern struct system_counterval_t convert_art_to_tsc(u64 art);
extern struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns);
+extern struct system_counterval_t set_tsc_system_counterval(u64 tsc);
extern void tsc_early_init(void);
extern void tsc_init(void);
@@ -1311,6 +1311,12 @@ struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns)
}
EXPORT_SYMBOL(convert_art_ns_to_tsc);
+struct system_counterval_t set_tsc_system_counterval(u64 tsc)
+{
+ return (struct system_counterval_t) { .cs = &clocksource_tsc,
+ .cycles = tsc};
+}
+EXPORT_SYMBOL(set_tsc_system_counterval);
static void tsc_refine_calibration_work(struct work_struct *work);
static DECLARE_DELAYED_WORK(tsc_irqwork, tsc_refine_calibration_work);