Navigate Linux Kernel Source With Elixir and cscope
Browse Linux source online with Elixir and index a local tree with cscope and make cscope, so you can find a symbol's definition and every caller in seconds.

Two tools cover almost every lookup
Reading kernel code is mostly following references: where is this function defined, who calls it, where is this field written. Plain grep answers those slowly and noisily on a tree this size. Two tools do it better. Elixir is a web cross-referencer that indexes every released version, and cscope is a local indexer that answers the same questions offline against your own checkout. This post shows both, on Linux 6.12 LTS.
Elixir: browse any version in a browser
Bootlin hosts Elixir at elixir.bootlin.com. It has three properties that matter for kernel work.
It keeps every version. A version selector switches the whole tree, so you can compare how schedule() looked in v5.4 and v6.12 without checking anything out.
It links identifiers. A function, macro, struct or variable name in the source is a link. Clicking it opens a page listing its definitions and its references, split by file and line.
It understands the configuration dimension. Because the kernel supports many architectures, the identifier page shows which definition belongs to which architecture, which plain text search cannot.
A typical session answers "what does kmalloc really call?":
Open the 6.12 source tree and use the Identifier search for
kmalloc.The result lists the definition in
include/linux/slab.hand many references.Click the definition, then follow
__kmalloc_noprofor the equivalent tomm/slub.c.Use the version selector to see what it looked like two years earlier.
The limits are real. Elixir shows source as released, not your local patches, and it needs a network connection. It is the right tool for orientation and for linking a colleague to an exact line; it is not the tool for navigating your own modified tree.
cscope: an offline index for your own checkout
The kernel build system has built-in targets for indexers. In a source tree, generate the cscope database for one architecture:
cd linux
make ARCH=x86 cscope
ls cscope.* GEN cscope
cscope.files cscope.out cscope.out.in cscope.out.poThe ARCH= argument tells the script which arch/ directory to include. Without it, the script uses the architecture of the host. That is the point of the target: indexing every architecture would mix a dozen definitions of the same function, and the answers would be hard to read.
Start the interface:
cscope -d-d tells cscope to use the existing database without rebuilding it, which saves time. The screen shows a menu of search types:
Find this C symbol:
Find this global definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:
Find assignments to this symbol:Move between fields with Tab, type a name, and press Enter. For kmalloc, "Find this global definition" jumps to the header and "Find functions calling this function" lists callers. Press the number next to a result to open it in your editor (set EDITOR=vim, for example), and Ctrl-D to quit.
The two searches that pay off most are "Find functions calling this function", which answers "who uses this API" and builds the call tree upward, and "Find assignments to this symbol", which answers "who changes this field". Plain text search treats both as the same word.
Rebuild when the tree changes
cscope does not watch files. After a git checkout to another version or a rebase, regenerate it:
make ARCH=x86 cscopeA stale index is the usual cause of "this definition is not there".
ctags as an alternative
If your editor prefers tags, the same Makefile target family offers tags and gtags:
make ARCH=x86 tags GEN tagsTags answer "jump to the definition" quickly but not "find callers", so they replace only half of cscope. Language servers can do both from compile_commands.json, which is the subject of a later post in this series.
Choosing between them
| Need | Use | Why |
|---|---|---|
| Quick lookup of an upstream identifier | Elixir | No setup, shows all versions and architectures |
| Link someone to an exact line | Elixir | Stable permalinks per version |
| Callers or assignments in your patched tree | cscope | Indexes the files you actually have |
| Offline reading on a train | cscope or tags | Needs no network |
| One text string, no structure | git grep | Fast and exact |
A worked example: who calls schedule()
Say you want to know how many places call the scheduler directly. In cscope pick "Find functions calling this function" and enter schedule. The result is a list of file, function and line. On the 6.12 tree it contains hundreds of entries across kernel/, fs/, drivers/ and mm/, so narrow it by file path when you care about a subsystem. In Elixir the same question is the references list on the identifier page for schedule, where you can filter by file. The count differs between the tools because Elixir indexes every architecture and cscope indexes only the one you generated.
Pitfalls
Macros hide definitions. A name generated by token pasting, like the SYSCALL_DEFINE3(read, ...) that creates ksys_read helpers and __x64_sys_read, will not appear under the name you expect. Search for the macro and read its expansion in include/linux/syscalls.h.
Configuration changes the answer. A function can be defined in two places, one for CONFIG_SMP and one for uniprocessor builds. When both appear, check the surrounding #ifdef before assuming which one runs.
Do not trust a result outside your architecture. A definition under arch/powerpc is irrelevant on x86.
Reading code you just found
Finding the definition is the start. Two habits make the next ten minutes faster. First, read the function's comment block: kernel-doc comments above exported functions state the arguments, the return value and the locking rules, and the kernel-doc format description explains how they are written. Second, check how the function is exported. EXPORT_SYMBOL and EXPORT_SYMBOL_GPL marks tell you whether a loadable module may call it, which decides whether code you write out of tree can depend on it at all.
When a function pointer is called, such as inode->i_op->lookup, neither tool can tell you which implementation runs, because the target is chosen at run time. Search for the structure's field name being assigned (cscope's "Find assignments to this symbol" does this) and you will find every file system or driver that fills it in. That list is usually the real answer to "what happens when this is called".


