login
Login
/
Register
Search
Header Space
Forums
News
Jobs
Blogs
Features
Man Pages
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
March
»
27
Re: What if a TLB flush needed to sleep?
view
thread
Score:
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
[view in full thread]
From:
Jens Axboe <jens.axboe@...>
To: Luck, Tony <tony.luck@...>
Cc: Matthew Wilcox <matthew@...>, <linux-arch@...>, <linux-mm@...>, <linux-kernel@...>
Subject:
Re: What if a TLB flush needed to sleep?
Date: Thursday, March 27, 2008 - 4:09 am
On Wed, Mar 26 2008, Luck, Tony wrote:
quoted text
> > Of course, someone who wrote it could do better ;-) > > Here is Willy's code in patch format (against linux-next > tree tag next-20080326 which includes his re-write of the > semaphore code). > > This looks a lot cleaner than my ia64 specific code that > used cmpxchg() for the down() operation and fetchadd for > the up() ... using a brand new semaphore_spin data type. > > It appears to work ... I tried to do some timing comparisons > of this generic version against my arch specific one, but the > hackbench test case has a run to run variation of a factor of > three (from 1min9sec to 3min44sec) so it is hopeless to try > and see some small percentage difference. > > commit 0359fbb64297d44328f26ec5fda3a3c26f1c5ba7 > Author: Matthew Wilcox <matthew@wil.cx> > Date: Wed Mar 26 11:08:18 2008 -0700 > > Add "down_spin()" API for semaphores > > For those places that need semaphore semantics but cannot sleep > > Signed-off-by: Tony Luck <tony.luck@intel.com> > > diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h > index a7125da..3404ce5 100644 > --- a/include/linux/semaphore.h > +++ b/include/linux/semaphore.h > @@ -53,6 +53,12 @@ static inline void sema_init(struct semaphore *sem, int val) > extern void down(struct semaphore *sem); > > /* > + * Attempt to acquire the semaphore. If another task is already holding the > + * semaphore, spin until the semaphore is released. > + */ > +extern void down_spin(struct semaphore *sem); > + > +/* > * As down(), except the sleep may be interrupted by a signal. If it is, > * this function will return -EINTR. > */ > diff --git a/kernel/semaphore.c b/kernel/semaphore.c > index bef977b..d3eb559 100644 > --- a/kernel/semaphore.c > +++ b/kernel/semaphore.c > @@ -23,6 +23,7 @@ > */ > > static noinline void __down(struct semaphore *sem); > +static noinline void __down_spin(struct semaphore *sem); > static noinline int __down_interruptible(struct semaphore *sem); > static noinline int __down_killable(struct semaphore *sem); > static noinline int __down_timeout(struct semaphore *sem, long jiffies); > @@ -41,6 +42,21 @@ void down(struct semaphore *sem) > } > EXPORT_SYMBOL(down); > > +void down_spin(struct semaphore *sem) > +{ > + unsigned long flags; > + int count; > + > + spin_lock_irqsave(&sem->lock, flags); > + count = sem->count - 1; > + if (likely(count >= 0)) > + sem->count = count; > + else > + __down_spin(sem); > + spin_unlock_irqrestore(&sem->lock, flags); > +} > +EXPORT_SYMBOL(down_spin); > + > int down_interruptible(struct semaphore *sem) > { > unsigned long flags; > @@ -197,6 +213,20 @@ static noinline int __sched __down_timeout(struct semaphore *sem, long jiffies) > return __down_common(sem, TASK_UNINTERRUPTIBLE, jiffies); > } > > +static noinline void __sched __down_spin(struct semaphore *sem) > +{ > + struct semaphore_waiter waiter; > + > + list_add_tail(&waiter.list, &sem->wait_list); > + waiter.task = current; > + waiter.up = 0; > + > + spin_unlock_irq(&sem->lock); > + while (!waiter.up) > + cpu_relax(); > + spin_lock_irq(&sem->lock); > +}
This doesn't look very nice - if down_spin() is called with interrupts disabled, __down_spin() enables them. -- Jens Axboe --
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [thread] [
date
] [
author
]
Messages in current thread:
What if a TLB flush needed to sleep?
, Luck, Tony
, (Tue Mar 25, 4:49 pm)
Re: What if a TLB flush needed to sleep?
, Christoph Lameter
, (Wed Mar 26, 3:25 pm)
Re: What if a TLB flush needed to sleep?
, Thomas Gleixner
, (Wed Mar 26, 4:29 pm)
Re: What if a TLB flush needed to sleep?
, Christoph Lameter
, (Wed Mar 26, 9:19 pm)
Re: What if a TLB flush needed to sleep?
, Peter Zijlstra
, (Thu Mar 27, 9:20 am)
Re: What if a TLB flush needed to sleep?
, Christoph Lameter
, (Thu Mar 27, 2:44 pm)
Re: What if a TLB flush needed to sleep?
, Peter Zijlstra
, (Fri Mar 28, 5:59 am)
Re: What if a TLB flush needed to sleep?
, Matthew Wilcox
, (Wed Mar 26, 8:32 am)
RE: What if a TLB flush needed to sleep?
, Luck, Tony
, (Wed Mar 26, 4:29 pm)
down_spin() implementation
, Matthew Wilcox
, (Thu Mar 27, 10:15 am)
Re: down_spin() implementation
, Jens Axboe
, (Fri Mar 28, 8:51 am)
Re: down_spin() implementation
, Matthew Wilcox
, (Fri Mar 28, 9:17 am)
Re: down_spin() implementation
, Jens Axboe
, (Fri Mar 28, 9:24 am)
Re: down_spin() implementation
, Nick Piggin
, (Thu Mar 27, 8:01 pm)
Re: down_spin() implementation
, Matthew Wilcox
, (Fri Mar 28, 8:45 am)
Re: down_spin() implementation
, Nick Piggin
, (Fri Mar 28, 9:04 pm)
RE: down_spin() implementation
, Luck, Tony
, (Fri Mar 28, 5:16 pm)
Re: down_spin() implementation
, Arnd Bergmann
, (Fri Mar 28, 7:48 pm)
Re: down_spin() implementation
, Stephen Rothwell
, (Fri Mar 28, 12:51 am)
Re: down_spin() implementation
, Nick Piggin
, (Fri Mar 28, 1:03 am)
Re: down_spin() implementation
, Matthew Wilcox
, (Fri Mar 28, 8:46 am)
Re: What if a TLB flush needed to sleep?
, Jens Axboe
, (Thu Mar 27, 4:09 am)
Re: What if a TLB flush needed to sleep?
, Alan Cox
, (Tue Mar 25, 5:47 pm)
Navigation
Create content
Mailing list archives
Recent posts
Mail archive search
Enter your search terms.
all mailing lists
alsa-devel
dragonflybsd-bugs
dragonflybsd-commit
dragonflybsd-docs
dragonflybsd-kernel
dragonflybsd-submit
dragonflybsd-user
freebsd-announce
freebsd-bugs
freebsd-chat
freebsd-cluster
freebsd-current
freebsd-drivers
freebsd-embeded
freebsd-fs
freebsd-hackers
freebsd-hardware
freebsd-mobile
freebsd-net
freebsd-performance
freebsd-pf
freebsd-security
freebsd-security-notifications
freebsd-threads
git
git-commits-head
linux-activists
linux-arm
linux-ath5k-devel
linux-btrfs
linux-c-programming
linux-driver-devel
linux-ext4
linux-fsdevel
linux-ia64
linux-input
linux-kernel
linux-kernel-janitors
linux-kernel-mentors
linux-kernel-newbies
linux-kvm
linux-net
linux-netdev
linux-newbie
linux-nfs
linux-raid
linux-scsi
linux-security-module
linux-sparse
linux-usb
linux-usb-devel
madwifi-devel
netbsd-announce
netbsd-tech-kern
openbsd-announce
openbsd-bugs
openbsd-ipv6
openbsd-misc
openbsd-security-announce
openbsd-smp
openbsd-source-changes
openbsd-tech
openfabrics-general
openmoko-community
openmoko-devel
openmoko-kernel
reiserfs-devel
tux3
ucarp
Optionally limit your search to a specific mailing list.
advanced
Popular discussions
linux-kernel
:
Rafael J. Wysocki
[Bug #11355] Regression in 2.6.27-rc2 when cross-building the kernel
David Miller
[GIT]: Networking
Robin Lee Powell
NFS hang + umount -f: better behaviour requested.
Artem Bityutskiy
[PATCH 11/22 take 3] UBI: user-interfaces unit
git
:
David Symonds
Re: I don't want the .git directory next to my code.
Petr Baudis
[ANNOUNCE] TopGit - A different patch queue manager
Daniel Barkalow
Non-http dumb protocols
Kevin Ballard
Re: git on MacOSX and files with decomposed utf-8 file names
linux-activists
:
Jim Winstead Jr.
Re: Root Disk/Book Disk Compatibility
Linus Benedict Torvalds
Trying to answer ...
Linus Torvalds
Re: mget / mput = bad director components
Gerard A. Allan
BUG REPORT --- call chsvga (really call getkey)
openbsd-misc
:
c l
site-to-site vpn 4.0 to cisco 3000
Darren Spruell
Re: OpenBSD as Virtualbox guest
Richard Stallman
Real men don't attack straw men
GVG GVG
ssh_exchange_identification: Connection closed by remote host
Latest forum posts
[IPSEC]IPSEC_MANUAL_REQID_MAX
1 hour ago
Linux kernel
Personal opinions about Video Poker
3 hours ago
Applications and Utilities
trouble with my Asus Mainboard
3 hours ago
Linux kernel
Which games would you prefer in online casinos?
3 hours ago
Linux kernel
help in UDP catching module..
21 hours ago
Linux kernel
Is there anything like Real-time drivers?
2 days ago
Linux general
ns16550 serail console in Linux 2.6.19
2 days ago
Linux general
what class should i use to register my devices
2 days ago
Linux kernel
reset bios pasword toshiba
3 days ago
Hardware
Analysis of Process Scheduling
4 days ago
Linux kernel
Show all forums...
Recent Tags
-rc5
2.6.27
Tux3
Linux
-rc
Linus Torvalds
-rc4
quote
filesystem
Andrew Morton
H. Peter Anvin
2.6.27-rc5
Daniel Phillips
more tags
Colocation donated by:
Who's online
There are currently
4 users
and
1338 guests
online.
Online users
espenfjo
Mr_Z
xbit
kingneutron
Syndicate
speck-geostationary