From: Kumar Gala <hidden> Date: 2009-08-18 22:10:15
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
From: Thomas Gleixner <hidden> Date: 2009-08-18 22:24:36
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
On Wed, 19 Aug 2009 10:38:06 +0100
David Howells [off-list ref] wrote:
Thomas Gleixner [off-list ref] wrote:
quoted
quoted
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.
From: Leon Woestenberg <hidden> Date: 2009-08-19 11:16:49
Hello,
On Wed, Aug 19, 2009 at 12:53 PM, Alan Cox[off-list ref] 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
From: Peter Zijlstra <peterz@infradead.org> Date: 2009-08-19 11:23:32
On Wed, 2009-08-19 at 13:16 +0200, Leon Woestenberg wrote:
Hello,
On Wed, Aug 19, 2009 at 12:53 PM, Alan Cox[off-list ref] wrote:
quoted
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?