lkml.org 
[lkml]   [2007]   [Jun]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: volatile and atomic_t/spinlock_t
On Tue, Jun 05, 2007 at 11:38:27AM -0700, Luck, Tony wrote:
> > So is
> >
> > while (__raw_spin_is_locked(&v));
> >
> > supposed to work? Or should that be
> >
> > while (__raw_spin_is_locked(&v))
> > cpu_relax();
> >
> > as well and all the volatiles can/should go away?
>
> cpu_relax() is a really good idea in every spinloop on
> hyper-threaded cores. It lets the h/w know that we aren't
> doing anything useful here, so resources and power can be
> diverted to other threads sharing the core.
>
> Avoiding the need for volatile or other compiler optimizer
> defeating tricks is a side benefit.

Currently it is already that it has to be

while (__raw_spin_is_locked(&v))
cpu_relax();

Just like in __raw_spin_unlock_wait(). Oh well, I should have
checked more before posting...
-
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-06-06 00:21    [W:0.034 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site