From: Thomas Gleixner <tglx@linutronix.de>
To: Rong Tao <rtoax@foxmail.com>
Cc: rtoax@foxmail.com, Rong Tao <rongtao@cestc.cn>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/vdso: Use non-serializing instruction rdtsc
Date: Tue, 16 May 2023 16:20:09 +0200 [thread overview]
Message-ID: <87ttwc73za.ffs@tglx> (raw)
In-Reply-To: <tencent_4DC4468312A1CB2CA34B0215FAD797D11F07@qq.com>
Rong!
On Tue, May 16 2023 at 14:52, Rong Tao wrote:
> Replacing rdtscp or 'lfence;rdtsc' with the non-serializable instruction
> rdtsc can achieve a 40% performance improvement with only a small loss of
> precision.
That rdtsc_ordered() is not there to achieve precision. It's there to
guarantee correctness. The correctness requirement is that reading clock
MONOTONIC is strictly monotonic, i.e. there is no way that you can
observe time going backwards. Neither locally nor accross CPUs.
As you explained:
> The RDTSC instruction is not a serializing instruction. It does not
> necessarily wait until all previous instructions have been executed
> before reading the counter.
Q: What guarantees that this does not speculate deep enough to actually
make time go backwards?
A: Nothing
Conclusion: The fence stays, unless you can prove the contrary under all
circumstances and microarchitecture generations.
Thanks,
tglx
next prev parent reply other threads:[~2023-05-16 14:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 6:52 [PATCH] x86/vdso: Use non-serializing instruction rdtsc Rong Tao
2023-05-16 14:12 ` Dave Hansen
2023-05-16 17:57 ` H. Peter Anvin
2023-05-16 20:39 ` Thomas Gleixner
2023-05-16 14:20 ` Thomas Gleixner [this message]
2023-05-16 21:53 ` Andy Lutomirski
2023-05-17 0:41 ` Rong Tao
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=87ttwc73za.ffs@tglx \
--to=tglx@linutronix.de \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rongtao@cestc.cn \
--cc=rtoax@foxmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox