From: Denys Vlasenko <dvlasenk@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@amacapital.net>
Cc: "Sara Sharon" <sara.sharon@intel.com>,
"Dan Williams" <dan.j.williams@intel.com>,
"Christian König" <christian.koenig@amd.com>,
"Vinod Koul" <vinod.koul@intel.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Johannes Berg" <johannes.berg@intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
"Andy Lutomirski" <luto@kernel.org>,
"the arch/x86 maintainers" <x86@kernel.org>,
"Ingo Molnar" <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Adrian Hunter" <adrian.hunter@intel.com>
Subject: Re: RFC: Petition Intel/AMD to add POPF_IF insn
Date: Thu, 18 Aug 2016 15:26:02 +0200 [thread overview]
Message-ID: <1686aa11-152d-9416-34dd-17820de7a7b6@redhat.com> (raw)
In-Reply-To: <CA+55aFyv2tj1YQH3Ga4oAkNEZgsT2+KmuU_MYqN0aUUtkBygrQ@mail.gmail.com>
> Of course, somebody really should do timings on modern CPU's (in cpl0,
> comparing native_fl() that enables interrupts with a popf)
I didn't do CPL0 tests yet. Realized that cli/sti can be tested in userspace
if we set iopl(3) first.
Surprisingly, STI is slower than CLI. A loop with 27 CLI's and one STI
converges to about ~0.5 insn/cycle:
# compile with: gcc -nostartfiles -nostdlib
_start: .globl _start
mov $172, %eax #iopl
mov $3, %edi
syscall
mov $200*1000*1000, %eax
.balign 64
loop:
cli;cli;cli;cli
cli;cli;cli;cli
cli;cli;cli;cli
cli;cli;cli;cli
cli;cli;cli;cli
cli;cli;cli;cli
cli;cli;cli;sti
dec %eax
jnz loop
mov $231, %eax #exit_group
syscall
perf stat:
6,015,787,968 instructions # 0.52 insn per cycle
3.355474199 seconds time elapsed
With all CLIs replaced by STIs, it's ~0.25 insn/cycle:
6,030,530,328 instructions # 0.27 insn per cycle
6.547200322 seconds time elapsed
POPF which needs to enable interrupts is not measurably faster than
one which does not change .IF:
Loop with:
400158: fa cli
400159: 53 push %rbx #saved eflags with if=1
40015a: 9d popfq
shows:
8,908,857,324 instructions # 0.11 insn per cycle ( +- 0.00% )
Loop with:
400140: fb sti
400141: 53 push %rbx
400142: 9d popfq
shows:
8,920,243,701 instructions # 0.10 insn per cycle ( +- 0.01% )
Even loop with neither CLI nor STI, only with POPF:
400140: 53 push %rbx
400141: 9d popfq
shows:
6,079,936,714 instructions # 0.10 insn per cycle ( +- 0.00% )
This is on a Skylake CPU.
The gist of it:
CLI is 2 cycles,
STI is 4 cycles,
POPF is 10 cycles
seemingly regardless of prior value of EFLAGS.IF.
next prev parent reply other threads:[~2016-08-18 13:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 17:20 Denys Vlasenko
2016-08-17 17:30 ` Christian König
2016-08-17 18:34 ` Denys Vlasenko
2016-08-17 17:32 ` Linus Torvalds
2016-08-17 18:41 ` Denys Vlasenko
[not found] ` <CA+55aFwmxwQBkyDjombS4cy1q=a_buhmDjDnaa8rdC8ZDaDYEA@mail.gmail.com>
2016-08-17 19:13 ` Andy Lutomirski
2016-08-17 19:26 ` Denys Vlasenko
2016-08-17 19:32 ` Linus Torvalds
2016-08-17 19:35 ` Denys Vlasenko
2016-08-17 19:54 ` Linus Torvalds
2016-08-17 19:37 ` Linus Torvalds
2016-08-17 21:26 ` Linus Torvalds
2016-08-17 21:35 ` Linus Torvalds
2016-08-17 21:43 ` Andy Lutomirski
2016-08-17 21:48 ` Linus Torvalds
2016-08-18 13:26 ` Denys Vlasenko [this message]
2016-08-18 17:24 ` Linus Torvalds
2016-08-18 17:47 ` Denys Vlasenko
2016-08-18 17:49 ` Denys Vlasenko
2016-08-19 10:54 ` Paolo Bonzini
2016-08-31 11:12 ` Denys Vlasenko
2016-08-18 9:21 ` Denys Vlasenko
2016-08-18 12:18 ` Denys Vlasenko
2016-08-18 17:22 ` Paolo Bonzini
2016-08-17 19:29 ` Linus Torvalds
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=1686aa11-152d-9416-34dd-17820de7a7b6@redhat.com \
--to=dvlasenk@redhat.com \
--cc=adrian.hunter@intel.com \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=dan.j.williams@intel.com \
--cc=johannes.berg@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=sara.sharon@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=vinod.koul@intel.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
all inboxes | Powered by JetHome®