The Linux Plumbers Conference is this week, and since Android is one of the biggest distributors of the Linux kernel in the world, Google software engineer Todd Kjos stopped by for a progress report from the Android team. Android 12—which will be out any day now—promises to bring Android closer than ever to mainline Linux by shipping Google’s “Generic Kernel Image” (GKI) to end-users.
Traditionally, the Linux kernel is forked several times before it hits an Android phone, usually by each stakeholder in an Android device. First, Google forks the Linux kernel into “Android common”—the Linux kernel plus a bunch of phone- and Android-specific changes. Then SoC vendors like Qualcomm, Samsung, or MediaTek fork Android Common to make an SoC-specific kernel for each major chip release. Then each device gets a fork of the SoC kernel for device-specific hardware support.
Android’s kernel fragmentation is a huge mess, and you can imagine how long and difficult the road is for a bugfix at the top of the fork tree to reach to the bottom, where end-users live. The official Android.com documentation notes that “These modifications can be extensive, to the point that as much as 50% of the code running on a device is out-of-tree code (not from upstream Linux or from AOSP common kernels).” It’s also a big time sink, and even Google phones typically ship kernels that start at two years old.
Google has been on a journey to lessen the distance between Android and Linux with the GKI. The goal is for Google to fork the Linux kernel once for Android, instead of three times, and give SoC and device manufacturers space for their customizations via plug-in modules.
Kjos explained, “The big push is to get all of the hardware-specific code out of the generic kernel and into vendor modules. One of the big parts of this effort is that we have to have a stable interface between those vendor modules and the generic kernel so that they can ship asynchronously.” This interface is called the “KMI” or “Kernel Module Interface.” Kjos says now the “main difference” between the Android GKI and mainline Linux are hooks for all of these vendor modules.
Kjos says Google prefers short hooks for these vendor modules as opposed to out-of-tree code, because “we want to be as close to upstream as we possibly can.” Google is working on getting vendor code upstreamed, too, but admits, “this is a multi-year project, and we don’t expect we’ll ever get all the way there.” Kjos laid out a timeline for the next few years of kernel work, which has 2020-2022 as work toward upstreaming existing features and isolating vendor changes in modules, and starting in 2023, taking an “upstream first” development model for new features. “Since out-of-tree modules are really important for our use case, we expect we’ll always have a set of exports and some things that are different or in addition to what’s upstream, but this whole project is a multi-year project working towards getting rid of as many out-of-tree patches as we possibly can, and aligning as much as possible with upstream.”
Google’s Generic Kernel Image work is very much along the same lines as Project Treble, which built a GSI (or “Generic System Image”) allowing versions of Android to be updated independently of the hardware support. Today, you can flash a generic version of Android to a phone and have it mostly work, but the usual politics relating to OEM customizations has meant that Generic System Images don’t ship on consumer devices. The GKI is different though, and Google actually plans to ship generic kernels to end-users.
While not mentioned in the talk, Google is working on distributing the GKI as a “Project Mainline” module, which would allow for kernel updates shipped through the Play Store, where the kernel can be updated as easily as an app. We’ve interviewed members of the Android team several times about the GKI, and the plan, eventually, is to be able to update not just LTS kernel versions through the Play Store, but also upgrade to major new releases. Today, LTS kernel updates occasionally arrive via OTA updates, but devices typically don’t jump to major new kernel versions.
The timeframe for shipping the GKI to consumers is “Android 12,” and since this core kernel work only happens on new devices, all eyes will be on the Pixel 6 to see how ambitious Google’s first swing at this will be. The Pixel 6 is the first device to ship with an in-house “Google Tensor” SoC, and if the theories about longer Google support timelines are right, being able to jump major kernel versions would be a big help for support life cycles that exceed five years. Assuming the Pixel 6 ships with Linux kernel 5.10—which was called out several times in this talk—just that will be a big improvement over the usual two-year delay—5.10 was released in December 2020.
Listing image by SOPA Images / Getty Images