On Sat, Feb 28, 2015 at 10:12:23PM +0200, Cihangir Akturk wrote: > Reading the lib/llist.c file in the kernel sources, I came across > the llist_add_bach function defined like this; > > bool llist_add_batch(struct llist_node *new_first, struct llist_node *new_last, > struct llist_head *head) > { > struct llist_node *first; > > do { > new_last->next = first = ACCESS_ONCE(head->first); > } while (cmpxchg(&head->first, first, new_first) != first); > > return !first; > } > > One thing bugging my mind is the ACCESS_ONCE macro. Is it really > needed here ? I mean I would write this function with ACCES_ONCE > moved outside the loop like as follows; > Do you know what ACCESS_ONCE does? I found this comment: "The compiler * is also forbidden from reordering successive instances of ACCESS_ONCE()" from: include/linux/compiler.h This might be something that does need to be called (to tell the compiler something) on every loop iteration. _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies