From: Borislav Petkov <bp@alien8.de>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, x86@kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 12/29] x86, tsx: Add a per thread transaction disable count
Date: Sat, 23 Mar 2013 16:52:56 +0100 [thread overview]
Message-ID: <20130323155256.GB10811@pd.tnic> (raw)
In-Reply-To: <20130323135156.GJ20853@two.firstfloor.org>
On Sat, Mar 23, 2013 at 02:51:56PM +0100, Andi Kleen wrote:
> Bit fields are slower and larger in code and unlike the others this is
> on hot paths.
Really? Let's see:
unsigned:
=========
.file 8 "/w/kernel/linux-2.6/arch/x86/include/asm/thread_info.h"
.loc 8 211 0
#APP
# 211 "/w/kernel/linux-2.6/arch/x86/include/asm/thread_info.h" 1
movq %gs:kernel_stack,%rax #, pfo_ret__
# 0 "" 2
.LVL238:
#NO_APP
... # AMD F10h SNB
disable:
incl -8056(%rax) # ti_25->notxn # INC mem: 4 ; 6
test:
cmpl $0, -8056(%rax) #, ti_24->notxn # CMP mem, imm: 4 ; 1
reenable:
decl -8056(%rax) # ti_25->notxn # DEC mem: 4 ; 6
bitfield:
=========
.file 8 "/w/kernel/linux-2.6/arch/x86/include/asm/thread_info.h"
.loc 8 211 0
#APP
# 211 "/w/kernel/linux-2.6/arch/x86/include/asm/thread_info.h" 1
movq %gs:kernel_stack,%rax #, pfo_ret__
# 0 "" 2
.LVL238:
#NO_APP
disable:
xorb $4, -8056(%rax) #, # XOR mem, imm: 1 ; 0
test:
testb $4, -8056(%rax) #, # TEST mem, imm: 4 ; -
reenable:
xorb $4, -8056(%rax) #, # XOR mem, imm: 1 ; 0
So let's explain. The AMD F10h column shows the respective instruction
latencies on AMD F10h. All instructions are DirectPath single.
The SNB column is something similar which I could find for Intel
Sandybridge: http://www.agner.org/optimize/instruction_tables.pdf. I'm
assuming Agner Fog's measurements are more or less accurate.
And wow, the XOR is *actually* faster. That's whopping three cycles on
AMD. Similar observation on SNB.
Now let's look at decoding bandwidth:
unsigned:
=========
disable:
13: ff 80 88 e0 ff ff incl -0x1f78(%rax)
test:
9: 83 b8 88 e0 ff ff 00 cmpl $0x0,-0x1f78(%rax)
reenable:
13: ff 88 88 e0 ff ff decl -0x1f78(%rax)
bitfield:
=========
disable:
13: 80 b0 88 e0 ff ff 04 xorb $0x4,-0x1f78(%rax)
test:
9: f6 80 88 e0 ff ff 04 testb $0x4,-0x1f78(%rax)
reenable:
13: 80 b0 88 e0 ff ff 04 xorb $0x4,-0x1f78(%rax)
This particular XOR encoding is 1 byte longer, the rest is on-par.
Oh, and compiler is gcc (Debian 4.7.2-5) 4.7.2.
So you were saying?
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2013-03-23 15:53 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 1:24 RFC: Kernel lock elision for TSX Andi Kleen
2013-03-23 1:24 ` [PATCH 01/29] tsx: Add generic noop macros for RTM intrinsics Andi Kleen
2013-03-25 3:39 ` Michael Neuling
2013-03-25 8:19 ` Andi Kleen
2013-03-25 8:50 ` Michael Neuling
2013-03-23 1:24 ` [PATCH 02/29] x86, tsx: Add " Andi Kleen
2013-03-25 3:40 ` Michael Neuling
2013-03-25 8:15 ` Andi Kleen
2013-03-25 8:54 ` Michael Neuling
2013-03-25 9:32 ` Andi Kleen
2013-03-23 1:24 ` [PATCH 03/29] tsx: Add generic disable_txn macros Andi Kleen
2013-03-23 1:24 ` [PATCH 04/29] tsx: Add generic linux/elide.h macros Andi Kleen
2013-03-23 1:24 ` [PATCH 05/29] x86, tsx: Add a minimal RTM tester at bootup Andi Kleen
2013-03-23 1:25 ` [PATCH 06/29] checkpatch: Don't warn about if ((status = _xbegin()) == _XBEGIN_STARTED) Andi Kleen
2013-03-25 3:39 ` Michael Neuling
2013-03-23 1:25 ` [PATCH 07/29] x86, tsx: Don't abort immediately in __read/write_lock_failed Andi Kleen
2013-03-23 1:25 ` [PATCH 08/29] locking, tsx: Add support for arch_read/write_unlock_irq/flags Andi Kleen
2013-03-23 1:25 ` [PATCH 09/29] x86, xen: Support arch_spin_unlock_irq/flags Andi Kleen
2013-03-23 1:25 ` [PATCH 10/29] locking, tsx: Add support for arch_spin_unlock_irq/flags Andi Kleen
2013-03-23 1:25 ` [PATCH 11/29] x86, paravirt: Add support for arch_spin_unlock_flags/irq Andi Kleen
2013-03-23 1:25 ` [PATCH 12/29] x86, tsx: Add a per thread transaction disable count Andi Kleen
2013-03-23 11:51 ` Borislav Petkov
2013-03-23 13:51 ` Andi Kleen
2013-03-23 15:52 ` Borislav Petkov [this message]
2013-03-23 16:25 ` Borislav Petkov
2013-03-23 17:16 ` Linus Torvalds
2013-03-23 17:32 ` Borislav Petkov
2013-03-23 18:01 ` Andi Kleen
2013-03-23 1:25 ` [PATCH 13/29] params: Add a per cpu module param type Andi Kleen
2013-03-23 1:25 ` [PATCH 14/29] params: Add static key module param Andi Kleen
2013-03-23 1:25 ` [PATCH 15/29] x86, tsx: Add TSX lock elision infrastructure Andi Kleen
2013-03-23 1:25 ` [PATCH 16/29] locking, tsx: Allow architecture to control mutex fast path owner field Andi Kleen
2013-03-23 1:25 ` [PATCH 17/29] x86, tsx: Enable lock elision for mutexes Andi Kleen
2013-03-23 1:25 ` [PATCH 18/29] locking, tsx: Abort is mutex_is_locked() Andi Kleen
2013-03-23 1:25 ` [PATCH 19/29] x86, tsx: Add support for rwsem elision Andi Kleen
2013-03-23 1:25 ` [PATCH 20/29] x86, tsx: Enable elision for read write spinlocks Andi Kleen
2013-03-23 1:25 ` [PATCH 21/29] locking, tsx: Protect assert_spin_locked() with _xtest() Andi Kleen
2013-03-23 1:25 ` [PATCH 22/29] locking, tsx: Add a trace point for elision skipping Andi Kleen
2013-03-23 1:25 ` [PATCH 23/29] x86, tsx: Add generic per-lock adaptive lock elision support Andi Kleen
2013-03-23 1:25 ` [PATCH 24/29] x86, tsx: Use adaptive elision for mutexes Andi Kleen
2013-03-23 1:25 ` [PATCH 25/29] x86, tsx: Add adaption support for spinlocks Andi Kleen
2013-03-23 1:25 ` [PATCH 26/29] x86, tsx: Add adaptation support to rw spinlocks Andi Kleen
2013-03-23 1:25 ` [PATCH 27/29] locking, tsx: Add elision to bit spinlocks Andi Kleen
2013-03-23 1:25 ` [PATCH 28/29] x86, tsx: Add adaptive elision for rwsems Andi Kleen
2013-03-23 1:25 ` [PATCH 29/29] tsx: Add documentation for lock-elision Andi Kleen
2013-03-23 17:11 ` RFC: Kernel lock elision for TSX Linus Torvalds
2013-03-23 18:00 ` Andi Kleen
2013-03-23 18:02 ` Andi Kleen
2013-03-24 14:17 ` Benjamin Herrenschmidt
2013-03-25 0:59 ` Michael Neuling
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=20130323155256.GB10811@pd.tnic \
--to=bp@alien8.de \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@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 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®