lkml.org 
[lkml]   [2007]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] timer/hrtimer: take per cpu locks in sane order
On Fri, Mar 02, 2007 at 11:47:52PM +0100, Heiko Carstens wrote:
> /*
> + * Locks two spinlocks l1 and l2.
> + * l1_first indicates if spinlock l1 should be taken first.
> + */
> +static inline void double_spin_lock(spinlock_t *l1, spinlock_t *l2,
> + bool l1_first)
> + __acquires(l1)
> + __acquires(l2)
> +{
> + if (l1_first) {
> + spin_lock(l1);
> + spin_lock(l2);
> + } else {
> + spin_lock(l2);
> + spin_lock(l1);
> + }
> +}

Two observations:

- We probably don't want people using this for locks that aren't
explicitly in the same level of the hierarchy. The name should
somehow indicate that. Something like spin_lock_siblings()?

- And once we know that, we can internally impose a natural stable
ordering on them based on their addresses, eliminating the third
argument and the need to duplicate the ordering calculation.

--
Mathematics is the supreme nostalgia of our time.
-
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/

\
 
 \ /
  Last update: 2007-03-05 00:41    [from the cache]
©2003-2011 Jasper Spaans