What is RCU, fundamentally? Sri Ramkrishna. Intro RCU stands for Read Copy Update  A synchronization method that allows reads to occur concurrently with.

Slides:



Advertisements
Similar presentations
Paging: Design Issues. Readings r Silbershatz et al: ,
Advertisements

Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
Dynamic Memory Management
1 Chapter 5 Concurrency: Mutual Exclusion and Synchronization Principals of Concurrency Mutual Exclusion: Hardware Support Semaphores Readers/Writers Problem.
Relaxed Consistency Models. Outline Lazy Release Consistency TreadMarks DSM system.
Concurrency Important and difficult (Ada slides copied from Ed Schonberg)
Ch. 7 Process Synchronization (1/2) I Background F Producer - Consumer process :  Compiler, Assembler, Loader, · · · · · · F Bounded buffer.
Memory management.
CS510 Concurrent Systems Jonathan Walpole. What is RCU, Fundamentally? Paul McKenney and Jonathan Walpole.
RCU in the Linux Kernel: One Decade Later by: Paul E. Mckenney, Silas Boyd-Wickizer, Jonathan Walpole Slides by David Kennedy (and sources)
/ PSWLAB Concurrent Bug Patterns and How to Test Them by Eitan Farchi, Yarden Nir, Shmuel Ur published in the proceedings of IPDPS’03 (PADTAD2003)
Synchronization. Shared Memory Thread Synchronization Threads cooperate in multithreaded environments – User threads and kernel threads – Share resources.
Read-Copy Update P. E. McKenney, J. Appavoo, A. Kleen, O. Krieger, R. Russell, D. Saram, M. Soni Ottawa Linux Symposium 2001 Presented by Bogdan Simion.
Introduction to Lock-free Data-structures and algorithms Micah J Best May 14/09.
10/31/20111 Relativistic Red-Black Trees Philip Howard 10/31/2011
CS510 Concurrent Systems Class 2 A Lock-Free Multiprocessor OS Kernel.
1 Sharing Objects – Ch. 3 Visibility What is the source of the issue? Volatile Dekker’s algorithm Publication and Escape Thread Confinement Immutability.
Relativistic Red Black Trees. Relativistic Programming Concurrent reading and writing improves performance and scalability – concurrent readers may disagree.
Nachos Phase 1 Code -Hints and Comments
Object Oriented Analysis & Design SDL Threads. Contents 2  Processes  Thread Concepts  Creating threads  Critical sections  Synchronizing threads.
The University of Adelaide, School of Computer Science
1 File Systems: Consistency Issues. 2 File Systems: Consistency Issues File systems maintains many data structures  Free list/bit vector  Directories.
Chapter 16 Recovery Yonsei University 1 st Semester, 2015 Sanghyun Park.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Synchronization.
Copyright ©: University of Illinois CS 241 Staff1 Threads Systems Concepts.
Kernel Locking Techniques by Robert Love presented by Scott Price.
Non-Blocking Concurrent Data Objects With Abstract Concurrency By Jack Pribble Based on, “A Methodology for Implementing Highly Concurrent Data Objects,”
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
Java Thread and Memory Model
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
© 2006 RightNow Technologies, Inc. Synchronization September 15, 2006 These people do not actually work at RightNow.
CS399 New Beginnings Jonathan Walpole. 2 Concurrent Programming & Synchronization Primitives.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
The read-copy-update mechanism for supporting real-time applications on shared-memory multiprocessor systems with Linux Guniguntala et al.
HXY Debugging Made by Contents 目录 History of Java MT Sequential & Parallel Different types of bugs Debugging skills.
CS510 Concurrent Systems Jonathan Walpole. RCU Usage in Linux.
Memory Management in Java Computer Science 3 Gerb Objective: Understand references to composite types in Java.
Concurrency in Shared Memory Systems Synchronization and Mutual Exclusion.
C H A P T E R E L E V E N Concurrent Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Read-Log-Update A Lightweight Synchronization Mechanism for Concurrent Programming Alexander Matveev (MIT) Nir Shavit (MIT and TAU) Pascal Felber (UNINE)
Implementing Lock. From the Previous Lecture  The “too much milk” example shows that writing concurrent programs directly with load and store instructions.
CSCI1600: Embedded and Real Time Software Lecture 17: Concurrent Programming Steven Reiss, Fall 2015.
Read-Copy-Update Synchronization in the Linux Kernel 1 David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis.
Implementing Mutual Exclusion Andy Wang Operating Systems COP 4610 / CGS 5765.
Lecture 5 Page 1 CS 111 Summer 2013 Bounded Buffers A higher level abstraction than shared domains or simple messages But not quite as high level as RPC.
CS510 Concurrent Systems “What is RCU, Fundamentally?” By Paul McKenney and Jonathan Walpole Daniel Mansour (Slides adapted from Professor Walpole’s)
Java Thread Programming
Healing Data Races On-The-Fly
Parallelism and Concurrency
Linked Lists in Action Chapter 5 introduces the often-used data public classure of linked lists. This presentation shows how to implement the most common.
CS703 – Advanced Operating Systems
Synchronization.
Lecture 19: Coherence and Synchronization
Atomic Operations in Hardware
Definitions Concurrent program – Program that executes multiple instructions at the same time. Process – An executing program (the running JVM for Java.
Introduction to Operating Systems
Kernel Synchronization II
Practical Concerns for Scalable Synchronization
Pointers.
Lecture: Coherence and Synchronization
Dr. Mustafa Cem Kasapbaşı
Implementing Mutual Exclusion
CSCI1600: Embedded and Real Time Software
Implementing Mutual Exclusion
CSE 451: Operating Systems Autumn 2003 Lecture 7 Synchronization
CSE 451: Operating Systems Autumn 2005 Lecture 7 Synchronization
CSE 153 Design of Operating Systems Winter 19
CS333 Intro to Operating Systems
CSCI1600: Embedded and Real Time Software
Honnappa Nagarahalli Arm
Presentation transcript:

What is RCU, fundamentally? Sri Ramkrishna

Intro RCU stands for Read Copy Update  A synchronization method that allows reads to occur concurrently with updates.  Supports concurrency between single updater and multiple readers while maintaining multiple versions of objects and ensuring that they are not freed up till all reads are complete.  Compares favorably with locking where you have to lock a critical section regardless of readers or writers.

Intro RCU is made up of three fundamental mechanisms:  Publish Subscribe mechanism  Wait for pre-existing RCU readers to complete  Maintain multiple versions of RCU objects.

Publish Subscribe Allows you to read data even though it's being updated. Some background:  We've seen that there is no guarantee that reads (or writes) are going to be in program order  Values could be assigned or viewed in the wrong order. A Publish mechanism is simply a mechanism that when a memory location is updated it forces the cpu and the compiler to execute pointer assignments and object initializations in the right order.

Subscribe Publish For some architectures like the DEC Alpha, this isn't enough as some compilers do some wacky optimization.  it optimizes by guessing and checks if their guess is right. For these, RCU introduces a rcu_deference primitive.  Really only useful on DEC Alpha architectures. Safe to not use it elsewhere.

Subscribe Publish The rcu_dereference primitive uses memory barriers and compiler directives to force thecpu and compiler to fetch values in the proper order. Example: rcu_read_lock ()‏ p = rc__dereference (gp)‏ if (p != NULL)‏ do_something_with (p->a, p->b, p->c)‏ rcu_read_unlock ()‏

Subscribe Publish The rcu_read_lock and rcu_read_unlock calls are used to declare a read-side critical section.  make sure that you don't sleep or block in this part.  don't actually do anything on some architectures.

Wait for Pre-Existing RCU Readers to Complete There are many ways to wait for something to finish using refcounts, reader/writer locks etc. Has the advantage of scability as it doesn't explicitly have to track any of the threads. Uses reader-side critical sections  can contain anything as long as it doesn't block or sleep. Can create performance problems since all readers won't be able to complete because some threads are blocking.

Wait for Pre-Existing RCU Readers to Complete Basic operation is:  Make a change to an object  Wait for all pre-existing RCU read-side critical sections to complete using synchronize_rcu primtive  Clean up This removes all unused objects and frees memory. Forces a context switch to a cpu. A context switch can't happen until all critical sections are complete. If a context switch happens it means that we have no readers going through their critical sections and probably not referencing the memory.

Wait for Pre-Existing RCU Readers to Complete synchronize_rcu primitive is really a technique to force a context switch on all cpus.  if a context switch happens, then we know that there are no readers and we can safely reclaim the memory.

1 struct foo { 2struct list head list; 3int a; 4int b; 5int c; 6 }; 7 LIST_HEAD (head); 8 / *... */ 9 p = search (head, key); 10 if (p == NULL) { 11 /* do something */ 12 } 13 q = kmalloc (sizeof (*p), GFP_KERNEL); 14 q = *p; 15 q->b = 2; 16 q->c = 3; 17 list_replace_rcu (&p->list, &q->list); 18 synchronize_rcu (); 19 kfree(p)‏

Maintaining Multiple Versions of Recently Updated Objects RCU will make a new copy every time an RCU object has been modified to. Readers will continue to see the old copy. When synchronize_rcu is called and returns, RCU will garbage collect reader's version of the object and update all the readers views since it won't complete till all the readers are done.