* spin_is_locked() broken for uniprocessor? @ 2009-08-18 22:09 Kumar Gala 2009-08-18 22:24 ` Thomas Gleixner 0 siblings, 1 reply; 8+ messages in thread From: Kumar Gala @ 2009-08-18 22:09 UTC (permalink / raw) To: Linux-Kernel List Cc: Thomas Gleixner, Benjamin Herrenschmidt, linuxppc-dev list I just want to validate that what I'm seeing (for UP, non-debug features): spin_is_locked() is defined as: include/linux/spinlock.h:#define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) for UP that should get us: include/linux/spinlock_up.h:#define __raw_spin_is_locked(lock) ((void) (lock), 0) which implies to me that spin_is_locked() will always return false. Is this expected behavior. - k ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-18 22:09 spin_is_locked() broken for uniprocessor? Kumar Gala @ 2009-08-18 22:24 ` Thomas Gleixner 2009-08-19 9:38 ` David Howells 0 siblings, 1 reply; 8+ messages in thread From: Thomas Gleixner @ 2009-08-18 22:24 UTC (permalink / raw) To: Kumar Gala Cc: Linux-Kernel List, Benjamin Herrenschmidt, linuxppc-dev list, Ingo Molnar, Peter Zijlstra, Steven Rostedt On Tue, 18 Aug 2009, Kumar Gala wrote: > I just want to validate that what I'm seeing (for UP, non-debug features): > > spin_is_locked() is defined as: > > include/linux/spinlock.h:#define spin_is_locked(lock) > __raw_spin_is_locked(&(lock)->raw_lock) > > for UP that should get us: > > include/linux/spinlock_up.h:#define __raw_spin_is_locked(lock) ((void)(lock), > 0) > > which implies to me that spin_is_locked() will always return false. Is this > expected behavior. That's wrong. spin_is_locked should always return true on UP. Thanks, tglx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-18 22:24 ` Thomas Gleixner @ 2009-08-19 9:38 ` David Howells 2009-08-19 9:41 ` Peter Zijlstra 2009-08-19 10:53 ` Alan Cox 0 siblings, 2 replies; 8+ messages in thread From: David Howells @ 2009-08-19 9:38 UTC (permalink / raw) To: Thomas Gleixner Cc: dhowells, Kumar Gala, Peter Zijlstra, Linux-Kernel List, Steven Rostedt, linuxppc-dev list, Ingo Molnar Thomas Gleixner <tglx@linutronix.de> wrote: > > which implies to me that spin_is_locked() will always return false. Is this > > expected behavior. > > That's wrong. spin_is_locked should always return true on UP. Surely it's not that simple? Maybe spin_is_lock() should be undefined on UP. David ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-19 9:38 ` David Howells @ 2009-08-19 9:41 ` Peter Zijlstra 2009-08-27 9:32 ` Benjamin Herrenschmidt 2009-08-19 10:53 ` Alan Cox 1 sibling, 1 reply; 8+ messages in thread From: Peter Zijlstra @ 2009-08-19 9:41 UTC (permalink / raw) To: David Howells Cc: Thomas Gleixner, Kumar Gala, Linux-Kernel List, Steven Rostedt, linuxppc-dev list, Ingo Molnar On Wed, 2009-08-19 at 10:38 +0100, David Howells wrote: > Thomas Gleixner <tglx@linutronix.de> wrote: > > > > which implies to me that spin_is_locked() will always return false. Is this > > > expected behavior. > > > > That's wrong. spin_is_locked should always return true on UP. > > Surely it's not that simple? Maybe spin_is_lock() should be undefined on UP. #define spin_is_locked(l) panic() should sort things out quickly ;-) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-19 9:41 ` Peter Zijlstra @ 2009-08-27 9:32 ` Benjamin Herrenschmidt 0 siblings, 0 replies; 8+ messages in thread From: Benjamin Herrenschmidt @ 2009-08-27 9:32 UTC (permalink / raw) To: Peter Zijlstra Cc: David Howells, Steven Rostedt, Linux-Kernel List, linuxppc-dev list, Thomas Gleixner, Ingo Molnar On Wed, 2009-08-19 at 11:41 +0200, Peter Zijlstra wrote: > > > > which implies to me that spin_is_locked() will always return > false. Is this > > > > expected behavior. > > > > > > That's wrong. spin_is_locked should always return true on UP. > > > > Surely it's not that simple? Maybe spin_is_lock() should be > undefined on UP. > > #define spin_is_locked(l) panic() > > should sort things out quickly ;-) Not defining it would sort things out even faster and avoid nasty case of system panic'ing when a module is loaded :-) Cheers, Ben. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-19 9:38 ` David Howells 2009-08-19 9:41 ` Peter Zijlstra @ 2009-08-19 10:53 ` Alan Cox 2009-08-19 11:16 ` Leon Woestenberg 1 sibling, 1 reply; 8+ messages in thread From: Alan Cox @ 2009-08-19 10:53 UTC (permalink / raw) To: David Howells Cc: Thomas Gleixner, dhowells, Kumar Gala, Peter Zijlstra, Linux-Kernel List, Steven Rostedt, linuxppc-dev list, Ingo Molnar On Wed, 19 Aug 2009 10:38:06 +0100 David Howells <dhowells@redhat.com> wrote: > Thomas Gleixner <tglx@linutronix.de> wrote: > > > > which implies to me that spin_is_locked() will always return false. Is this > > > expected behavior. > > > > That's wrong. spin_is_locked should always return true on UP. > > Surely it's not that simple? Maybe spin_is_lock() should be undefined on UP. That would lead to a lot of #ifdef CONFIG_SMP #endif in drivers because there is driver code that uses spin_is_locked() in fairly sensible fashion when dealing with locking. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-19 10:53 ` Alan Cox @ 2009-08-19 11:16 ` Leon Woestenberg 2009-08-19 11:23 ` Peter Zijlstra 0 siblings, 1 reply; 8+ messages in thread From: Leon Woestenberg @ 2009-08-19 11:16 UTC (permalink / raw) To: Alan Cox Cc: David Howells, Thomas Gleixner, Kumar Gala, Peter Zijlstra, Linux-Kernel List, Steven Rostedt, linuxppc-dev list, Ingo Molnar Hello, On Wed, Aug 19, 2009 at 12:53 PM, Alan Cox<alan@lxorguk.ukuu.org.uk> wrote: > On Wed, 19 Aug 2009 10:38:06 +0100 > > in drivers because there is driver code that uses spin_is_locked() in > fairly sensible fashion when dealing with locking. > One use is to measure lock contention hits on a particular spin lock. However I wonder if there are tracing capabilities to measure lock contention on a particular lock? Currently I have inserted code much like this to get a feeling on the contention: this_cpu = get_cpu(); put_cpu(); contention = spin_is_locked(&lock); spin_lock*(&lock); if (contention) { /* spin lock was contended, prev_cpu, this_cpu */ /* no hard guarantee, as we had a possible race inbetween is_locked() and lock(), but works for driver/irq spin lock */ } /* critical section */ prev_cpu = this_cpu; spin_unlock*(&lock); Regards, -- Leon ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: spin_is_locked() broken for uniprocessor? 2009-08-19 11:16 ` Leon Woestenberg @ 2009-08-19 11:23 ` Peter Zijlstra 0 siblings, 0 replies; 8+ messages in thread From: Peter Zijlstra @ 2009-08-19 11:23 UTC (permalink / raw) To: Leon Woestenberg Cc: Alan Cox, David Howells, Thomas Gleixner, Kumar Gala, Linux-Kernel List, Steven Rostedt, linuxppc-dev list, Ingo Molnar On Wed, 2009-08-19 at 13:16 +0200, Leon Woestenberg wrote: > Hello, > > On Wed, Aug 19, 2009 at 12:53 PM, Alan Cox<alan@lxorguk.ukuu.org.uk> wrote: > > On Wed, 19 Aug 2009 10:38:06 +0100 > > > > in drivers because there is driver code that uses spin_is_locked() in > > fairly sensible fashion when dealing with locking. > > > One use is to measure lock contention hits on a particular spin lock. > > > However I wonder if there are tracing capabilities to measure lock > contention on a particular lock? lock_stat no good for you? ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-08-27 9:33 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-08-18 22:09 spin_is_locked() broken for uniprocessor? Kumar Gala 2009-08-18 22:24 ` Thomas Gleixner 2009-08-19 9:38 ` David Howells 2009-08-19 9:41 ` Peter Zijlstra 2009-08-27 9:32 ` Benjamin Herrenschmidt 2009-08-19 10:53 ` Alan Cox 2009-08-19 11:16 ` Leon Woestenberg 2009-08-19 11:23 ` Peter Zijlstra
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox