RCU kernel documentation-RCU concepts

Source: Internet
Author: User

Kernel/documentation/rcu.txt

The basic idea of RCU (read-copy update) is to divide a destruction operation into two steps: the first step is that when the writer is destroying, no reader will notice the existence of the destruction action; the second step is to execute real destruction. There is a "Grace Period"/grace period/quiet period/between the two. This grace period must be long enough to ensure that the reader who reads the deleted items has completed the read operation, and the read reference count is subtracted. For example, the RCU-protected linked list deletion operation first removes the table item from the linked list, waits for enough "grace period", and then releases the table item. Refer to the listrcu.txt document, which details the use of RCU protection on the linked list.

Frequently Asked Questions (FAQ)

Why everyone loves RCU:

The advantage of RCU is that its two-step method does not require RCU readers to request any locks, perform any atomic operations, write shared memory, or execute any memory barriors. We know that in modern CPUs, these operations are very time-consuming, so using RCU greatly improves the performance of read-intensive operations. In addition, the RCU reader does not need to apply for a lock and simplifies the code to avoid deadlocks.

When RCU reader cannot actively notify the operation to complete, how can I determine whether grace period has ended when updating route?

Like spinlocks, RCU reader does not allow process blocking. It switches to user-mode for execution or enters the idle loop. Therefore, once the CPU enters one of the three States, we can determine that the RCU-protected critical code has ended. Therefore, when we move an element from the linked list, we can safely release this element by waiting for all CPUs to switch over the context, executing the user mode or entering the idle loop.

RCU has two variants: RCU and srcu, which require readers to maintain the CPU-local count.

If you are running on a single processor and can only do one thing at a time, why wait for this grace period?

See up.txt (uniprocessor)

How can I find out where the kernel uses RCU?

Search

Rcu_read_lock, rcu_read_unlock, call_rcu, rcu_read_lock_bh, rcu_read_unlock_bh, call_rcu_bh,

Srcu_read_lock, srcu_read_unlock, synchronize_rcu, synchronize_net, synchronize_srcu

RCU Usage Guide

Checklist.txt

Why is RCU?

RCU is the abbreviation of read-copy update. the file listrcu.txt details the origin of this name.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.