spinlocks -- why are releases inlined and acquires are not?

From: Jiri Kosina
Date: Mon Mar 31 2008 - 20:08:50 EST


Hi,

include/linux/spinlock.h shows:

#define spin_lock_irq(lock) _spin_lock_irq(lock)

unconditionally, i.e. irrespectible of config options, we always (on SMP)
call kernel/spinlock.c:_spin_lock_irq(), which is even not inlined.

Contrary to that, unlocks are written as one would expect, i.e:

#if defined(CONFIG_DEBUG_SPINLOCK) || defined(CONFIG_PREEMPT) || \
!defined(CONFIG_SMP)
# define spin_unlock_irq(lock) _spin_unlock_irq(lock)
#else
# define spin_unlock_irq(lock) \
do { \
__raw_spin_unlock(&(lock)->raw_lock); \
__release(lock); \
local_irq_enable(); \
} while (0)

and __raw_spin_unlock() is of course properly inlined.

What is the reason for this asymetry? Shouldn't the acquiring functions be
implemented in the very same way? Or at least, shouldn't all the
__lockfunc functions be inlined?

Thanks,

--
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/