|
|
Subscribe / Log in / New account

A different approach to kernel configuration

By Jonathan Corbet
September 12, 2017

Open Source Summit
The kernel's configuration system can be challenging to deal with; Linus Torvalds recently called it "one of the worst parts of the whole project". Thus, anything that might help users with the process of configuring a kernel build would be welcome. A talk by Junghwan Kang at the 2017 Open-Source Summit demonstrated an interesting approach, even if it's not quite ready for prime time yet.

Kang is working on a Debian-based, cloud-oriented distribution; he wanted to tweak the kernel configuration to minimize the size of the kernel and, especially, to reduce its attack surface by removing features that were not needed. The problem is that the kernel is huge, and there are a lot of features that are controlled by configuration options. There are over 300 feature groups and over 20,000 configuration options in current kernels. Many of these options have complicated dependencies between them, adding to the challenge of configuring them properly.

Kang naturally turned to the work that others have already done in an attempt to simplify his kernel-configuration task. One interesting project is undertaker-tailor (also known as "the valiant little tailor"), a project that came out of the VAMOS project. This tool uses the ftrace tracing mechanism to watch a kernel while the system runs a representative workload. From the resulting traces, it concludes which parts of the kernel are actually used, finds the configuration options controlling those [Junghwan Kang] parts, then generates a configuration that only includes the needed subsystems. This system, Kang said, is novel, but "incomplete".

In particular, undertaker-tailor has a number of bugs; "it doesn't work and needs an overhaul". Kang tracked down and fixed some of the bugs, sending his fixes upstream in the process. The tool was badly confused by address-space layout randomization, for example. He fixed a few issues until he could get a configuration out of it. Unfortunately, the resulting kernel failed to boot. It turns out that this tool requires the user to spend some time setting whitelists and blacklists, but that brings the user back to the original configuration issue.

Another tool for trimming down a kernel configuration is the make localmodconfig command. It simply looks at the modules loaded into the running kernel and assumes that each is there because something needed it. It generates a kernel configuration that builds in those modules and leaves out the rest. This approach did create a working kernel, but that kernel was still "fat", with numerous features configured in that were not really needed.

So Kang went off to create a solution of his own. He wanted to come up with an automated system that would create a minimally sized but working kernel for his specific workload. His solution uses undertaker-tailor to collect system traces with the use cases of interest running. But then a separate "tailoring manager" runs to create the configuration from the trace data. As was the case before, this configuration is unlikely to boot and run properly. So another process works to "fill in" configuration options until the kernel eventually works.

This filling-in stage uses the localmodconfig configuration as a starting point; it thus won't fill in options that are already known not to be necessary. The first stage looks at warnings from the configuration system itself, adding options until the warnings are addressed. Then kernels are built and tested using Xnee to simulate a desktop session. There is also a hand-built blacklist used to explicitly exclude some options.

This process, which involves building and testing a lot of kernels in virtual machines, takes about five hours to run. It generates a kernel that is quite a bit smaller than what make localmodconfig provides, with almost all modules configured out. As a bonus, this kernel boots in 1/5 of the time.

Future steps include creating a larger set of workloads to be sure that all use cases for this distribution have been addressed. At some point, Kang also plans to add support for kernels running on bare metal; currently, only virtualized kernels can be configured in this way. Even now, though, he said that the resulting tool is useful for non-expert kernel users who are trying to build a kernel using something smaller than a kitchen-sink distribution configuration. Those users will have to wait, though, since Kang has not yet released this project to the world; he said he would like to do that once he receives management approval.

Postscript

Presentations of this type are often as useful for the problem they pose as for the solutions they present. In this case, it's not entirely clear that "non-expert users" will find it easier to create representative workloads that cover all needed tasks, run them with a kernel under tracing, create a suitable blacklist, and generate their final configuration. The task still seems daunting.

The problem is not Kang's solution, though; the problem is that he was driven to create such a solution just to get through the task of configuring a kernel to his needs. The kernel's configuration system is, indeed, one of the worst parts of the project. But it is also a part that nobody is really working on; it receives a bit of maintenance, but there does not appear to be any significant effort out there to address its shortcomings. Two-hundred companies support work on each kernel development cycle, but none of them see the configuration system as one of the problems that they need to solve. Until that changes, we are likely to continue to see users struggling with it.

[Thanks to the Linux Foundation, LWN's travel sponsor, for supporting your editor's travel to the Open Source Summit.]

Index entries for this article
KernelBuild system/Kernel configuration
ConferenceOpen Source Summit North America/2017


to post comments

A different approach to kernel configuration

Posted Sep 12, 2017 12:26 UTC (Tue) by WolfWings (subscriber, #56790) [Link] (5 responses)

Honestly the largest obstacle to kernel configuration is the menuconfig tool hasn't kept up.

Some newer systems are arbitrary such as picking a compression or encryption algo at random as 'required' despite the actual code not requiring any single algo, just AT LEAST ONE algo existing from a large set.

Others are setup one-way (the USB <-> networking <-> wireless trifecta for example) for the requirements so if you don't disable things in the correct order you can't disable other things.

And there are numerous "top level items" that could be pushed down a level (or two!) to organize the tree structure in a more 'discoverable' way.

A lot of it is improved Kconfig's being needed IMHO; the existing actual tools are well thought out, but Kconfig's aren't reviewed anywhere near as much as the functional code I feel, so a LOT of really bad cruft and cargo-cult scripting has ended up in those over the years since the syntax seems entirely unique and unrelated to anything else.

A different approach to kernel configuration

Posted Sep 12, 2017 12:46 UTC (Tue) by tao (subscriber, #17563) [Link] (4 responses)

Yeah, the config system is a nightmare, especially when new options are introduced--the choices of what to default to N or Y by default seems arbitrary at best. defconfig should probably default to a modern machine.

A different approach to kernel configuration

Posted Sep 12, 2017 21:35 UTC (Tue) by rodgerd (guest, #58896) [Link] (3 responses)

At this point the defconf would probably be most accurate as a Xen or KVM guest.

A different approach to kernel configuration

Posted Sep 13, 2017 3:15 UTC (Wed) by Frogging101 (guest, #113180) [Link] (2 responses)

They already have kvmconfig and xenconfig.

In my opinion, the defconf should enable the components that one could reasonably expect to find on an x86 desktop or server system, and disable the more exotic drivers that one would never find on such a system to reduce the number of unnecessary components in a build.

A different approach to kernel configuration

Posted Sep 13, 2017 15:10 UTC (Wed) by Frogging101 (guest, #113180) [Link]

Actually, I don't even care what the defconfig is. But a "generic x86 desktop" config would be nice. My current method to get a base config for my desktop is to download a Debian or Ubuntu kernel .deb and extract the config.

You can get said debs at https://packages.debian.org/unstable/kernel/linux-image-a... or http://kernel.ubuntu.com/~kernel-ppa/mainline/?C=N;O=D . Make an empty directory to extract it to, and run dpkg -x <deb file> <destination dir>. Look in boot/ under the destination for the config. Copy it to your kernel tree as .config. If it's an older config, run "yes '' | make oldconfig" before using it.

A different approach to kernel configuration

Posted Sep 13, 2017 23:16 UTC (Wed) by Yui (guest, #118557) [Link]

Or perhaps distro-specific minimal configurations like Linus proposed five years ago. This would at least make the job of people who are working on a distro based on an existing one a bit easier.

https://lkml.org/lkml/2012/7/13/369

A different approach to kernel configuration

Posted Sep 12, 2017 16:45 UTC (Tue) by marduk (subscriber, #3831) [Link] (3 responses)

I'm really looking forward to using a tool like this. I have been hand-tuning kernels for years but there's always something in the back of your head that makes you wonder if you really needed option A or if you left out option B which you could have really benefited from. It's true that the config subsystem has grown so large that it's gotten out of control. It's going to require an overhaul and a fresh set of eyes to really make it into something impressive. But like the article states there is little demand upstream, or downstream for that matter.

A different approach to kernel configuration

Posted Sep 14, 2017 3:20 UTC (Thu) by csigler (subscriber, #1224) [Link] (2 responses)

> ... the config subsystem has grown so large that it's gotten out of control.

Paging ESR... paging Mr. ESR.... ;-)

A different approach to kernel configuration

Posted Sep 14, 2017 4:00 UTC (Thu) by edgewood (subscriber, #1123) [Link] (1 responses)

I had the exact same thought when I first read the article. I was surprised there wasn't a reference to Aunt Tilly in it!

A different approach to kernel configuration

Posted Sep 15, 2017 3:44 UTC (Fri) by csigler (subscriber, #1224) [Link]

This just shows how old we both are... :-(

A different approach to kernel configuration

Posted Sep 13, 2017 3:23 UTC (Wed) by pabs (subscriber, #43278) [Link] (1 responses)

Did Kang mention which distro he is working for?

A different approach to kernel configuration

Posted Sep 13, 2017 23:24 UTC (Wed) by montj2 (guest, #111739) [Link]

I could not find a definitive answer, but I am left to believe it is something private for his current position at the National Security Research Institute of South Korea. Were you able to find more?

A different approach to kernel configuration

Posted Sep 13, 2017 4:31 UTC (Wed) by unixbhaskar (guest, #44758) [Link] (2 responses)

I am looking forward to such a thing to come up. I have been hand-tuning kernel for many years now and it is a cumbersome process, but you gain a lot of insight about it. But having a tool like this would have certainly help lesser mortals better time.

A different approach to kernel configuration

Posted Sep 13, 2017 18:40 UTC (Wed) by Tara_Li (guest, #26706) [Link] (1 responses)

Perhaps if the tool scanned the hardware first, and then generated a "suggested config" that could then be tweaked - bonus points if it includes comments on what it found and why it suggested that configuration - and even a "Found nVidia graphics chipset - would you like to use the free nouveau driver, or will you be installing the nVidia proprietary driver later?"

A different approach to kernel configuration

Posted Sep 14, 2017 19:05 UTC (Thu) by flussence (guest, #85566) [Link]

Graphics drivers are particularly annoying here. You either want everything for a distro kernel, or want a very specific one for a custom kernel. But unlike (say) sound cards, the latter's not an option — you need to compile in support for all nVidia cards or all Radeons or all Intel chips. My /boot/vmlinuz is growing almost a megabyte per year because of it.

A different approach to kernel configuration

Posted Sep 13, 2017 16:15 UTC (Wed) by edeloget (subscriber, #88392) [Link]

This is indeed an interesting approach but it's limited to a single use case - rebuilding a config for a kernel that suits you.

I would love to see someone try to tackle the need for a simpler configuration tool. Creating a booting kernel for an esoteric custom board is a hard task even for expert themselves, and its has to do with how the kernel config is organized (not how menuconfig works).

A different approach to kernel configuration

Posted Sep 14, 2017 11:43 UTC (Thu) by smitty_one_each (subscriber, #28989) [Link]

> As a bonus, this kernel boots in 1/5 of the time.

Time being frog$kins, a more rapidly available cloud image is a right jolly awesome thing.


Copyright © 2017, 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy