0

synchronize_rcu() is used to waits only for ongoing RCU read-side critical sections to complete. If so, it should been blocked forever when beening called inside a read block. However, the following code works well on my linux kernel, why?

void port_range_clean( void ) 
{
    struct port_range *p;

redo:
    rcu_read_lock();
    list_for_each_entry_rcu(p, &port_rt->ports, list) {
        list_del_rcu(&p->list);
        synchronize_rcu();
         rcu_read_unlock();           
        kfree(p);
        goto redo;
    }
}
river
  • 694
  • 6
  • 22
  • You may assume that calling `synchronize_rcu` withing RCU critical section is an *undefined behaviour* - it may crash, it may block forever, ... or it may silently pass. E.g., on systems with a **single CPU** being active, `syncrhonize_rcu` is just no-op. With RCU debugging enabled, you may get warnings in the kernel log about improper usage of functions. – Tsyvarev Sep 04 '18 at 09:31
  • Can you give me more principle why `synchronize_rcu` not hangs system in my case ? Thanks. – river Sep 05 '18 at 09:19
  • I don't know details of RCU implementation in Linux kernel, so cannot give more reasons why your code doesn't crash. – Tsyvarev Sep 05 '18 at 10:02

0 Answers0