Tue, 06 Nov 2007

Kernel Coding: Good Enough?

Two incidents recently disturbed me about the state of kernel code and review. The first was Willy's stringbuf patch: I felt compelled to contribute a version which was more polished.

Ignoring (for this post at least!) the voodoo optimization that followed, what concerns me is that stringbuf was good, but not great. Yet I always think of the kernel as a bastion of really good C code and practice, carefully honed by thoughtful coders. Here even the unmeasured optimization attempts show a lack of effort on the part of experienced kernel coders.

Then came Jens Axboe's scatterlist changes. The transition pain is fine, but the resulting interface is subtle and not up to the standard I expect of kernel infrastructure: when I tried to use them in virtio the result was ugly and suboptimal. This is a side-effect of an attempt not to break things: to keep loops over chained scatterlists simple. Yet it turns out that introducing a header for multiple scatterlist arrays is both more explicit and can coexist cleanly with the old code, which would have vastly simplified the transition.

DaveM said to me that the scatterlist code "isn't that bad" and he's absolutely right. But it's not *great*, and that concerns me enough to look hard at replacing it, even though it works.

I briefly wondered if accelerated decentralized development and the weakening of review are causing a gradual lowering of standards. But I think it's like it always is: it's *hard* to write great code, and most of us frequently fall short.


[/tech] permanent link