When a Linux kernel API changes, hundreds of drivers are converted by hand over months, and the earlier conversions are reviewed examples for the later ones. We ask whether small open language models running on a laptop can turn such examples into Coccinelle semantic patches, the rules kernel maintainers already use for tree-wide changes. We adapt guided code generation to this task: the training examples are decomposed by script into a tree of change variants, the model writes one small rule per variant under feedback from applying it to the examples, deterministic components repair SmPL syntax and generalise driver-specific names, rules are composed greedily, and a compile critic repairs or rejects a rule whose output does not build. We evaluate on a pre-registered test set of 7 migrations whose new APIs appeared after the training cutoffs of all three models (Qwen2.5-Coder 7B, Llama 3.1 8B, Gemma 3 4B), with 122 held-out driver conversions, counting a conversion as solved only if the rule's output matches the human fix and compiles. With the framework, Qwen2.5-Coder solves 35.3 conversions on average over three seeds (range 32-41), against 1.0 when prompted directly; Spinfer solves 41 and a frontier LLM agent 66. The local model solves fewer conversions than Spinfer but its rules are the most precise on the test set (0.74 of the files they change are solved, against 0.55 for Spinfer and 0.70 for the frontier agent), and the compile critic removes every output that matches the human fix but does not build. The two general-purpose models stay weak even with guidance (at most 12 solved). All code, prompts, model responses and results are released.
Figures & tables
Fig. 1: The four stages. Shaded boxes are deterministic scripts; blue boxes call the local model. Only the training siblings are read; held-out targets are never seen.
Set
Migration
New API
Train
Targets
Buildable
Target dates
dev
ida_simple
–
20
20
20
2022-06–2024-05
dev
i2c_probe_new
–
20
20
19
2023-05–2023-09
dev
platform_remove_new
–
20
20
20
2023-03–2024-05
dev
strlcpy_strscpy
–
20
20
15
2021-01–2023-12
dev
pci_dma_wrappers
–
20
20
20
2020-12–2022-02
test
secs_to_jiffies
2024-10-30
17
10
10
2025-04–2026-05
TABLE I: Data. New API : first commit that adds the new API under include/ (test set only; all after the models’ training cutoffs). Train : training siblings. Buildable : targets whose original file compiles on x86_64 allmodconfig ; the denominator of every success count.
Frontier
Qwen2.5-Coder 7B
Llama 3.1 8B
Gemma 3 4B
Migration
Bld.
LLM †
Spinfer
one-shot
full
one-shot
full
one-shot
full
devm_kmemdup_array
16
1
2
0.0
1.3 [0–2]
0.0
0.0
0.0
0.0
ethtool_rx_ring_count
20
12
0
0.0
0.0
0.0
0.0
0.0
0.0
gpio_set_rv
20
14
0
0.0
0.0
0.0
0.0
0.0
0.0
iio_claim_direct
20
17
16
0.0
16.0
0.0
0.0
0.0
0.0
iio_push_with_ts
20
12
12
1.0
0.7 [0–1]
0.0
0.0
0.0
0.0
TABLE II: Test set: held-out conversions solved (output matches the human fix exactly or as a complete subset, and compiles). Local models: mean over three seeds, [min–max] where the seeds differ. one-shot : one rule from the plain examples; full : the complete framework. † A frontier LLM agent that may have seen these migrations during training; a reference point, not a like-for-like competitor.
Frontier
Qwen2.5-Coder 7B
Llama 3.1 8B
Gemma 3 4B
Migration
Bld.
LLM †
Spinfer
one-shot
full
one-shot
full
one-shot
full
i2c_probe_new
19
19
0
12.7 [0–19]
19.0
0.0
0.0
0.0
0.0
ida_simple
20
14
9
0.0
5.3 [5–6]
0.0
1.7 [0–5]
0.0
3.0 [0–9]
pci_dma_wrappers
20
6
2
0.0
1.3 [0–2]
0.0
0.0
0.0
0.0
platform_remove_new
20
19
0
0.0
0.0
0.0
0.0
0.0
0.0
strlcpy_strscpy
15
14
13
8.7 [0–13]
12.3 [11–13]
0.0
0.0
0.0
0.0
TABLE III: Development set, same layout as Table II . These migrations were used to design the framework, so the numbers are optimistic.
Development (of 94)
Test (of 122)
Configuration
Qwen2.5-Coder
Llama
Gemma
Qwen2.5-Coder
Llama
Gemma
one-shot
21.3 [13–32]
0.0
0.0
1.0
0.0
0.0
+ feedback
21.3 [13–32]
0.0
0.0
1.0
2.0 [0–6]
0.0
+ decomposition
21.7 [13–32]
0.0
0.0
18.0
2.0 [0–6]
0.0
+ guidance
29.0 [21–34]
2.3 [0–7]
0.0
35.3 [32–41]
10.0 [9–12]
0.0
+ auto-repair
38.0 [37–39]
1.7 [0–5]
3.0 [0–9]
35.3 [32–41]
7.0 [0–12]
2.7 [0–8]
TABLE IV: Ablation: conversions solved as components are added (mean over three seeds, [min–max]). Every configuration is composed by stage 3; the last row adds the compile critic of stage 4.
Set
Source
Success
Changed
Divergent
Broken
Precision
dev
Frontier LLM †
72.0
91.0
17.0
0.0
0.79
dev
Spinfer
24.0
47.0
13.0
0.0
0.51
dev
Qwen2.5-Coder 7B, before compile critic
38.0
82.7
12.0
20.0
0.46
dev
Qwen2.5-Coder 7B, full
38.0
62.7
12.0
0.0
0.61
dev
Llama 3.1 8B, before compile critic
1.7
22.3
10.7
0.0
0.07
dev
Llama 3.1 8B, full
1.7
20.7
8.7
0.0
0.08
TABLE V: Precision of the outputs on buildable targets (local models: mean over seeds). Changed : targets the rule edits; Divergent : the rule makes an edit the human did not make; Broken : the output matches the human fix (exactly or as a subset) but does not compile; Precision : solved / changed.
Development
Test
Model
Calls
Seconds
Repairs
Calls
Seconds
Repairs
Qwen2.5-Coder 7B
13.2
21
0.4
9.7
15
0.5
Llama 3.1 8B
16.3
31
0.1
9.7
23
0.0
Gemma 3 4B
17.4
30
0.0
9.7
16
0.3
TABLE VI: Cost per migration of the full configuration on one laptop GPU (RTX 5060, 8 GB): model calls and seconds of generation in stage 2, and repair calls of the compile critic (stage 4), mean over migrations and seeds. Compilation time is excluded.