From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [087/139] x86-64: support native xadd rwsem implementation
Date: Thu, 22 Apr 2010 12:54:24 -0700 [thread overview]
Message-ID: <20100422195413.763850312@kvm.kroah.org> (raw)
In-Reply-To: <20100422195715.GA25490@kroah.com>
2.6.33-stable review patch. If anyone has any objections, please let us know.
------------------
From: Linus Torvalds <torvalds@linux-foundation.org>
commit bafaecd11df15ad5b1e598adc7736afcd38ee13d upstream.
This one is much faster than the spinlock based fallback rwsem code,
with certain artifical benchmarks having shown 300%+ improvement on
threaded page faults etc.
Again, note the 32767-thread limit here. So this really does need that
whole "make rwsem_count_t be 64-bit and fix the BIAS values to match"
extension on top of it, but that is conceptually a totally independent
issue.
NOT TESTED! The original patch that this all was based on were tested by
KAMEZAWA Hiroyuki, but maybe I screwed up something when I created the
cleaned-up series, so caveat emptor..
Also note that it _may_ be a good idea to mark some more registers
clobbered on x86-64 in the inline asms instead of saving/restoring them.
They are inline functions, but they are only used in places where there
are not a lot of live registers _anyway_, so doing for example the
clobbers of %r8-%r11 in the asm wouldn't make the fast-path code any
worse, and would make the slow-path code smaller.
(Not that the slow-path really matters to that degree. Saving a few
unnecessary registers is the _least_ of our problems when we hit the slow
path. The instruction/cycle counting really only matters in the fast
path).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <alpine.LFD.2.00.1001121810410.17145@localhost.localdomain>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/x86/Kconfig.cpu | 2 -
arch/x86/lib/Makefile | 1
arch/x86/lib/rwsem_64.S | 81 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 83 insertions(+), 1 deletion(-)
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -319,7 +319,7 @@ config X86_L1_CACHE_SHIFT
config X86_XADD
def_bool y
- depends on X86_32 && !M386
+ depends on X86_64 || !M386
config X86_PPRO_FENCE
bool "PentiumPro memory ordering errata workaround"
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -39,4 +39,5 @@ else
lib-y += thunk_64.o clear_page_64.o copy_page_64.o
lib-y += memmove_64.o memset_64.o
lib-y += copy_user_64.o rwlock_64.o copy_user_nocache_64.o
+ lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem_64.o
endif
--- /dev/null
+++ b/arch/x86/lib/rwsem_64.S
@@ -0,0 +1,81 @@
+/*
+ * x86-64 rwsem wrappers
+ *
+ * This interfaces the inline asm code to the slow-path
+ * C routines. We need to save the call-clobbered regs
+ * that the asm does not mark as clobbered, and move the
+ * argument from %rax to %rdi.
+ *
+ * NOTE! We don't need to save %rax, because the functions
+ * will always return the semaphore pointer in %rax (which
+ * is also the input argument to these helpers)
+ *
+ * The following can clobber %rdx because the asm clobbers it:
+ * call_rwsem_down_write_failed
+ * call_rwsem_wake
+ * but %rdi, %rsi, %rcx, %r8-r11 always need saving.
+ */
+
+#include <linux/linkage.h>
+#include <asm/rwlock.h>
+#include <asm/alternative-asm.h>
+#include <asm/frame.h>
+#include <asm/dwarf2.h>
+
+#define save_common_regs \
+ pushq %rdi; \
+ pushq %rsi; \
+ pushq %rcx; \
+ pushq %r8; \
+ pushq %r9; \
+ pushq %r10; \
+ pushq %r11
+
+#define restore_common_regs \
+ popq %r11; \
+ popq %r10; \
+ popq %r9; \
+ popq %r8; \
+ popq %rcx; \
+ popq %rsi; \
+ popq %rdi
+
+/* Fix up special calling conventions */
+ENTRY(call_rwsem_down_read_failed)
+ save_common_regs
+ pushq %rdx
+ movq %rax,%rdi
+ call rwsem_down_read_failed
+ popq %rdx
+ restore_common_regs
+ ret
+ ENDPROC(call_rwsem_down_read_failed)
+
+ENTRY(call_rwsem_down_write_failed)
+ save_common_regs
+ movq %rax,%rdi
+ call rwsem_down_write_failed
+ restore_common_regs
+ ret
+ ENDPROC(call_rwsem_down_write_failed)
+
+ENTRY(call_rwsem_wake)
+ decw %dx /* do nothing if still outstanding active readers */
+ jnz 1f
+ save_common_regs
+ movq %rax,%rdi
+ call rwsem_wake
+ restore_common_regs
+1: ret
+ ENDPROC(call_rwsem_wake)
+
+/* Fix up special calling conventions */
+ENTRY(call_rwsem_downgrade_wake)
+ save_common_regs
+ pushq %rdx
+ movq %rax,%rdi
+ call rwsem_downgrade_wake
+ popq %rdx
+ restore_common_regs
+ ret
+ ENDPROC(call_rwsem_downgrade_wake)
next prev parent reply other threads:[~2010-04-22 20:01 UTC|newest]
Thread overview: 142+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 19:57 [000/139] 2.6.33.3-stable review Greg KH
2010-04-22 19:52 ` [001/139] drm/edid: allow certain bogus edids to hit a fixup path rather than fail Greg KH
2010-04-22 19:52 ` [002/139] drm/radeon: add new RS880 pci id Greg KH
2010-04-22 19:53 ` [003/139] drm: remove the EDID blob stored in the EDID property when it is disconnected Greg KH
2010-04-22 19:53 ` [004/139] fat: fix buffer overflow in vfat_create_shortname() Greg KH
2010-04-22 19:53 ` [005/139] oom: fix the unsafe usage of badness() in proc_oom_score() Greg KH
2010-04-22 19:53 ` [006/139] drm/radeon/kms: never treat rs4xx as AGP Greg KH
2010-04-22 19:53 ` [007/139] drm/radeon/kms: Fix NULL pointer dereference if memory allocation failed in a simple way Greg KH
2010-04-22 19:53 ` [008/139] drm/radeon/kms: dont print error on -ERESTARTSYS Greg KH
2010-04-22 19:53 ` [009/139] drm/radeon/kms: fix pal tv-out support on legacy IGP chips Greg KH
2010-04-22 19:53 ` [010/139] drm: Return ENODEV if the inode mapping changes Greg KH
2010-04-22 19:53 ` [011/139] sh: Fix FDPIC binary loader Greg KH
2010-04-22 19:53 ` [012/139] sh: Enable the mmu in start_secondary() Greg KH
2010-04-22 19:53 ` [013/139] reiserfs: Fix locking BUG during mount failure Greg KH
2010-04-22 19:53 ` [014/139] [SCSI] libiscsi: Fix recovery slowdown regression Greg KH
2010-04-22 19:53 ` [015/139] x86,kgdb: Always initialize the hw breakpoint attribute Greg KH
2010-04-22 19:53 ` [016/139] Freezer: Fix buggy resume test for tasks frozen with cgroup freezer Greg KH
2010-04-22 19:53 ` [017/139] iwlwifi: fix regulatory Greg KH
2010-04-22 19:53 ` [018/139] iwlwifi: counting number of tfds can be free for 4965 Greg KH
2010-04-22 19:53 ` [019/139] iwlwifi: range checking issue Greg KH
2010-04-22 19:53 ` [020/139] setup correct int pipe type in ar9170_usb_exec_cmd Greg KH
2010-04-22 19:53 ` [021/139] mac80211: fix PREQ processing and one small bug Greg KH
2010-04-22 19:53 ` [022/139] mac80211: move netdev queue enabling to correct spot Greg KH
2010-04-22 19:53 ` [023/139] mac80211: tear down all agg queues when restart/reconfig hw Greg KH
2010-04-22 19:53 ` [024/139] sparc: Fix regset register window handling Greg KH
2010-04-22 19:53 ` [025/139] sunxvr500: Ignore secondary output PCI devices Greg KH
2010-04-22 19:53 ` [026/139] WATCHDOG: hpwdt - fix lower timeout limit Greg KH
2010-04-22 19:53 ` [027/139] WATCHDOG: iTCO_wdt: TCO Watchdog patch for additional Intel Cougar Point DeviceIDs Greg KH
2010-04-22 19:53 ` [028/139] genirq: Force MSI irq handlers to run with interrupts disabled Greg KH
2010-04-22 19:53 ` [029/139] tty: release_one_tty() forgets to put pids Greg KH
2010-04-22 19:53 ` [030/139] HID: fix oops in gyration_event() Greg KH
2010-04-22 19:53 ` [031/139] raw: fsync method is now required Greg KH
2010-04-22 19:53 ` [032/139] readahead: fix NULL filp dereference Greg KH
2010-04-22 19:53 ` [033/139] include/linux/kfifo.h: fix INIT_KFIFO() Greg KH
2010-04-22 19:53 ` [034/139] ALSA: mixart: range checking proc file Greg KH
2010-04-22 19:53 ` [035/139] ALSA: hda: Fix 0 dB offset for Lenovo Thinkpad models using AD1981 Greg KH
2010-04-22 19:53 ` [036/139] ALSA: hda - Add ASRock mobo to MSI blacklist Greg KH
2010-04-22 19:53 ` [037/139] ALSA: hda - Add MSI blacklist for Aopen MZ915-M Greg KH
2010-04-22 19:53 ` [038/139] backlight: mbp_nvidia_bl - add five more MacBook variants Greg KH
2010-04-22 19:53 ` [039/139] pata_via: Add VIA VX900 support Greg KH
2010-04-22 19:53 ` [040/139] libata: disable NCQ on Crucial C300 SSD Greg KH
2010-04-22 19:53 ` [041/139] [S390] s390: disable change bit override Greg KH
2010-04-22 19:53 ` [042/139] cifs: Fix a kernel BUG with remote OS/2 server (try #3) Greg KH
2010-04-22 19:53 ` [043/139] CIFS: initialize nbytes at the beginning of CIFSSMBWrite() Greg KH
2010-04-22 19:53 ` [044/139] ath9k: fix double calls to ath_radio_enable Greg KH
2010-04-22 19:53 ` [045/139] iwlwifi: need check for valid qos packet before free Greg KH
2010-04-22 19:53 ` [046/139] mac80211: Handle mesh action frames in ieee80211_rx_h_action Greg KH
2010-04-22 19:53 ` [047/139] ARM: 6031/1: fix Thumb-2 decompressor Greg KH
2010-04-22 19:53 ` [048/139] drm/edid/quirks: Envision EN2028 Greg KH
2010-04-22 19:53 ` [049/139] drm/radeon: R300 AD only has one quad pipe Greg KH
2010-04-22 19:53 ` [050/139] drm/radeon/kms: fix washed out image on legacy tv dac Greg KH
2010-04-22 19:53 ` [051/139] drm/radeon/kms/combios: verify dac_adj values are valid Greg KH
2010-04-22 19:53 ` [052/139] x86-32, resume: do a global tlb flush in S4 resume Greg KH
2010-04-22 19:53 ` [053/139] x86: Handle overlapping mptables Greg KH
2010-04-22 19:53 ` [054/139] x86, hpet: Erratum workaround for read after write of HPET comparator Greg KH
2010-04-22 19:53 ` [055/139] x86: Fix double enable_IR_x2apic() call on SMP kernel on !SMP boards Greg KH
2010-04-22 19:53 ` [056/139] sched: sched_getaffinity(): Allow less than NR_CPUS length Greg KH
2010-04-22 19:53 ` [057/139] sched: Fix sched_getaffinity() Greg KH
2010-04-22 19:53 ` [058/139] NFSv4: Fall back to ordinary lookup if nfs4_atomic_open() returns EISDIR Greg KH
2010-04-22 19:53 ` [059/139] NFSv4: fix delegated locking Greg KH
2010-04-22 19:53 ` [060/139] Input: wacom - switch mode upon system resume Greg KH
2010-04-22 19:53 ` [061/139] Input: sparse-keymap - free the right keymap on error Greg KH
2010-04-22 19:53 ` [062/139] ALSA: hda - add a quirk for Clevo M570U laptop Greg KH
2010-04-22 19:54 ` [063/139] ALSA: usb - Fix Oops after usb-midi disconnection Greg KH
2010-04-22 19:54 ` [064/139] hwmon: (sht15) Fix sht15_calc_temp interpolation function Greg KH
2010-04-22 19:54 ` [065/139] hwmon: (sht15) Properly handle the case CONFIG_REGULATOR=n Greg KH
2010-04-22 19:54 ` [066/139] drm/i915: Add no_lvds entry for the Clientron U800 Greg KH
2010-04-22 19:54 ` [067/139] drm/radeon/kms: more atom parser fixes (v2) Greg KH
2010-04-22 19:54 ` [068/139] drm/radeon/kms: disable the tv encoder when tv/cv is not in use Greg KH
2010-04-22 19:54 ` [069/139] drm/radeon/kms: fix tv dac conflict resolver Greg KH
2010-04-22 19:54 ` [070/139] drm/radeon/kms: fix rs600 tlb flush Greg KH
2010-04-22 19:54 ` [071/139] drm/radeon/kms: add FireMV 2400 PCI ID Greg KH
2010-04-22 19:54 ` [072/139] x86/amd-iommu: Pt mode fix for domain_destroy Greg KH
2010-04-22 19:54 ` [073/139] x86/amd-iommu: Use helper function to destroy domain Greg KH
2010-04-22 19:54 ` [074/139] x86/amd-iommu: enable iommu before attaching devices Greg KH
2010-04-22 19:54 ` [075/139] Revert "x86: disable IOMMUs on kernel crash" Greg KH
2010-04-22 19:54 ` [076/139] x86, lib: Add wbinvd smp helpers Greg KH
2010-04-22 19:54 ` [077/139] x86, cacheinfo: Fix disabling of L3 cache indices Greg KH
2010-04-22 19:54 ` [078/139] intel-agp: Switch to wbinvd_on_all_cpus Greg KH
2010-04-22 19:54 ` [079/139] x86, cacheinfo: Add cache index disable sysfs attrs only to L3 caches Greg KH
2010-04-22 19:54 ` [080/139] x86, cacheinfo: Calculate L3 indices Greg KH
2010-04-22 19:54 ` [081/139] x86, cacheinfo: Remove NUMA dependency, fix for AMD Fam10h rev D1 Greg KH
2010-04-22 19:54 ` [082/139] x86, cacheinfo: Enable L3 CID only on AMD Greg KH
2010-04-22 19:54 ` [083/139] dm ioctl: introduce flag indicating uevent was generated Greg KH
2010-04-22 19:54 ` [084/139] x86-32: clean up rwsem inline asm statements Greg KH
2010-04-22 19:54 ` [085/139] x86: clean up rwsem type system Greg KH
2010-04-22 19:54 ` [086/139] x86-64, rwsem: 64-bit xadd rwsem implementation Greg KH
2010-04-22 19:54 ` Greg KH [this message]
2010-04-22 19:54 ` [088/139] x86: Fix breakage of UML from the changes in the rwsem system Greg KH
2010-04-22 19:54 ` [089/139] x86-64, rwsem: Avoid store forwarding hazard in __downgrade_write Greg KH
2010-04-22 19:54 ` [090/139] fix NFS4 handling of mountpoint stat Greg KH
2010-04-22 19:54 ` [091/139] quota: Fix possible dq_flags corruption Greg KH
2010-04-22 19:54 ` [092/139] ocfs2: set i_mode on disk during acl operations Greg KH
2010-04-22 19:54 ` [093/139] ocfs2: Change bg_chain check for ocfs2_validate_gd_parent Greg KH
2010-04-22 19:54 ` [094/139] 9p: Skip check for mandatory locks when unlocking Greg KH
2010-04-22 19:54 ` [095/139] pci: Update pci_set_vga_state() to call arch functions Greg KH
2010-04-22 19:54 ` [096/139] PCI: kill off pci_register_set_vga_state() symbol export Greg KH
2010-04-22 19:54 ` [097/139] IPoIB: Fix TX queue lockup with mixed UD/CM traffic Greg KH
2010-04-22 19:54 ` [098/139] x86/PCI: irq and pci_ids patch for Intel Cougar Point DeviceIDs Greg KH
2010-04-22 19:54 ` [099/139] ALSA: hda_intel: ALSA HD Audio " Greg KH
2010-04-22 19:54 ` [100/139] ALSA: hda - enable snoop for Intel Cougar Point Greg KH
2010-04-22 19:54 ` [101/139] ata_piix: IDE Mode SATA patch for Intel Cougar Point DeviceIDs Greg KH
2010-04-22 19:54 ` [102/139] ahci: AHCI and RAID mode " Greg KH
2010-04-22 19:54 ` [103/139] i2c-i801: Add Intel Cougar Point device IDs Greg KH
2010-04-22 19:54 ` [104/139] b43: Allow PIO mode to be selected at module load Greg KH
2010-04-22 19:54 ` [105/139] b43: fall back gracefully to PIO mode after fatal DMA errors Greg KH
2010-04-22 19:54 ` [106/139] ALSA: hda - Add position_fix quirk for Biostar mobo Greg KH
2010-04-22 19:54 ` [107/139] ecryptfs: fix use with tmpfs by removing d_drop from ecryptfs_destroy_inode Greg KH
2010-04-22 19:54 ` [108/139] eCryptfs: Decrypt symlink target for stat size Greg KH
2010-04-22 19:54 ` [109/139] ecryptfs: fix error code for missing xattrs in lower fs Greg KH
2010-04-22 19:54 ` [110/139] USB: cdc-acm: Update to new autopm API Greg KH
2010-04-22 19:54 ` [111/139] USB: cdc-acm: Fix stupid NULL pointer in resume() Greg KH
2010-04-22 19:54 ` [112/139] iwlwifi: clear all tx queues when firmware ready Greg KH
2010-04-22 19:54 ` [113/139] iwlwifi: fix scan race Greg KH
2010-04-22 19:54 ` [114/139] e1000e: stop cleaning when we reach tx_ring->next_to_use Greg KH
2010-04-22 19:54 ` [115/139] perf_events, x86: Implement Intel Westmere/Nehalem-EX support Greg KH
2010-04-22 19:54 ` [116/139] xfs: Non-blocking inode locking in IO completion Greg KH
2010-04-22 19:54 ` [117/139] xfs: fix locking for inode cache radix tree tag updates Greg KH
2010-04-22 19:54 ` [118/139] xfs: check for more work before sleeping in xfssyncd Greg KH
2010-04-22 19:54 ` [119/139] ACPI: EC: Allow multibyte access to EC Greg KH
2010-04-22 19:54 ` [120/139] md/raid5: allow for more than 2^31 chunks Greg KH
2010-04-22 19:54 ` [121/139] ACPI: EC: Limit burst to 64 bits Greg KH
2010-04-22 19:54 ` [122/139] modules: fix incorrect percpu usage Greg KH
2010-04-22 19:55 ` [123/139] lockdep: " Greg KH
2010-04-22 19:55 ` [124/139] module: fix __module_ref_addr() Greg KH
2010-04-22 19:55 ` [125/139] md: deal with merge_bvec_fn in component devices better Greg KH
2010-04-22 19:55 ` [126/139] powerpc: Fix SMP build with disabled CPU hotplugging Greg KH
2010-04-22 19:55 ` [127/139] ext4: fix async i/o writes beyond 4GB to a sparse file Greg KH
2010-04-22 19:55 ` [128/139] sched: Use proper type in sched_getaffinity() Greg KH
2010-04-22 19:55 ` [129/139] KVM: VMX: Update instruction length on intercepted BP Greg KH
2010-04-22 19:55 ` [130/139] KVM: SVM: Fix memory leaks that happen when svm_create_vcpu() fails Greg KH
2010-04-22 19:55 ` [131/139] KVM: Dont spam kernel log when injecting exceptions due to bad cr writes Greg KH
2010-04-22 19:55 ` [132/139] KVM: allow bit 10 to be cleared in MSR_IA32_MC4_CTL Greg KH
2010-04-22 19:55 ` [133/139] KVM: VMX: Save/restore rflags.vm correctly in real mode Greg KH
2010-04-22 19:55 ` [134/139] KVM: MMU: fix kvm_mmu_zap_page() and its calling path Greg KH
2010-04-22 19:55 ` [135/139] KVM: fix the handling of dirty bitmaps to avoid overflows Greg KH
2010-04-22 19:55 ` [136/139] KVM: Increase NR_IOBUS_DEVS limit to 200 Greg KH
2010-04-22 19:55 ` [137/139] KVM: x86: Fix TSS size check for 16-bit tasks Greg KH
2010-04-22 19:55 ` [138/139] x86/gart: Disable GART explicitly before initialization Greg KH
2010-04-22 19:55 ` [139/139] MIPS: Sibyte: Fix M3 TLB exception handler workaround Greg KH
2010-04-22 20:52 ` Sebastian Andrzej Siewior
2010-04-23 16:23 ` [stable] [000/139] 2.6.33.3-stable review Greg KH
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=20100422195413.763850312@kvm.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable-review@kernel.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.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®