public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: kan.liang@linux.intel.com
To: tglx@linutronix.de, jstultz@google.com, peterz@infradead.org,
	mingo@redhat.com, linux-kernel@vger.kernel.org
Cc: sboyd@kernel.org, eranian@google.com, namhyung@kernel.org,
	ak@linux.intel.com, adrian.hunter@intel.com,
	Kan Liang <kan.liang@linux.intel.com>
Subject: [RFC PATCH V2 0/9] Convert TSC to monotonic raw clock for PEBS
Date: Mon, 13 Feb 2023 11:07:45 -0800	[thread overview]
Message-ID: <20230213190754.1836051-1-kan.liang@linux.intel.com> (raw)

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

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/20230123182728.825519-1-kan.liang@linux.intel.com/

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(-)

-- 
2.35.1


             reply	other threads:[~2023-02-13 19:08 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 19:07 kan.liang [this message]
2023-02-13 19:07 ` [RFC PATCH V2 1/9] timekeeping: Expose the conversion information of monotonic raw kan.liang
2023-02-13 19:28   ` John Stultz
2023-02-13 19:07 ` [RFC PATCH V2 2/9] perf: Extend ABI to support post-processing monotonic raw conversion kan.liang
2023-02-13 19:37   ` John Stultz
2023-02-13 21:40     ` Liang, Kan
2023-02-13 22:22       ` John Stultz
2023-02-14 10:43         ` Peter Zijlstra
2023-02-14 17:46           ` Liang, Kan
2023-02-14 19:37             ` John Stultz
2023-02-14 20:09               ` Liang, Kan
2023-02-14 20:21                 ` John Stultz
2023-03-12 20:50                   ` Andi Kleen
2023-02-14 19:34           ` John Stultz
2023-02-14 14:51         ` Liang, Kan
2023-02-14 17:00           ` Liang, Kan
2023-02-14 20:11             ` John Stultz
2023-02-14 20:38               ` Liang, Kan
2023-02-17 23:11                 ` John Stultz
2023-03-08 18:44                   ` Liang, Kan
2023-03-09  1:17                     ` John Stultz
2023-03-09 16:56                       ` Liang, Kan
2023-03-11  5:55                         ` John Stultz
2023-03-13 21:19                           ` Liang, Kan
2023-03-18  6:02                             ` John Stultz
2023-03-21 15:26                               ` Liang, Kan
2023-02-14 19:52           ` John Stultz
2023-02-13 19:07 ` [RFC PATCH V2 3/9] perf/x86: Factor out x86_pmu_sample_preload() kan.liang
2023-02-13 19:07 ` [RFC PATCH V2 4/9] perf/x86: Enable post-processing monotonic raw conversion kan.liang
2023-02-14 20:02   ` Thomas Gleixner
2023-02-14 20:21     ` Liang, Kan
2023-02-14 20:55       ` Thomas Gleixner
2023-03-21 15:38         ` Liang, Kan
2023-02-13 19:07 ` [RFC PATCH V2 5/9] perf/x86/intel: Enable large PEBS for monotonic raw kan.liang
2023-02-13 19:07 ` [RFC PATCH V2 6/9] tools headers UAPI: Sync linux/perf_event.h with the kernel sources kan.liang
2023-02-13 19:07 ` [RFC PATCH V2 7/9] perf session: Support the monotonic raw clock conversion information kan.liang
2023-02-13 19:07 ` [RFC PATCH V2 8/9] perf evsel, tsc: Support the monotonic raw clock conversion kan.liang
2023-02-13 19:07 ` [RFC PATCH V2 9/9] perf evsel: Enable post-processing monotonic raw conversion by default kan.liang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230213190754.1836051-1-kan.liang@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.com \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sboyd@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox