RE: [PATCH] Profile likely/unlikely macros

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> Andrew Morton wrote:
> > Daniel Walker <[email protected]> wrote:
> > 
> >> +	if (likeliness->type & LIKELY_UNSEEN) {
> >> +		if (atomic_dec_and_test(&likely_lock)) {
> >> +			if (likeliness->type & LIKELY_UNSEEN) {
> >> +				likeliness->type &= (~LIKELY_UNSEEN);
> >> +				likeliness->next = likeliness_head;
> >> +				likeliness_head = likeliness;
> >> +			}
> >> +		}
> >> +		atomic_inc(&likely_lock);
> > 
> > 
> > hm, good enough I guess.  It does need a comment explaining why we 
> > don't just do spin_lock().
> 
> I guess it is so it can be used in NMIs and interrupts 
> without turning interrupts off (so is somewhat lightweight).
> 
> But please Daniel, just use spinlocks and trylock. This is 
> buggy because it doesn't get the required release consistency correct.

Could you elaborate a bit what's wrong here? (memory barriers, etc? What about the test_and_set_bit() thing Andrew suggested?)

Trylock is a bit more dirty because we need to avoid recursion (it used likely/unlikely too). While there are ways to work around
it, atomic operations seem to be cleaner.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux