Monthly Archives: June 2014

Beginning the internship at OPW

This is my first post on this blog, where I will keep track of the many interesting things that I will work on during this internship.

For the beginning, I want to say that I am very happy for being accepted at Outreach Program for Women. All I wanted for this summer was to have the opportunity to work at the Linux Kernel and, with the help of this program, my wish came true.

I will work on RCU (Read-Copy-Update) and my mentor is Paul E. McKenney. More exactly the name of my project is “Automatically Locate RCU Abuses”.

So, what is RCU?
Read-Copy-Update is a reader-writer synchronization mechanism. It allows multiple readers which not contain any locks or atomic instructions (or memory barriers – although few architectures need them) and writers can update in the presence of readers! This is a very interesting feature.

Write-side critical sections maintain multiple versions of data structures in order to keep valid data for older and newer readers. If there is unnecessary data, the writers have a mechanism of deferring the destruction of that data. They could wait for a signal from a reader and delete it, but instead they wait until they have many signals from more readers and then gets rid of those operations. This is a good thing because it avoids the overhead of doing this after every read-side critical section.

For more information about it, I suggest the RCU Documentation and the interesting articles/papers on the Internet about it too 🙂

A tool that I will use throughout this internship is Coccinelle. Coccinelle is a very useful, powerful and time-saving tool. Coccinelle was created for helping the Linux Kernel. It matches and transforms the source code of C programs. You can rename functions, add new parameters to them or remove parameters and much more things, both simpler and more difficult. There are many examples on the Internet and if you are curious you could take a look.

Now, let’s discuss how I spent these internship days. I allocated some important time for RCU Documentation, Coccinelle documentation and examples of Coccinelle scripts. My mentor helped me having a better understanding of RCU and right now I am working at my first task. Also, he was very understanding with me because I have made a slow start due to my final exams.

Shortly, my first task assume to automatically replace (using Coccinelle) calls of the macro “rcu_assign_pointer” with “RCU_INIT_POINTER”. There are some cases where this thing could be done, but I have to be very careful because a wrong replacement leads to bad things (impossible to detect memory corruption).

  • “rcu_assign_pointer” assigns a specified value to a specified RCU-protected pointer. It also inserts memory barriers to determine the compiler to not reorder the code that initializes the structure after the pointer assignment. It ensures that any concurrent RCU readers will see the initialization made before the assignment.
  • “RCU_INIT_POINTER” assigns a specified value to a specified RCU-protected pointer, but it doesn’t have any memory barriers. It is useful when readers do not need any ordering constraints.

I have been looking of the usages of “rcu_assign_pointer” in the source tree and I started to think of how I will write the Coccinelle script.

In the next post, I will talk about the cases where these replacements could be done and my progress in this task.