From: "Hall, Christopher S" <christopher.s.hall@intel.com>
To: "Hunter, Adrian" <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
Jiri Olsa <jolsa@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "Borislav Petkov" <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
H Peter Anvin <hpa@zytor.com>,
Mathieu Poirier <mathieu.poirier@linaro.org>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
"Leo Yan" <leo.yan@linaro.org>,
"jgross@suse.com" <jgross@suse.com>,
"sdeep@vmware.com" <sdeep@vmware.com>,
"pv-drivers@vmware.com" <pv-drivers@vmware.com>,
"pbonzini@redhat.com" <pbonzini@redhat.com>,
"seanjc@google.com" <seanjc@google.com>,
"kys@microsoft.com" <kys@microsoft.com>,
"sthemmin@microsoft.com" <sthemmin@microsoft.com>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"Andrew.Cooper3@citrix.com" <Andrew.Cooper3@citrix.com>
Subject: RE: [PATCH V2 03/11] perf/x86: Add support for TSC in nanoseconds as a perf event clock
Date: Tue, 8 Mar 2022 21:06:24 +0000 [thread overview]
Message-ID: <6f07a7d4e1ad4440bf6c502c8cb6c2ed@intel.com> (raw)
In-Reply-To: <013b5425-2a60-e4d4-b846-444a576f2b28@intel.com>
Adrian Hunter wrote:
> On 7.3.2022 16.42, Peter Zijlstra wrote:
> > On Mon, Mar 07, 2022 at 02:36:03PM +0200, Adrian Hunter wrote:
> >
> >>> diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
> >>> index 4420499f7bb4..a1f179ed39bf 100644
> >>> --- a/arch/x86/kernel/paravirt.c
> >>> +++ b/arch/x86/kernel/paravirt.c
> >>> @@ -145,6 +145,15 @@ DEFINE_STATIC_CALL(pv_sched_clock, native_sched_clock);
> >>>
> >>> void paravirt_set_sched_clock(u64 (*func)(void))
> >>> {
> >>> + /*
> >>> + * Anything with ART on promises to have sane TSC, otherwise the whole
> >>> + * ART thing is useless. In order to make ART useful for guests, we
> >>> + * should continue to use the TSC. As such, ignore any paravirt
> >>> + * muckery.
> >>> + */
> >>> + if (cpu_feature_enabled(X86_FEATURE_ART))
> >>
> >> Does not seem to work because the feature X86_FEATURE_ART does not seem to get set.
> >> Possibly because detect_art() excludes anything running on a hypervisor.
> >
> > Simple enough to delete that clause I suppose. Christopher, what is
> > needed to make that go away? I suppose the guest needs to be aware of
> > the active TSC scaling parameters to make it work ?
>
> There is also not X86_FEATURE_NONSTOP_TSC nor values for art_to_tsc_denominator
> or art_to_tsc_numerator. Also, from the VM's point of view, TSC will jump
> forwards every VM-Exit / VM-Entry unless the hypervisor changes the offset
> every VM-Entry, which KVM does not, so it still cannot be used as a stable
> clocksource.
Translating between ART and the guest TSC can be a difficult problem and ART software
support is disabled by default in a VM.
There are two major issues translating ART to TSC in a VM:
The range of the TSC scaling field in the VMCS is much larger than the range of values
that can be represented using CPUID[15H], i.e., it is not possible to communicate this
to the VM using the current CPUID interface. The range of scaling would need to be
restricted or another para-virtualized method - preferably OS/hypervisor agnostic - to
communicate the scaling factor to the guest needs to be invented.
TSC offsetting may also be a problem. The VMCS TSC offset must be discoverable by the
guest. This can be done via TSC_ADJUST MSR. The offset in the VMCS and the guest
TSC_ADJUST MSR must always be equivalent, i.e. a write to TSC_ADJUST in the guest
must be reflected in the VMCS and any changes to the offset in the VMCS must be
reflected in the TSC_ADJUST MSR. Otherwise a para-virtualized method must
be invented to communicate an arbitrary VMCS TSC offset to the guest.
next prev parent reply other threads:[~2022-03-08 21:06 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-14 11:09 [PATCH V2 00/11] perf intel-pt: Add perf event clocks to better support VM tracing Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 01/11] perf/x86: Fix native_perf_sched_clock_from_tsc() with __sched_clock_offset Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 02/11] perf/x86: Add support for TSC as a perf event clock Adrian Hunter
2022-03-04 12:30 ` Peter Zijlstra
2022-03-04 13:03 ` Adrian Hunter
2022-03-04 12:32 ` Peter Zijlstra
2022-03-04 17:51 ` Thomas Gleixner
2022-03-04 12:33 ` Peter Zijlstra
2022-03-04 12:41 ` Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 03/11] perf/x86: Add support for TSC in nanoseconds " Adrian Hunter
2022-03-04 13:41 ` Peter Zijlstra
2022-03-04 18:27 ` Adrian Hunter
2022-03-07 9:50 ` Peter Zijlstra
2022-03-07 9:50 ` Peter Zijlstra
2022-03-07 10:06 ` Juergen Gross via Virtualization
2022-03-07 10:06 ` Juergen Gross
2022-03-07 10:38 ` Peter Zijlstra
2022-03-07 10:38 ` Peter Zijlstra
2022-03-07 10:58 ` Juergen Gross via Virtualization
2022-03-07 10:58 ` Juergen Gross
2022-03-07 12:36 ` Adrian Hunter
2022-03-07 14:42 ` Peter Zijlstra
2022-03-07 14:42 ` Peter Zijlstra
2022-03-08 14:23 ` Adrian Hunter
2022-03-08 21:06 ` Hall, Christopher S [this message]
2022-03-14 11:50 ` Adrian Hunter
2022-04-25 5:30 ` Adrian Hunter
2022-04-25 9:32 ` Thomas Gleixner
2022-04-25 9:32 ` Thomas Gleixner
2022-04-25 13:15 ` Adrian Hunter
2022-04-25 17:05 ` Thomas Gleixner
2022-04-25 17:05 ` Thomas Gleixner
2022-04-26 6:51 ` Adrian Hunter
2022-04-27 23:10 ` Thomas Gleixner
2022-04-27 23:10 ` Thomas Gleixner
2022-05-16 7:20 ` Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 04/11] perf tools: Add new perf clock IDs Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 05/11] perf tools: Add API probes for new " Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 06/11] perf tools: Add new clock IDs to "perf time to TSC" test Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 07/11] perf tools: Add perf_read_tsc_conv_for_clockid() Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 08/11] perf intel-pt: Add support for new clock IDs Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 09/11] perf intel-pt: Use CLOCK_PERF_HW_CLOCK_NS by default Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 10/11] perf intel-pt: Add config variables for timing parameters Adrian Hunter
2022-02-14 11:09 ` [PATCH V2 11/11] perf intel-pt: Add documentation for new clock IDs Adrian Hunter
2022-02-21 6:54 ` [PATCH V2 00/11] perf intel-pt: Add perf event clocks to better support VM tracing Adrian Hunter
2022-03-01 11:06 ` Adrian Hunter
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=6f07a7d4e1ad4440bf6c502c8cb6c2ed@intel.com \
--to=christopher.s.hall@intel.com \
--cc=Andrew.Cooper3@citrix.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jolsa@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=kys@microsoft.com \
--cc=leo.yan@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=pv-drivers@vmware.com \
--cc=sdeep@vmware.com \
--cc=seanjc@google.com \
--cc=sthemmin@microsoft.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--cc=virtualization@lists.linux-foundation.org \
--cc=x86@kernel.org \
/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 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.