[go: up one dir, main page]

|
|
Log in / Subscribe / Register

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:

mutex_lock(&my_mutex);
p = find_an_element(key);
list_del_rcu(&p->list);
synchronize_rcu();
kfree(p);
mutex_unlock(&my_mutex);
Only one task at a time may hold 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:

mutex_lock(&my_mutex);
p = find_an_element(key);
list_del_rcu(&p->list);
mutex_unlock(&my_mutex);
synchronize_rcu();
kfree(p);
In this case, many updaters could be waiting for grace periods in parallel, so there could be many concurrent versions of the list.


to post comments

What is RCU, Fundamentally?

Posted Jun 3, 2024 6:57 UTC (Mon) by summergift (guest, #171661) [Link]

Thank you for your explanation!


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds