From: "Andy Lutomirski" <luto@kernel.org>
To: "Rong Tao" <rtoax@foxmail.com>, "Thomas Gleixner" <tglx@linutronix.de>
Cc: "Rong Tao" <rongtao@cestc.cn>, "Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"the arch/x86 maintainers" <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/vdso: Use non-serializing instruction rdtsc
Date: Tue, 16 May 2023 14:53:24 -0700 [thread overview]
Message-ID: <6d2cf767-a5bb-4df4-bf9c-dcbf3bf82722@app.fastmail.com> (raw)
In-Reply-To: <tencent_4DC4468312A1CB2CA34B0215FAD797D11F07@qq.com>
On Mon, May 15, 2023, at 11:52 PM, Rong Tao wrote:
> From: Rong Tao <rongtao@cestc.cn>
>
> Replacing rdtscp or 'lfence;rdtsc' with the non-serializable instruction
> rdtsc can achieve a 40% performance improvement with only a small loss of
> precision.
>
> The RDTSCP instruction is not a serializing instruction, but it does wait
> until all previous instructions have executed and all previous loads are
> globally visible. The RDTSC instruction is not a serializing instruction.
> It does not necessarily wait until all previous instructions have been
> executed before reading the counter.
>
> Record the time-consuming of vdso clock_gettime(), pseudo code:
>
> count = 1000 * 1000 * 100;
> while (count--)
> clock_gettime(CLOCK_REALTIME, &ts);
>
> Time-consuming comparison:
>
> Time Consume(ns) | rdtsc_ordered() | rdtsc() | Promote
> ------------------+-----------------+-----------+---------
> Physical Machine | 1269147289 | 759067324 | 40%
> Guest OS (KVM) | 1756615963 | 995823886 | 43%
>
> Signed-off-by: Rong Tao <rongtao@cestc.cn>
Out of curiosity, what happens if you apply that patch and run this thing:
https://git.kernel.org/pub/scm/linux/kernel/git/luto/misc-tests.git/tree/evil-clock-test.cc
Build it with g++ -O2 and run:
./evil-clock-test -c monotonic
--Andy
next prev parent reply other threads:[~2023-05-16 21:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 6:52 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
2023-05-16 21:53 ` Andy Lutomirski [this message]
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=6d2cf767-a5bb-4df4-bf9c-dcbf3bf82722@app.fastmail.com \
--to=luto@kernel.org \
--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=tglx@linutronix.de \
--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
Powered by JetHome