|
|
Log in / Subscribe / Register

Kernel development

Brief items

Kernel release status

The 3.10 merge window remains open; see the separate article below for a summary of what has been merged so far.

Stable updates: 3.9.1, 3.8.12, 3.4.44, and 3.0.77 were all released on May 7.

Comments (none posted)

Quotes of the week

My conclusion is that build and boot test systems just don't work in an open source environment as no one actively checks the results. Why would they - maintainers already have enough to do with reading 6500+ emails a month on mailing lists. Why bother going to look at a website as well which might give even more work.
— Russell King

When I first got involved in Linux, there was no PCI API (now called the hotplug or device API), and patch submission was a moderately painful process of throwing spaghetti at a wall: sending and resending, with both Linus and maintainers having to manually resolve merge conflicts. <shiver>

It was a real fight to get any Linux hardware support at all. The vast amount of hardware documentation was locked away or simply unavailable.

Working on memory management or filesystems or scheduling was always the Sexy Rock Star PhD work that attracted engineers. OTOH, I felt, device drivers were ignored as boring, unsexy grunt work. Which, ok, maybe it was. Each new device driver, though, spread Linux to more and greater locales. Alan Cox and Don Becker did enormous heavy lifting back then. Now Linux is where it is today, with most hardware vendors actively seeking open source driver support (except NVIDIA, natch). The kernel has come a long way.

Time for new open source pastures outside the kernel, for me.

— Jeff Garzik moves on

It is hard to overstate how pleased we are with these results. Particularly after our first dbench tests a couple of days ago were embarrassing: more than five times slower than Ext4. The issue turned out to be inefficient inode allocation. Hirofumi changed the horribly slow itable btree search to a simple "allocate the next inode number" counter, and shazam! The slowpoke became a superstar. Now, this comes with a caveat: the code that produces this benchmark currently relies on this benchmark-specific hack to speed up inode number allocation. However, we are pretty sure that our production inode allocation algorithm will have insignificant additional overhead versus this temporary hack.
— Daniel Phillips claims to outperform tmpfs

Linux remains a benchmark for quality. Since the original Coverity Scan report in 2008, scanned versions of Linux have consistently achieved a defect density of less than 1.0, and versions scanned in 2011 and 2012 demonstrated a defect density below .7. In 2011, Coverity scanned more than 6.8 million lines of Linux code and found a defect density of .62. In 2012, Coverity scanned more than 7.4 million lines of Linux code and found a defect density of .66. At the time of this report, Coverity scanned 7.6 million lines of code in Linux 3.8 and found a defect density of .59.
— Coverity

Comments (5 posted)

Kernel development news

What's coming in 3.10, part 2

By Jonathan Corbet
May 8, 2013
As of this writing, 10,892 non-merge changesets have been pulled into the mainline repository for the 3.10 development cycle, nearly 5,800 since last week's summary. That does not yet make 3.10 the busiest merge window ever, but chances are good that the current record holder (3.8, at 10,901 changesets) will be surpassed in the very near future. In other words, there has been a lot going on.

User-visible changes merged since last week's summary include:

  • The "full dynamic tick" patch set has been merged, allowing non-idle CPUs to run without the periodic timer interrupt in some situations. See this article for more information about this feature.

  • The TCP stack has gained support for the tail loss probe algorithm, which can speed recovery when a packet is dropped at the end of a connection. Many connections are short and latency-sensitive, so tail loss has a bigger effect than one might think. From the commit: "The TLP patch series have been extensively tested on Google Web servers. It is most effective for short Web transactions, where it reduced RTOs [retransmission timeouts] by 15% and improved HTTP response time (average by 6%, 99th percentile by 10%)."

  • The batman-adv mesh networking subsystem now supports "network coding," a mechanism that can, in some situations, transmit two packets to two destinations simultaneously by exclusive-ORing them together.

  • The TCP cookie transactions mechanism has been removed. It was never fully implemented and had a performance cost.

  • The IPv6 protocol is now supported over IEEE 1394 ("Firewire").

  • The netlink interface now supports memory-mapped I/O, eliminating the need to copy data between user and kernel space. Unsurprisingly, this involves the addition of yet another ring buffer implementation to the kernel. See Documentation/networking/netlink_mmap.txt for details.

  • The "single zImage" goal for the ARM architecture is getting closer; several more platforms have gained multiplatform support. The biggest holdout at this point is Samsung's Exynos, which was reverted prior to the pull request because it turned out not to be quite ready.

  • The XFS filesystem continues to gain checksums and other identifying information in all metadata blocks, aiding filesystem consistency checks and the cleanup process if something goes wrong. The new documentation file Documentation/filesystems/xfs-self-describing-metadata.txt has more information about this work and its goals.

  • The ARM multi-cluster power management patch set has been merged, clearing the way for further big.LITTLE support, including the just-posted in-kernel switcher code.

  • The Ceph filesystem has new support for RBD layering, essentially a mechanism for the quick creation of copy-on-write clones of filesystem snapshots.

  • Various tweaks to the reader/writer semaphore code have led to some impressive performance improvements for some workloads. Pgbench results improved as much as 100% in one case.

  • New hardware support includes:

    • Boards and processors: Atmel SAMA5D3 processors, Freescale T4240 QDS and B4 QDS boards, Renesas R8A73A4, R8A7778, and R8A7790 processors, and Freescale i.MX6 DualLite/Solo processors.

    • Audio: TI TAS5086 codecs and Asahi Kasei AK5386 codecs.

    • Input: IMS passenger control units (in-seat controllers for airline entertainment systems).

    • Miscellaneous: Samsung S3C64XX SoC pin controllers, VIA VT8500 and Wondermedia WM8xxx-series pinmux/gpio controllers, Freescale SAHARA crypto accelerators, Broadcom BCM2835 random number generators, ChromeOS embedded I2C, SPI, and keyboard controllers, Silicon Laboratories 4761/64/68 AM/FM radios, NVIDIA Tegra host1x DMA engines, Aeroflex Gaisler GRGPIO cores, TI LP5562 LED controllers, Samsung S3C, S5P and Exynos SoC PWM timers, Renesas R-Car GPIO controllers, and TI DA8xx/OMAP-L13x remote processors.

    • Networking: Ralink RT5572 wireless network interfaces, Realtek RTL8188EE wireless network adapters, and Realtek RTL8152-based Ethernet adapters.

    • Virtualized: CAIF link layer over virtio and QXL virtual GPUs.

Changes visible to kernel developers include:

  • NAPI-using network drivers that set themselves up with a weight greater than 64 will generate a user-visible warning. Larger weights can create unfairness on systems with multiple interfaces; they can also interfere with the proper functioning of the byte queue limits mechanism.

  • The I2C layer has a new bus arbitration module for multi-master situations and a new bus recovery infrastructure as well.

  • The ALSA ASoC subsystem has a new generic dmaengine_pcm driver that is able to replace a lot of platform-specific PCM implementations.

  • Developers wanting to tweak the randomness of "randconfig" builds can do so with the new KCONFIG_PROBABILITY environment variable.

  • The release() function in struct block_device_operations now returns void.

  • There is a new "reset controller" driver class. Reset controllers are able to force-reset another system component by way of a mechanism like a GPIO line.

A two-week merge window would close on May 13. Given the volume of code merged so far, though, it would not be at all surprising if Linus declared the end a little sooner than that.

Comments (2 posted)

(Nearly) full tickless operation in 3.10

By Jonathan Corbet
May 8, 2013
On a typical Linux system, each running CPU will be diverted between 100 and 1000 times each second by the periodic timer interrupt. That interrupt is the CPU's cue to reconsider which process should be running, catch up with read-copy-update (RCU) callbacks, and generally handle any necessary housekeeping. This periodic "tick" can be reasonably compared to the infamous big kernel lock (BKL): it is convenient to have around, but it also has an effect on performance that makes developers wish to abolish it. The key difference might be that getting rid of the timer tick has taken rather longer than was required to eliminate the BKL. The 3.10 kernel will take an important step in that direction, though, with the addition of the "full NOHZ" mode — but a lot of limitations still apply.

Linux has had a partial solution to the timer tick problem for years in the form of the CONFIG_NO_HZ configuration option. If that option is set, the timer tick will be turned off, but only when the CPU is idle. This mode improves the situation considerably; it allows idle CPUs to stay in deep sleep states, reducing power use. Systems with virtualized guests also benefit, since, otherwise, each guest would be servicing timer interrupts when it should be doing nothing. In short: disabling the timer tick when the processor is idle makes enough sense that most distributions do it by default.

Indeed, given that letting sleeping CPUs lie is generally a good policy, one might wonder why this behavior is optional at all. The answer is that it increases the cost of moving into and out of the idle state, (very) slightly increasing the time it takes to get an idle CPU back to work. That cost may be considered excessive in highly latency-sensitive environments. For everybody else, disabling the timer tick for idle CPUs is almost certainly the right thing to do; for battery-powered systems that is doubly true.

The next step — disabling the tick for non-idle processors — is a lot more work with a smaller reward, so it is not surprising that it has taken a while to come about. Frederic Weisbecker finally took up the challenge in 2010; after a lot of changes and help by others (Paul McKenney made some significant RCU changes, for example), this work has been pulled into the 3.10 kernel.

In 3.10, the CONFIG_NO_HZ option has been replaced by a three-way choice:

  • CONFIG_HZ_PERIODIC is the old-style mode wherein the timer tick runs at all times.
  • CONFIG_NO_HZ_IDLE (the default setting) will cause the tick to be disabled at idle, the way setting CONFIG_NO_HZ did in earlier kernels.
  • CONFIG_NO_HZ_FULL will enable the "full" tickless mode.

The build-system code has been set up so that "make oldconfig" on 3.10 should yield a configuration that matches the previous setting of CONFIG_NO_HZ with no intervention required. Full tickless mode defaults to off; selecting that mode will enable tasks to run without the timer tick, but there are a number of things to be aware of.

Among those are the requirement that the CPUs available for running without a timer tick must be designated at boot time using the nohz_full= command-line parameter. The boot CPU cannot run in this mode — at least one CPU needs to continue to receive interrupts and do the necessary housekeeping. The CONFIG_NO_HZ_FULL_ALL configuration option causes all CPUs (other than the boot CPU) to run in the full tickless mode by default; it can still be overridden with nohz_full=, though. The set of full tickless CPUs cannot be changed after boot; the amount of work required to make that possible would be large, and there does not seem to be a pressing need for this ability.

Even then, a running CPU will only disable the timer tick if there is a single runnable process on that CPU. As soon as a second process appears, the tick is needed so that the scheduler can make the necessary time-slice decisions. And even with a single runnable process, it is not technically tickless, since the timer tick still needs to happen at least once per second to keep the scheduler happy. But dropping from as high as 1000Hz to 1Hz is obviously a significant improvement. Response-time jitter due to timer interrupts will be nearly eliminated, and, according to Ingo Molnar, as much as 1% of the CPU's time will be saved.

There are workloads out there that will benefit significantly from those improvements. High-performance computing (HPC) and realtime are obvious candidates; in both cases, dedicating a CPU to a single task is a fairly common tactic already. But, in an era where even phones have quad-core processors, having a single runnable process on a given CPU is not an uncommon situation.

There are a lot more details to making full tickless operation work properly; setting up a system to use this feature requires a fair amount of fiddling at this time. At a minimum, the administrator should make extensive use of CPU affinities to keep unwanted processes (including kernel threads) off the relevant processors. Some RCU configuration is required as well; see Documentation/timers/NO_HZ.txt for lots of details on the various options.

Full tickless operation, as seen in 3.10, is clearly a significant step forward, but, equally clearly, this project is not yet complete. There is a fair amount of detail work to be done, including making the feature work on 32-bit processors (a patch exists), getting rid of that final once-per-second tick, mitigating some unfortunate side effects on the scheduler's statistics and load balancing, and fixing the inevitable bugs. This is a large and invasive change to how the core kernel works; there will almost certainly be some surprising behaviors that emerge once the tickless mode starts to get wider testing.

The biggest item on the "to do" list, though, must surely be getting rid of the single-runnable-process requirement. Just in case the developers involved did not already feel that way, Linus made his opinion on the matter clear:

So as long as the NOHZ is for HPC-style loads, then quite frankly, I don't feel it is worth it. The _only_ thing that makes it worth it is that "future plans" part where it would actually help real loads.

So, chances are, this limitation will be removed from the tickless implementation in some future development cycle, along with the other various rough edges. In the meantime, the 3.10 kernel will contain a significant step forward in the evolution of the core Linux kernel: the partial removal of a source of latency and overhead that has been there since the very first kernel release. Not even the big kernel lock endured anywhere near that long.

Comments (34 posted)

LFCS: The LLVMLinux project

By Jake Edge
May 7, 2013

The Linux Foundation Collaboration Summit (LFCS) seems to be a likely venue for an update on the status of building the kernel with Clang/LLVM. Both in 2011 and 2012, we covered those updates. LFCS 2013 continued the trend as LLVMLinux project lead Behan Webster presented the status and plans for the project at LFCS. The gathering lived up to its name as well, since two problems faced by the project were solved through collaboration at the summit.

[LLVMLinux logo]

Webster is a computer engineer who has worked in a lot of different industries: automotive, telecommunications, embedded systems, etc. For 20 years or so, he has worked on Linux, using it either as a development environment or as the operating system of a shipping product. He is the project lead for the LLVMLinux project, which is an effort to get the Linux kernel to build with Clang and LLVM.

LLVM is a set of libraries that can be used to build tools, he said. Those tools could be compilers, linkers, or JITs, or they could be tools for source code analysis, metadata extraction, code refactoring, and so forth. Most of the latter kinds of tools don't directly relate to LLVMLinux, but the toolchain for building C, C++, and Objective C programs does. The toolchain starts with Clang, the frontend for C-family programs, but there are other pieces as well, including the compiler-rt library, lld and MCLinker linkers, checker static analyzer, LLDB debugger, and others.

Why?

There are a number of reasons, beyond just simply having a choice, that make compiling Linux with LLVM a useful endeavor. For one thing, it compiles faster, which is important to reduce the time of the code-compile-run-debug cycle. LLVM is a fast-moving project, Webster said, and it is "amazing how fast Clang has caught up" to GCC in some areas. It generates faster code than GCC in some areas—slower code in others.

LLVM is already being used in many different domains, like audio and video in such projects as llvmpipe, CUDA, and Renderscript. There is an advantage to having a single toolchain used in all of these different domains as compiler extensions only need to be written once and can then apply in lots of different places. LLVM also has a different license—BSD-style—which is not better or worse than others, Webster said, but it allows tool vendors to do things with LLVM that they couldn't with GCC. LLVM is also well-supported by a large group of full-time developers.

The static analyzer for LLVM is "amazing", though it does not yet work on the kernel code. This tool has traditionally done better than other, similar tools. One of the headline features is "fix-it hints", which are suggestions for fixing small, localized problems in the source; a similar feature now appears in GCC 4.8. That is one example where we are seeing "more and better" development from both projects because of the competition between them, Webster said.

The Google compiler team has built a tool around LLVM that shows a novel use of the compiler toolkit. The tool looks for common problems that appear as certain patterns in the LLVM intermediate representation and can map them back to the C++ code to show the programmer where they made an error. This shows things that you can do that we haven't seen before, he said.

Beyond Android's use of LLVM for Renderscript and Gallium3D's llvmpipe driver, there are also distributions looking at building all or parts of their repositories using LLVM. For Debian, Sylvestre Ledru has been building the repository using Clang. His most recent results show that there are more failures than before, Webster said, because new versions of Clang are more strict. Gentoo is looking at support for LLVM/Clang, as is FreeBSD.

LLVMLinux

The goal of the LLVMLinux project is to get to the point where the kernel will build with LLVM. Ultimately, that means that LLVM would have everything it needs to build the kernel, while the kernel would get any changes it requires so that it can be built with LLVM.

To that end, the project has a Git repository for its build framework that contains scripts and patches to build the kernel. The scripts fetch, patch, and build various pieces, like LLVM/Clang, toolchains for cross assembly and linking, the kernel, and QEMU.

Several cross-toolchains are supported, including Codesourcery (which is the default), Linaro/Ubuntu, and Android. Those are necessary for the GNU assembler and linker, as those pieces for LLVM are not yet mature enough to use for building the kernel. There is support in the project's tree for various targets, including Versatile Express, x86-64, Raspberry Pi, and Nexus 7. There are other targets in progress, including the Galaxy S3 and BeagleBone.

The project is using Buildbot for continuous integration. Any time there is a commit in the project, LLVM, or kernel repositories, a full build is kicked off. In addition, the Linux Test Project suite is run nightly using QEMU for the Versatile Express.

Problem areas

Getting to this point has been "challenging", Webster said, as there are a number of difficulties the project has run into. To start with, LLVM's integrated assembler (IA) can't be used on kernel code because it doesn't handle the format used by the kernel's assembly code. In addition, IA does not handle 16-bit code. Building would be faster using IA, he said, but that's just not possible right now, which results in a dependency on the GNU toolchain.

The Linux code is GCC-specific in a number of ways. GCC (and thus the kernel) conforms to the gnu89 standard, while Clang conforms to gnu99 (which is "essentially C99" with some GCC additions). Webster thinks that a future version of GCC will move to C99, which will help. Kernel developers have long said that the standard is insufficient, so the kernel code goes beyond it in various ways. But, the standards have largely caught up, he said, though there are still some "notable exceptions". It is almost as if the Linux kernel has been driving the C standards.

Beyond that, there are some GCC flags that the kernel uses which are not supported by Clang. Some of the built-in functions are very different between Clang and GCC. Another problem area is Kbuild, which is also GCC-specific. In particular, unsupported flags cause different return values from GCC and Clang. In both cases, a warning is issued, but the different return code causes problems.

There are several GCC flags that are not supported by Clang, including -fconserve-stack, -fdelete-null-pointer-checks, -fno-inline-functions-called-once, and -mno-thumb-interwork. More details on these can be found in the slides [ODP] from Webster and Mark Charlebois's 2012 Linux Plumbers Conference talk.

There are a handful of GCC language extensions that will never be part of LLVM/Clang, he said, including variable-length arrays in structures (VLAIS). Zero-length arrays at the end of structures are supported, as are variable-length arrays outside of structures, but constructs like:

    struct foo {
        char a[n];
    } bar;
are not allowed by C99 or the more recent C11. The LLVM developers are not inclined to add VLAIS, as it makes the compiler harder to maintain, so LLVMLinux has to try to convince kernel developers to remove them. Currently, iptables, cryptographic hashing (HMAC), and a few other places use VLAIS and the maintainers like the code the way it is, Webster said. But the project has been running some tests on alternatives and getting the same or slightly better performance by switching away from VLAIS.

A member of the audience asked if it made sense to fork Clang to add VLAIS support, but Webster downplayed that option. All of the Clang developers are of a single mind about this particular feature, he said, though they would be supportive of a fork if someone decided to take that path. In the end, it comes down to changing "dozens of lines" of kernel code versus a "significant architectural change" in the LLVM toolchain. Turning the arrays into pointers is an easy way to fix the problem, but some maintainers don't want to take changes just to support a different compiler, he said, in answer to follow-on questions.

Nested functions are another problem area, but they are used infrequently. In general, when patches come in that have nested functions, the kernel developers have pushed back and asked for a rewrite. However, the Thinkpad ACPI driver still has nested functions, though Webster sent a patch to change that. He has not yet heard back, but it is just a rearrangement of the code, without any functional change.

Neither of those two features are in the C standard, nor are they used very frequently in the kernel. It would be relatively easy to not require them. The other extensions used by the kernel are "innocuous and simple", he said. For example, Clang does not support variables explicitly assigned to specific CPU registers, but he would like to see that support get added.

A recently discovered bug in Clang's C preprocessor is behind a problem with section reference mismatches. The attributes being used to put __init and __exit functions into different ELF sections are being mishandled. Webster "firmly believes" that the kernel pushes the tools harder than any other code base, and this is one example where that pushing has found bugs. It is probably just a corner case that had not been tested (or exercised by other code built with Clang), resulting in various "section reference mismatch" and "merged global" messages (as well as kernel module loading problems on x86) when the kernel was linked.

Webster then mentioned __builtin_const_p(), which GCC makes available to test whether the argument is a constant value, but LLVM cannot support as it cannot really make that distinction. At that point, Steven Rostedt started poking around in the kernel code, asking the occasional question. In a post-summit email, Webster said that Rostedt tracked the use of __builtin_const_p() down to a particular commit in mm/slab.c made by Christoph Lameter, who was also present at the summit. Within 24 hours, Rostedt and Lameter worked out a replacement; Rostedt was even able to run it by Andrew Morton, who agreed in principle to the change.

Status

For LLVM, all required patches from the project are now upstream. There are still some outstanding issues, including the section reference mismatch problem above. He believes that Clang 3.3 will mostly work out of the box for building kernels with the LLVMLinux patches.

Another outstanding issue is a segmentation fault in Clang when it is compiling arch/arm/mm/context.c. That problem seemed to be related to using atomic_64 operations along with nearby inline assembly code and Webster was having difficulty creating a simple test case. After the talk, another attendee, Konstantin Serebryany, suggested using creduce, which is an LLVM-based tool that can bisect code to try to find a minimal subset that reproduces a problem. By the time Webster started figuring out the tool later that day, Serebryany had attached a minimal test case to the bug report. Within another few days, it was fixed in the LLVM tree. In his email, Webster paraphrased the famous saying by noting that LFCS showed him that "the right eyes make bugs shallow".

There are still some kernel patches that need to be pushed upstream as well. Kbuild support, removing VLAIS use, handling __builtin_const_p(), and so on, all need solutions either in the upstream kernel or elsewhere.

It is not strictly necessary, but he would like to use the LLVM integrated assembler for its speed, too. Getting the checker static analyzer to run on the kernel would be useful as well.

Anyone wanting to help will find a variety of ways to do so, Webster said. Helping to push patches upstream or work on unsupported features is one way. In addition, LLVMLinux is just working for x86 and ARM right now, adding MIPS and other architectures would be nice. As might be guessed, interested folks will find information on mailing lists, IRC, and more on the project's web page.

Comments (18 posted)

Patches and updates

Kernel trees

Greg KH Linux 3.9.1 ?
Greg KH Linux 3.8.12 ?
Sebastian Andrzej Siewior 3.8.11-rt8 ?
Steven Rostedt 3.6.11.2-rt34 ?
Greg KH Linux 3.4.44 ?
Steven Rostedt 3.4.42-rt57 ?
Steven Rostedt 3.2.44-rt65 ?
Greg KH Linux 3.0.77 ?
Steven Rostedt 3.0.75-rt103 ?

Architecture-specific

Core kernel code

Device drivers

Documentation

Michael Kerrisk (man-pages) man-pages-3.51 is released ?

Filesystems and block I/O

Memory management

Security-related

Page editor: Jonathan Corbet
Next page: Distributions>>


Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds