1

the codes is:

 static inline void __list_add_rcu(struct list_head * new,
                  struct list_head * prev, struct list_head * next)
  {
          new->next = next;
          new->prev = prev;
          smp_wmb();
          next->prev = new;
          prev->next = new;
  }

 #define smp_wmb()       wmb()

 #ifdef CONFIG_UNORDERED_IO
 #define wmb()   asm volatile("sfence" ::: "memory")
 #else
 #define wmb()   asm volatile("" ::: "memory")

I know the function of smp_wmb() can prevent reordering the instructions by the complier from wiki.
But what ways of RCU prevent reordering by CPU?

Cœur
  • 37,241
  • 25
  • 195
  • 267
lxgeek
  • 1,732
  • 2
  • 22
  • 33
  • I would recommend to take a look at [memory-barriers.txt](http://www.mjmwired.net/kernel/Documentation/memory-barriers.txt) in the kernel docs, it might be helpful. – Eugene Nov 04 '13 at 08:27

0 Answers0