Skip to content

RFC Convert TSC to monotonic raw clock for PEBS

[email protected] lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest9 patches 28 repliesIn review
  2. v13 patches 16 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9timekeeping: Expose the conversion information of monotonic rawinclude/linux/timekeeping.h kernel/time/timekeeping.c+42 -01 reply
2/9perf: Extend ABI to support post-processing monotonic raw conversioninclude/uapi/linux/perf_event.h kernel/events/core.c+25 -323 replies
3/9perf/x86: Factor out x86_pmu_sample_preload()arch/x86/events/amd/core.c arch/x86/events/core.c arch/x86/events/intel/core.c +2 more+12 -100 replies
4/9perf/x86: Enable post-processing monotonic raw conversionarch/x86/events/core.c arch/x86/events/intel/ds.c arch/x86/events/perf_event.h+33 -34 replies
5/9perf/x86/intel: Enable large PEBS for monotonic rawarch/x86/events/intel/core.c+2 -10 replies
6/9tools headers UAPI: Sync linux/perf_event.h with the kernel sourcestools/include/uapi/linux/perf_event.h+18 -30 replies
7/9perf session: Support the monotonic raw clock conversion informationtools/lib/perf/include/perf/event.h tools/perf/util/session.c tools/perf/util/tsc.c +1 more+42 -20 replies
8/9perf evsel, tsc: Support the monotonic raw clock conversiontools/perf/util/evlist.h tools/perf/util/evsel.c tools/perf/util/evsel.h +3 more+38 -20 replies
9/9perf evsel: Enable post-processing monotonic raw conversion by defaulttools/perf/util/evsel.c tools/perf/util/evsel.h tools/perf/util/perf_event_attr_fprintf.c+12 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [RFC PATCH V2 0/9] Convert TSC to monotonic raw clock for PEBS

From: Kan Liang <[email protected]>

Compared with V1, this patch series provides a different solution to address the conversion issue according to the feedback from Thomas and John.
- Support the monotonic raw clock rather than the monotonic clock. The monotonic raw clock is not affected by NTP/PTP correction. The conversion information can be used to calculate the time for large PEBS and do post-processing in perf tool.
- Support post-processing. Move the conversion to the user space perf tool.
Link to V1:
https://lore.kernel.org/lkml/[email protected]/

Motivation:
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 raw clock is required.

Solution:
Currently, the conversion of any clock id is done in the kernel. The patch series extends the existing ABI to dump both the raw HW time and the conversion information into the user space. The conversion will be done in the perf tool.

The extended ABI is shared among different ARCHs. But the patch series only implements the post-processing conversion on X86 platforms. For the other ARCHs, there is nothing changed. The post-processing conversion can be added later separately.

Only support the post-processing conversion for monotonic raw clock, since it is not affected by NTP/PTP correction.

With the patch series, on X86, the post-processing conversion is the default setting of perf tool for monotonic raw clock.

The patch series is on top of Peter's perf/core branch.

Kan Liang (9):
timekeeping: Expose the conversion information of monotonic raw
perf: Extend ABI to support post-processing monotonic raw conversion perf/x86: Factor out x86_pmu_sample_preload()
perf/x86: Enable post-processing monotonic raw conversion perf/x86/intel: Enable large PEBS for monotonic raw
tools headers UAPI: Sync linux/perf_event.h with the kernel sources perf session: Support the monotonic raw clock conversion information perf evsel, tsc: Support the monotonic raw clock conversion perf evsel: Enable post-processing monotonic raw conversion by default

 arch/x86/events/amd/core.c                |  3 +-
 arch/x86/events/core.c                    | 15 +++++++---
 arch/x86/events/intel/core.c              |  6 ++--
 arch/x86/events/intel/ds.c                | 15 +++++++---
 arch/x86/events/perf_event.h              | 20 +++++++++++++
 include/linux/timekeeping.h               | 18 ++++++++++++
 include/uapi/linux/perf_event.h           | 21 ++++++++++++--
 kernel/events/core.c                      |  7 +++++
 kernel/time/timekeeping.c                 | 24 ++++++++++++++++
 tools/include/uapi/linux/perf_event.h     | 21 ++++++++++++--
 tools/lib/perf/include/perf/event.h       |  8 +++++-
 tools/perf/util/evlist.h                  |  1 +
 tools/perf/util/evsel.c                   | 28 +++++++++++++++++--
 tools/perf/util/evsel.h                   |  8 ++++++
 tools/perf/util/perf_event_attr_fprintf.c |  1 +
 tools/perf/util/session.c                 |  9 ++++++
 tools/perf/util/tsc.c                     | 34 ++++++++++++++++++++++-
 tools/perf/util/tsc.h                     |  8 ++++++
 18 files changed, 223 insertions(+), 24 deletions(-)
Signature · 1 line
2.35.1