What is RCU, Fundamentally?
What is RCU, Fundamentally?
Posted Jun 8, 2015 18:32 UTC (Mon) by PaulMcKenney (✭ supporter ✭, #9624)In reply to: What is RCU, Fundamentally? by firolwn
Parent article: What is RCU, Fundamentally?
In the following code, we have at most two versions:
Only one task at a time may holdmutex_lock(&my_mutex); p = find_an_element(key); list_del_rcu(&p->list); synchronize_rcu(); kfree(p); mutex_unlock(&my_mutex);
my_mutex, so there can be at most two versions of the list, the new one with the element deleted, and for pre-existing readers, the old one with that element still in place. (When this article was written, the Linux kernel used semaphores for sleeplocks, but it now uses mutexes.)
In contrast, suppose that the mutex is held only across the deletion:
In this case, many updaters could be waiting for grace periods in parallel, so there could be many concurrent versions of the list.mutex_lock(&my_mutex); p = find_an_element(key); list_del_rcu(&p->list); mutex_unlock(&my_mutex); synchronize_rcu(); kfree(p);