|
|
Subscribe / Log in / New account

Splicing out syscalls for tiny kernels

By Jonathan Corbet
December 3, 2014
It is no secret that the Linux kernel has grown over time; the constant addition of features and hardware support means that almost every development cycle adds more code than it removes. The good news is that, for most of us, the increase in hardware speed and size has far outstripped the growth of the kernel, so few of us begrudge the extra resources that a larger kernel requires. Developers working on tiny systems, though, are still concerned about every byte consumed by the kernel. Accommodating their needs seems likely to be a source of ongoing stress in the community.

The latest example comes from Pieter Smith's patch set to remove support for the splice() family of system calls, including sendfile() and tee(). There will be many tiny systems with dedicated applications that have no need for those calls; removing them from the kernel makes 8KB of memory available for other purposes. The Linux "tinification" developers see that as a worthwhile gain, but some others disagree.

In particular, David Miller opposed the change, saying "I think starting to compile out system calls is a very slippery slope we should not begin the journey down." He worries that, even if a specific system works today without splice(), there may be a surprise tomorrow when some library starts using that system call. Developers working on Linux systems, David appears to be arguing, should be able to count on having the basic system call set available to them anywhere.

The tinification developers have a couple of answers to this concern. One is that developers working on tiny systems know what they are doing and which system calls they can do without. As Josh Triplett put it:

We're talking about embedded systems small enough that you're booting with init=/your/app and don't even call fork(), where you know exactly what code you're putting in and what libraries you use. And they're almost certainly not running glibc.

The other response is that the kernel has, in fact, provided support for compiling out major subsystems since the beginning. Quoting Josh again:

It's not a "slippery slope"; it's been our standard practice for ages. We started down that road long, long ago, when we first introduced Kconfig and optional/modular features. /dev/* are user-facing interfaces, yet you can compile them out or make them modular. /sys/* and/proc/* are user-facing interfaces, yet you can compile part or all of them out. Filesystem names passed to mount are user-facing interfaces, yet you can compile them out.

(This list goes on for some time; see the original mail for all the details). Eric Biederman added that the SYSV IPC system calls have been optional for a long time, and Alan Cox listed more optional items as well. David finally seemed to concede that making system calls optional was not a new thing for the Linux kernel, but he stopped short of actually supporting the splice() removal patch.

Without his opposition, though, this patch may go in. But a look at the kernel tinification project list makes it clear that this discussion is likely to return in the future. The tinification developers would like to be able to compile out support for SMP systems, random number generation, signal handling, capabilities, non-root users, sockets, the ability for processes to exit, and more. Eventually, they would like to have an automated tool that can examine a user-space image and build a configuration removing every system call that the given programs do not use.

Needless to say, any kernel that has been stripped down to that extent will not resemble a contemporary Linux system. But, on the other hand, neither do the ancient (but much smaller) kernels that these users often employ now. If Linux wants to have a place on tiny systems, the kernel will have to adapt to the resource constraints that come with such systems. That will bring challenges beyond convincing developers to allow important functionality to be configured out; the tinification developers will also have to figure out a way to allow this configuration without introducing large numbers of new configuration options and adding complexity to the build system.

It looks like a hard line to walk. But the Linux kernel embodies the solution to a lot of hard problems already; where there are willing developers, there is usually a way. If the tinification developers can find a way here, Linux has a much better chance of being present on the tiny systems that are likely to be embedded in all kinds of devices in the coming years. That seems like a goal worth trying for.

Index entries for this article
KernelEmbedded systems


to post comments

Splicing out syscalls for tiny kernels

Posted Dec 4, 2014 3:13 UTC (Thu) by dw (subscriber, #12017) [Link]

It seems a little myopic to assume this work is only useful in the context of embedded systems living inside car keys or whatever else. Library operating systems are hardly a new concept (with new ones appearing constantly, e.g. MirageOS or Arrakis), and with the continuous improvement we're seeing in storage hierarchy latencies, are very unlikely to disappear any time soon.

Improving modularization of the kernel in the short term may eventually lead it to remaining competitive with application designs optimized either for extreme efficiency (as we already see in commercial settings -- e.g. HFT, process control) or containerization (assuming at some point, compute time is no longer sold in quantities as brutally coarse as double-digit percentage slices of the host machine).

Splicing out syscalls for tiny kernels

Posted Dec 4, 2014 7:29 UTC (Thu) by eru (subscriber, #2753) [Link] (3 responses)

Compiling out fundamental unix features like signals, exit, non-root users... sounds pretty strange. Wouldn't that be the sign that you really should use some other kernel?

Splicing out syscalls for tiny kernels

Posted Dec 4, 2014 8:05 UTC (Thu) by dlang (guest, #313) [Link] (2 responses)

and give up all the hardware support? why?

Splicing out syscalls for tiny kernels

Posted Dec 7, 2014 23:06 UTC (Sun) by liam (guest, #84133) [Link] (1 responses)

This may be naive, but, how many of those drivers would work with such a kernel?

Splicing out syscalls for tiny kernels

Posted Dec 8, 2014 16:38 UTC (Mon) by rgmoore (✭ supporter ✭, #75) [Link]

I think the whole idea is that the parts you need would still work. This is for really tiny, hardware-constrained embedded applications. That means that both the hardware and software are tightly defined, and it should be relatively easy to list exactly which features of the kernel are ever used. If the tools for listing used features and removing unneeded ones are well written, trimming the kernel to the bare minimum should be simple enough to be part of a standard development process.

8 kilobytes of memory

Posted Dec 4, 2014 13:43 UTC (Thu) by epa (subscriber, #39769) [Link] (1 responses)

removing them from the kernel makes 8KB of memory available for other purposes.
Is that because the kernel code is 8Kbyte smaller or because the working memory needed by the kernel is less? Or a combination of both? (It might matter if some embedded systems want to put the kernel in ROM, I guess.)

8 kilobytes of memory

Posted Dec 17, 2014 19:45 UTC (Wed) by tbird20d (subscriber, #1901) [Link]

"working memory" as a concept doesn't really apply to the kernel, as the kernel is (currently) completely resident in memory. Making that NOT SO, is yet another possible tinification project. But maybe you're just referring to the difference between code and data.


Copyright © 2014, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds