Who Made that Change and When: Using cregit for Debugging

When debugging kernel problems that aren’t obvious, it’s necessary to understand the history of changes to the source files. For example, a race condition that results in a lockdep warning might have tentacles into multiple code paths. This requires us to examine and understand not only the changes made, but also why they were made. Individual patch commit logs are the best source of the information on why a change was made.

So how do we find this information? My goto tool set for such endeavors has been a combination of git gui and git log. Recently I started using cregit. I will go over these options in this blog.

git log

Running git log on a source file will show all the commits for that file, then you can find the corresponding code change by generating the patch. Using git log can be tedious, but useful for targeted commit search.

git gui

Running git gui in the Linux Kernel source directory and then examining the repository/branch will show the individual commits and the corresponding changes. It can also be used to look at the branch history in a nice graph.

In the image below, you will see the git gui main window on the far left, the selected repository directory/file structure in the middle window, and the selected file ../drivers/media/platform/s5p-mfc/s5p_mfc.c in the window on the right. The SHA1 ID for each commit is shown on the left hand side bar in blue.

Who Made that Change and When Using cregit for Debugging - git-gui

Scroll through and find the commit that you want to highlight and look at its commit log. Once you find the commit, click on the commit and it will expand the commit as shown in the image below. The “this this” tag indicates the selected commit and the changes associated with this commit are highlighted in green, and you can find all the changes by scrolling through the file. The bottom window displays the commit log for the selected commit:

Who Made that Change and When Using cregit for Debugging - this_commit

You can select the Visualize all Branch History option to see the history of commits for the repository:

Who Made that Change and When Using cregit for Debugging - visual_branch

cregit-linux

I started using cregit-linux (Contributors to Linux) for doing research on the changes for debugging problems. Cregit was created by Daniel German from the University of Victoria in Canada, Alexandre Courouble and Bram Adams from the Polytechnique of Montreal in Canada, and Kate Stewart from the Linux Foundation.

The cregit-linux site maintains Linux kernel source code repositories that are transformed using cregit for each of the releases for the past year. It currently has Linux kernel releases 4.7 though 4.13. Please note that the “Information contained on the cregit-linux website is for historical information purposes only and does not indicate or represent copyright ownership.”

It is easy to browse the source files to examine individual commit information that includes the SHA1 ID, Author, and the corresponding code change, all in a single window. It also includes the complete list of contributors to the source file as well as individual functions in it. cregit – Linux 4.13 s5p_mfc.c

Now let’s find the s5p_mfc_open() and it’s contributors as shown in the pictures below:

Who Made that Change and When Using cregit for Debugging - s5p_mfc_open

Who Made that Change and When Using cregit for Debugging - s5p_mfc_open_contributors

To find out who added the line and associated commit information is as simple as hovering over a line of the source code. The lines of code each of the contributors changed is displayed as the same color that’s used for the name of that contributor.  Hover over the line of code you are interested in and click to get an option to examine the corresponding commit. It will pop up in a window like the one below:

Who Made that Change and When Using cregit for Debugging - hover_commit

Now, you can select the commit to view the actual commit on Linus Torvalds’ Linux mirror on GitHub.

Who Made that Change and When Using cregit for Debugging - cregit_commit

It’s super easy! One downside is that the cregit-linux site doesn’t include the mainline kernel, so if you’re debugging a mainline problem you’ll have to use git-gui for those commits. Even so, the cregit-linux site makes it a lot easier to find out who made a specific change and when; also provides a lot more information on the contributors and history of the changes.

Happy browsing and debugging!

Author: Shuah Khan

Shuah contributes to multiple aspects of the Linux Kernel, and she maintains the Kernel Selftest framework.