Re: Usage of unlikely in RCU code

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

 



Dear Julie....

On Tue, Aug 2, 2011 at 04:28, Julie Sullivan <kernelmail.jms@xxxxxxxxx> wrote:
> Specifically, the conditional
>
>  if (t->rcu_read_lock_nesting == 0 &&
>            unlikely(ACCESS_ONCE(t->rcu_read_unlock_special)))
>                rcu_read_unlock_special(t);
>
> I've googled for 'likely/unlikely' and i've seen
>
>  if (unlikely(...
>
> before in kernel code, and I might understand if the logical operator
> here were || not &&, but why is the 'unlikely' attribute only applied
> to the second operand here?

i guess that's because first condition "t->rcu_read_lock_nesting == 0"
has about 50%-50% chance.... so putting likely() or unlikely() has no
use here...

i read somewhere (or maybe someone's opinion) that you only use
likely() or unlikely() if you are about above 90% (or maybe...if
possible 99%) sure that condition will be true or false....otherwise,
avoid likely()/unlikely() and let the compiler+processor do the usual
ordering/branch prediction.

just my 2 cents...

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux