[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

Kernel tinification

By Jonathan Corbet
August 20, 2014

Kernel Summit 2014
Josh Triplett started his 2014 Kernel Summit session with an assertion: saying that "Linux runs on everything from cellphones to supercomputers" is trite and uninformative. In 2014, he said, a smartphone is not an embedded system. He would like to convince kernel developers to pay a bit more attention to the needs of real embedded systems — those with only a few megabytes of flash and a tiny amount of memory. The Linux kernel, he says, has gotten far too big to run comfortably on such systems; he would like to build a consensus in favor of a "tinification" effort to shrink things back down.

[Size chart] He put up a chart showing the in-memory size of the smallest possible kernel over time. That size, he said, has increased with almost every release. It rarely goes down; about the only time was when developers figured out how to configure out the TTY layer. A growing kernel makes it hard for the people who are trying to build tiny systems, forcing them to go to a proprietary real-time operating system instead. It should be possible to use Linux on such systems, he said, but we have to make it possible to build smaller kernels — perhaps as much as an order of magnitude smaller.

Some people apparently suggest the use of 2.4 kernels for such use cases. The 2.4 kernel is indeed quite a bit smaller, but it still does not solve the problem. Just because somebody is using tiny hardware does not mean that they can do without (some of) the capabilities found in current kernels.

Some notes on building tiny kernels can be found at tiny.wiki.kernel.org.

Part of the problem, Josh said, is that the kernel is full of mandatory subsystems that cannot be configured out. If somebody wants to, say, build a kernel without support for signals, it should be possible for them to do so. We also suffer from a lack of good metrics on kernel size; most developers are blissfully unaware of how their changes affect the size of the kernel.

Ted Ts'o mentioned a related discussion on the ext4 development list. Tiny systems often run without a memory management unit (MMU), but most filesystems do not work in a kernel configured to operate without an MMU. Is it worth the trouble to make filesystems work on such systems? After all, the high-end filesystems are developed for large systems and scalability; they may not have much to offer for tiny systems. Others agreed, noting that tiny systems often do not even have the block layer built into them. Josh said that there may be value in ext4 support, though. Among other things, there is work afoot to use Linux as a bootloader on small systems; ext4 support is important there.

Grant Likely said that, while he is happy to see patches to enable the building of smaller kernels, he is worried about how all of the configuration options would work. We can't handle the complexity of the options we have now. Also, most kernel development is focused on the addition of new features. There is not a lot of pressure to make the kernel smaller, so nobody is working on it. The users who want this capability, he said, are not having a big impact on kernel development.

Peter Zijlstra agreed that more configuration options would not be welcome; we cannot, he said, even build-test all of the combinations of the current options. There was some talk of trying to hide many of the options and to instead use dependencies to select the right features when needed. But there are a number of practical difficulties here, especially in situations where a number of kernel subsystems could conceivably satisfy a given dependency.

Grant said, though, that to talk about configurations and dependency resolution was to get lost in side issues. People who are building tiny systems will have no choice but to get into the details of how their kernels are configured. What is needed are developers who are actively working on size issues. While other developers may have agreed with this point of view, the discussion quickly moved back to configuration issues and, in particular, the feared explosion of the size of the configuration space.

It was suggested that a user of a tiny system could provide the configuration system with a list of the system calls that will actually be used on the deployed system. The configuration code would then decide how to create a minimal kernel that provides the needed capabilities. Ted said [Josh Triplett] that this might be a good project for somebody to work on out of tree. In the end, he said, kernel developers simply do not have the time to test this kind of feature.

In general, Ted asked Josh, what would he like from the group? Josh answered that he would like developers to start seeing size increases as a regression and to be willing to accept reasonable patches to fix those regressions. Tejun Heo responded that this was not reasonable, given all of the other constraints that kernel developers must deal with. Worrying about size will just make the whole task even harder.

Tim Bird said that at least some of this task could be automated. There has been some research work on the elimination of unneeded code. In the more immediate future, he would like to see the link-time optimization (LTO) work merged into the kernel. Josh agreed that LTO is useful; among other things, it should enable the removal of a number of size-oriented configuration options. Andi Kleen, who has done the bulk of the LTO work so far, said that it can help, but that the code has to be designed correctly to get the most value from LTO. "Crazy callback dependencies," he said, will thwart LTO. Linus said that, for now, he does not trust the LTO implementation in the current toolchain, so he does not want to let the changes into the kernel. Toolchain bugs can create no end of obscure problems, and he does not want to see those in the kernel. Until that code stabilizes, LTO will remain outside.

It was also suggested that it would help to point to a real target or two for tiny kernels. As it is, developers have little understanding of the type of system that is being talked about. David Woodhouse suggested that the QEMU emulator could be set up as a reference target, but Grant asserted that a QEMU configuration is easy for developers to ignore. What is needed is a real hardware target.

Ted pointed out that "you get what you measure." What is needed, he said, is more information on kernel bloat and what is causing it. Andi responded that developers do not really care about this issue; size issues are simply not on their radar. Chris Mason suggested that Fengguang Wu's build system could start providing size-change information; that would put developers more in the position of intentionally choosing to make the kernel bigger. Andi agreed that size increases are usually done by accident; making them more visible might help.

As the session reached a close, Josh suggested that it would be useful to have a configuration option to turn absolutely everything off. It would not normally be possible to re-enable specific items, but developers working on tiny systems could apply a patch to get around that limitation. Once they have done that, though, the only way the development community would be interested in a problem report would be if it came accompanied with a patch to fix the problem.

What will come of this discussion remains to be seen. But, as Josh pointed out, if nothing else, developers are starting to talk about the problem, even if they are just scoffing. One has to start somewhere.

Next: What makes Linus happy (or not)?

Index entries for this article
KernelEmbedded systems
ConferenceKernel Summit/2014


to post comments

Kernel tinification

Posted Aug 21, 2014 14:55 UTC (Thu) by yaap (subscriber, #71398) [Link] (4 responses)

"forcing them to go to a proprietary real-time operating system instead"

There are several free RTOS, like FreeRTOS or eCos so no need to dramatize by saying "proprietary" there ;) Even with a tinified linux, there will always be room for such light RTOS at the low end (tiny micro-controllers).

Kernel tinification

Posted Aug 22, 2014 15:51 UTC (Fri) by etienne (guest, #25256) [Link] (3 responses)

> Even with a tinified linux, there will always be room for such light RTOS at the low end (tiny micro-controllers).

There is a lot more software these days.
The other day, in my kitchen, the new "Induction Ceramic hob" crashed with non-responsive soft On/Off - I had to apply a complete and external power Off/On cycle...

Kernel tinification

Posted Aug 31, 2014 9:49 UTC (Sun) by Wol (subscriber, #4433) [Link] (2 responses)

We had our induction hob fitted as part of our new kitchen some six years ago, and how's *this* for an obscure bug!!!

We repeatedly had the same issue as you, soft crashes requiring a hard reset to fix. So we called in the engineer under warranty to fix it.

He looked outside, and said "Are you under a flight path?". We are, about three or four miles from City Airport, almost right under the normal approach. So the engineer said, "it's a well known problem, the flight avionics interfere with the controller. You'll need a new controller." He replaced it and it's been fine ever since ...

Cheers,
Wol

Kernel tinification

Posted Aug 31, 2014 10:37 UTC (Sun) by Fowl (subscriber, #65667) [Link]

Welcome to the future!

Kernel tinification

Posted Sep 9, 2014 9:06 UTC (Tue) by oldtomas (guest, #72579) [Link]

How history repeats itself.

I haven't the reference ready, but I think it was in CACM's "Inside Risks" column, late in the last century: some computer at a port (of the naval kind) crashed repeatedly. It took some time to realize that the crashes came at a bi-weekly schedule. From there it was relatiely easy to correlate the crashes with the (regular) arrival of one military ship: its radar machinery confused the electronics of said computer.

Kernel tinification

Posted Aug 22, 2014 8:07 UTC (Fri) by micka (subscriber, #38720) [Link]

> we have to make it possible to build smaller kernels — perhaps as much as an order of magnitude smaller.

This packs a bit of precision. A binary ordre of magnitude ?

LTO

Posted Aug 22, 2014 9:28 UTC (Fri) by epa (subscriber, #39769) [Link] (4 responses)

Instead of (possibly buggy) link-time optimization, could you not concatenate all the source files into one enormous translation unit and compile that with optimization? If nothing else, it would be a great stress test for gcc. Perhaps even with today's large memory sizes (128 gigabytes, say) it is still not practical.

LTO

Posted Aug 22, 2014 10:54 UTC (Fri) by anselm (subscriber, #2796) [Link] (1 responses)

I'm not overly familiar with the Linux kernel source, but it seems to me that individual translation units (source files) might use »static« declarations at top level to keep identifiers local to that translation unit, which is a popular programming technique in C.

Simply concatenating everything to make one huge translation unit would presumably fail if a name is declared that way in two different source files.

.

LTO

Posted Aug 29, 2014 21:07 UTC (Fri) by nix (subscriber, #2304) [Link]

Not only do they do that -- they even do things like #include files that declare structure types with the same name but different members depending on #defines that vary per translation unit.

There's no *way* you can handle that in the same TU.

LTO

Posted Aug 28, 2014 9:01 UTC (Thu) by yoshi314 (guest, #36190) [Link] (1 responses)

i wonder if -whole-program can be used in final link stage.

LTO

Posted Aug 29, 2014 10:37 UTC (Fri) by jezuch (subscriber, #52988) [Link]

> i wonder if -whole-program can be used in final link stage.

Normally, no - because in the final link stage all you (normally) have are the already compiled and optimized object files. You need the source code in some form [also] available, and that's *exactly* what gcc's LTO does. There's not much more to it.

And, it's a lot less buggy than a few years ago.

Kernel tinification

Posted Aug 24, 2014 4:10 UTC (Sun) by dlang (guest, #313) [Link]

wireless access points have MB of flash and not that much memory (depending on the model, 16MB flash and 128MB ram is not uncommon), these are also cheap.

Such devices do have a need to read usb attached disks created on larger systems.

This isn't as tiny as what some people are aiming for, but trying to keep systems of this size running comfortably would go a fair ways towards the really tiny systems (especially since different people would want to be doing very different things with their APs, so they would be cutting out different parts of the kernel)

Kernel tinification

Posted Aug 29, 2014 13:50 UTC (Fri) by phuewe (guest, #71161) [Link]

How was the minimum kernel size shown in the diagram measured?

Also a real reference hardware would be a good thing, especially to get started.

Linux recommended / compatible RTOS

Posted Sep 2, 2014 23:32 UTC (Tue) by tdwebste (guest, #18154) [Link] (4 responses)

I am going to assume the simple statement is true.
"Linux can not run in the confined flash and ram of cortex-M0 and cortex-M4 ARM processors."

These processors are used in many IOT devices. Examples include nordic, stmicro cortex-M0 MCU with programmable ble radio, Toshiba cortex-M4 MCU with accelerometer, programmable ble radios, lcd controller.

What is the recommended opensource Linux compatible RTOS?
With compatible: Event queue, Asynchronous message queue, mailbox intercommunication.

Linux recommended / compatible RTOS

Posted Sep 3, 2014 0:47 UTC (Wed) by pizza (subscriber, #46) [Link] (2 responses)

> I am going to assume the simple statement is true.
> "Linux can not run in the confined flash and ram of cortex-M0 and cortex-M4 ARM processors."

It depends entirely on how much RAM and flash those parts have.

Many of these Cortex-M processors support the use of external RAM and flash. Those that do are generally capable of running uClinux; in particular there's mainline support for at least some of the EFM32 parts.

Linux recommended / compatible RTOS

Posted Sep 3, 2014 2:57 UTC (Wed) by tdwebste (guest, #18154) [Link] (1 responses)

I was hoping the discussion was NOT going to revolve around whether Linux can be shoe horned into cortex m0, m4 ARM processors.

cortex m0 processors are in extremely price sensitive markets, which makes external flash very undesirable. These processors usually have under 512k flash and 64k ram.
cortex m4 processors maybe able to run Linux. But there is many reasons not to. The main being the m4 and m0 are often performing similar applications. Applications that often need to be compiled without unused file system and networking support to reduced flash and ram requirements.

Currently running the same OS on cortex m0 and m4 ARM processors makes the most since.

It is increasingly common for a cortex-m0/4 to be connected by pcb/usb/serial bus to a more powerful ARM processor running Linux. The imx6 is a example combining ARM Cortex-A9 and Cortex-M4 cores.

Back to my original question.
Recommended opensource Linux compatible RTOS?
Compatible: Event queue, Asynchronous message queue, mailbox intercommunication.

Linux recommended / compatible RTOS

Posted Sep 3, 2014 11:31 UTC (Wed) by pizza (subscriber, #46) [Link]

> These processors usually have under 512k flash and 64k ram.

Indeed, 512/64 is actually a pretty high-end part.

> Recommended opensource Linux compatible RTOS?
> Compatible: Event queue, Asynchronous message queue, mailbox intercommunication.

In short, such a thing does not exist, at least not if you're looking to be API-compatible with Linux. Or even behaivorally-compatible.

Come to think of it, eCOS may be the closest, but by the time you enable all the nice APIs and features the RAM/Flash requirements are such that you may as well be running uClinux.

nuttx is pretty full-featured too at this point, and RTX has been freed by ARM and is actually bundled with CMSIS these days. Personally, I'm particularly fond of FreeRTOS, but it's fairly bare bones in comparison to the others.

Linux recommended / compatible RTOS

Posted Sep 15, 2014 17:22 UTC (Mon) by tinti (guest, #98866) [Link]

You may try Nuttx. I don't know how much compatible it is.

http://www.nuttx.org/


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