All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Convert TSC to monotonic clock for PEBS
@ 2023-01-23 18:27 kan.liang
  2023-01-23 18:27 ` [PATCH 1/3] timekeeping: NMI safe converter from a given time to monotonic kan.liang
                   ` (3 more replies)
  0 siblings, 4 replies; 20+ messages in thread
From: kan.liang @ 2023-01-23 18:27 UTC (permalink / raw)
  To: peterz, mingo, tglx, jstultz, sboyd, linux-kernel
  Cc: eranian, namhyung, ak, Kan Liang

From: Kan Liang <kan.liang@linux.intel.com>

A Processor Event Based Sampling (PEBS) record includes a field that
provide the time stamp counter value when the counter was overflowed
and the PEBS record was generated. The accurate time stamp can be used
to reconcile user samples. However, the current PEBS codes only can
convert the time stamp to sched_clock, which is not available from user
space. A solution to convert a given TSC to user visible monotonic
clock is required.

The perf_event subsystem only converts the TSC in a NMI handler. The
converter function must be fast and NMI safe.

Considered the below two existing functions, but none of them fulfill
the above requirements.
- The ktime_get_mono_fast_ns() is NMI safe, but it can only return the
  current clock monotonic rather than a given time's monotonic.
- The get_device_system_crosststamp() can calculate the system time from
  a given device time. But it's not fast and NMI safe.

Introduce a new generic interface, get_mono_fast_from_given_time, to
convert a given timestamp to clock monotonic.

Kan Liang (3):
  timekeeping: NMI safe converter from a given time to monotonic
  x86/tsc: Add set_tsc_system_counterval
  perf/x86/intel/ds: Support monotonic clock for PEBS

 arch/x86/events/intel/core.c |  2 +-
 arch/x86/events/intel/ds.c   | 30 +++++++++++++---
 arch/x86/include/asm/tsc.h   |  1 +
 arch/x86/kernel/tsc.c        |  6 ++++
 include/linux/timekeeping.h  |  9 +++++
 kernel/time/timekeeping.c    | 68 ++++++++++++++++++++++++++++++++++--
 6 files changed, 108 insertions(+), 8 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-01-27 13:30 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23 18:27 [PATCH 0/3] Convert TSC to monotonic clock for PEBS kan.liang
2023-01-23 18:27 ` [PATCH 1/3] timekeeping: NMI safe converter from a given time to monotonic kan.liang
2023-01-24  7:01   ` John Stultz
2023-01-24 15:09     ` Liang, Kan
2023-01-24 18:43       ` John Stultz
2023-01-24 20:12         ` Liang, Kan
2023-01-24 20:33           ` John Stultz
2023-01-24 22:08             ` Liang, Kan
2023-01-24 22:40               ` John Stultz
2023-01-25 16:44                 ` Liang, Kan
2023-01-24  8:51   ` Thomas Gleixner
2023-01-24  9:10     ` Stephane Eranian
2023-01-24 16:06       ` Liang, Kan
2023-01-27 13:30       ` Thomas Gleixner
2023-01-23 18:27 ` [PATCH 2/3] x86/tsc: Add set_tsc_system_counterval kan.liang
2023-01-23 18:27 ` [PATCH 3/3] perf/x86/intel/ds: Support monotonic clock for PEBS kan.liang
2023-01-24  6:56   ` John Stultz
2023-01-24 15:17     ` Liang, Kan
2023-01-24  6:13 ` [PATCH 0/3] Convert TSC to " John Stultz
2023-01-24 15:04   ` Liang, Kan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.