High-MCC functions in the Linux Kernel

Ahmad Jbara, Adam Matan, Dror G. Feitelson

Research output: Contribution to journalArticlepeer-review

15 Scopus citations


McCabe's Cyclomatic Complexity (MCC) is a widely used metric for the complexity of control flow. Common usage decrees that functions should not have an MCC above 50, and preferably much less. However, the Linux kernel includes more than 800 functions with MCC values above 50, and over the years 369 functions have had an MCC of 100 or more. Moreover, some of these functions undergo extensive evolution, indicating that developers are successful in coping with the supposed high complexity. Functions with similarly high MCC values also occur in other operating systems and domains, including Windows. For example, the highest MCC value in FreeBSD is 1316, double the highest MCC in Linux. We attempt to explain all this by analyzing the structure of high-MCC functions in Linux and showing that in many cases they are in fact well-structured (albeit we observe some cases where developers indeed refactor the code in order to reduce complexity). Moreover, human opinions do not correlate with the MCC values of these functions. A survey of perceived complexity shows that there are cases where high MCC functions were ranked as having a low complexity. We characterize these cases and identify specific code attributes such as the diversity of constructs (not only a switch but also ifs) and nesting that correlate with discrete increases in perceived complexity. These observations indicate that a high MCC is not necessarily an impediment to code comprehension, and support the notion that complexity cannot be fully captured using simple syntactic code metrics. In particular, we show that regularity in the code (meaning repetitions of the same pattern of control structures) correlates with low perceived complexity.

Original languageEnglish (US)
Pages (from-to)1261-1298
Number of pages38
JournalEmpirical Software Engineering
Issue number5
StatePublished - Oct 1 2014
Externally publishedYes
Event2012 20th IEEE International Conference on Program Comprehension, ICPC 2012 - Passau, Germany
Duration: Jun 11 2012Jun 13 2012


  • Code regularity
  • Linux kernel
  • McCabe cyclomatic complexity
  • Perceived complexity
  • Software complexity

ASJC Scopus subject areas

  • Hardware and Architecture
  • Software


Dive into the research topics of 'High-MCC functions in the Linux Kernel'. Together they form a unique fingerprint.

Cite this