warning icon QCon London 2021 has been canceled. See our current virtual and in-person events.
You are viewing content from a past/completed QCon -

Presentation: Coccinelle: 10 Years of Automated Evolution in the Linux Kernel

Track: Modern CS in the Real World

Location: Westminster, 4th flr.

Duration: 11:50am - 12:40pm

Day of week: Monday

Slides: Download Slides

This presentation is now available to view on InfoQ.com

Watch video with transcript

What You’ll Learn

  1. Hear about Coccinelle, what it is and what it is good for.
  2. Learn how to use Coccinelle.


Over the last 10+ years, we have been developing the Coccinelle C-program matching and transformation tool. Coccinelle allows developers to match and transform C code via a generalization of the familiar patch syntax. As Coccinelle is independent of the C preprocessor, Coccinelle rules can be applied across a code base, regardless of configuration constraints. Over the years, Coccinelle has been extensively used in Linux kernel development, resulting in over 7000 commits to the Linux kernel, and has found its place as part of the Linux kernel development process. This talk gives an introduction to the use of Coccinelle and gives an overview of its impact on the Linux kernel.


Tell us a little bit about the work that you're doing today.


Mostly I'm interested in the maintenance of very large codebases. I would like to make it easier for people to understand the code, to get a good feeling about the code, to change the code and especially to understand the history of the code and how they can use the history to help them go forward in the future.


What is the goal of the talk?


I want to make it easier for people to update their code in a good way. For example, some code may be written in a certain way. Maybe it was a good idea at the time, but one can see that it's not a good idea anymore, and one would like to update it. But then one may think to onesself, oh, I'm going to have to go through 500 files and change 600 lines of code or something like that. There's a very high chance of making a mistake. It would be also extremely boring. And so I'm not going to do it. I'm just going to live with the way things are and maybe things will be okay somehow in the future.

The idea of Coccinelle is to enable you to make very concise specifications that will allow you to update your code in this good way so it can move forward in the future, so you can write a very concise specification and it will do the whole thing automatically for you.


Can Coccinelle be used for other languages than C/Linux?


Today it's targeted mainly to C code. We've developed it with Linux kernel in mind, but it has been used for plenty of other C codebases. There's some issues with respect to macros and you have to configure it with the macros that are using your codebase, but it's usually pretty easy to get it to work pretty well on most C codebases as long as they are written in a reasonable manner. We also support some aspects of C++. If you want to update the part of your C++ code that looks like C, then it may work on that as well. And we also have a prototype for Java that hasn't been explored very much, but if people are interested in using it, then we would be happy to have feedback at least and to improve it if necessary.


What is the persona targeted by this talk?


Most of our users so far have been developers, that is the people actually touching the code and have some recurring change that they need to automate. Coccinelle can also be used for finding certain patterns of code, maybe patterns that might have bugs. And so a target would be people who need to find those kinds of issues. In coming to QCon, I hope also to be able to talk maybe a bit more to higher level managers who might be interested in supporting further development of Coccinelle or just using it maybe on a wider scale in the projects that they're working on.


And perhaps expanding it into the Java language.


We're also interested in expanding it to other languages, but we don't have the manpower for that at the moment. The Java port took about three months, so maybe other languages would not take too long either. I don't know.


What would be some takeaways from your talk?


The main point is the methodology of how you can use the tool. So in the talk, I will be going through that methodology, it's quite simple. You just take an extract of code that represents the thing that you want to change, and then you extract the code and make it a bit more abstract and then you just run with it. So I would like people to come away from the talk feeling that they can download the tool and they can know how to use it pretty much on their own. Maybe just based on the slides of the talk, they shouldn't have to spend a lot of time studying documentation and so on. It should be hopefully just ready to go immediately.

Speaker: Julia Lawall

Senior Researcher @Inria

Julia Lawall is a Senior Research Scientist at Inria. Her research is at the intersection of programming languages and operating systems. She develops the tool Coccinelle and has over 2000 patches in the Linux kernel based on this work.

Find Julia Lawall at

Last Year's Tracks