Linux kernel interfaces

Linux kernel APIs and ABIs


title: "Linux kernel interfaces" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["interfaces-of-the-linux-kernel"] description: "Linux kernel APIs and ABIs" topic_path: "technology/operating-systems" source: "https://en.wikipedia.org/wiki/Linux_kernel_interfaces" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0

::summary Linux kernel APIs and ABIs ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/6/68/Linux_kernel_interfaces.svg" caption="Linux API, Linux ABI, and in-kernel APIs and ABIs"] ::

The Linux kernel provides multiple interfaces to user-space and kernel-mode code. The interfaces can be classified as either application programming interface (API) or application binary interface (ABI), and they can be classified as either kernel–user space or kernel-internal.

{{Anchor|Linux API}}Linux API

::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/43/Linux_API.svg" caption="publisher=[[freedesktop.org]]}} (by [[freedesktop.org]])."] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/43/Linux_kernel_API.svg" caption="Linux API vs. [[POSIX]] API"] ::

The Linux API includes the kernel–user space API, which allows code in user space to access system resources and services of the Linux kernel.{{cite web | url = https://www.linux.it/~rubini/docs/ksys/ksys.html | title = Kernel System Calls | date = 2006-11-02 | access-date = 2014-11-11 | author = Alessandro Rubini | website = linux.it

The Linux API, by choice, has been kept stable over the decades through a policy of not introducing breaking changes; this stability guarantees the portability of source code.{{cite web | url = https://lkml.org/lkml/2012/12/23/75 | title = Re: [Regression w/ patch] Media commit causes user space to misbahave (was: Re: Linux 3.8-rc1) | date = 2012-12-23 | access-date = 2014-08-26 | author = Linus Torvalds | publisher = Linux kernel mailing list | quote = If a change results in user programs breaking, it's a bug in the kernel. We never EVER blame the user programs.

Much available free and open-source software is written for the POSIX API. Since so much more development flows into the Linux kernel as compared to the other POSIX-compliant combinations of kernel and C standard library, the Linux kernel and its API have been augmented with additional features. Programming for the full Linux API, rather than just the POSIX API, may provide advantages in cases where those additional features are useful. Well-known current examples are udev, systemd and Weston. People such as Lennart Poettering openly advocate to prefer the Linux API over the POSIX API, where this offers advantages.

At FOSDEM 2016, Michael Kerrisk explained some of the perceived issues with the Linux kernel's user-space API, describing that it contains multiple design errors by being non-extensible, unmaintainable, overly complex, of limited purpose, in violation of standards, and inconsistent. Most of those mistakes cannot be fixed because doing so would break the ABI that the kernel presents to the user space.

{{Anchor|System Call Interface|SCI}} System call interface of the Linux kernel

The system call interface of a kernel is the set of all implemented and available system calls in a kernel. In the Linux kernel, various subsystems, such as the Direct Rendering Manager (DRM), define their own system calls, all of which are part of the system call interface.

Various issues with the organization of the Linux kernel system calls are being publicly discussed. Issues have been pointed out by Andy Lutomirski, Michael Kerrisk and others.

The C standard library

::figure[src="https://upload.wikimedia.org/wikipedia/commons/4/45/Linux_kernel_System_Call_Interface_and_glibc.svg" caption="The [[GNU C Library]] is a wrapper around the Linux kernel system call interface."] ::

A C standard library for Linux includes wrappers around the system calls of the Linux kernel; the combination of the Linux kernel system call interface and a C standard library is what builds the Linux API. Some popular implementations of the C standard library are

Although the landscape is shifting, amongst these options, glibc remains the most popular implementation, to the point of many treating it as the default and the term equivalent to libc.

Additions to POSIX

As in other Unix-like systems, additional capabilities of the Linux kernel exist that are not part of POSIX:

  • cgroups subsystem, the system calls it introduces and libcgroup
  • The system calls of the Direct Rendering Manager, especially the driver-private ioctls for the command submission, are not part of the POSIX specifications.
  • Advanced Linux Sound Architecture could set system calls, which are not part of the POSIX specifications
  • The system calls [futex](futex) (fast userspace mutex), [epoll](epoll), [splice](splice-system-call), [dnotify](dnotify), [fanotify](fanotify), and [inotify](inotify) have been exclusive to the Linux kernel so far.
  • The system call [getrandom](getrandom) was introduced in version 3.17 of the Linux kernel mainline
  • [memfd](memfd) was proposed by the kdbus developers
    • [memfd_create](memfd-create) was merged into the Linux kernel mainline in kernel version 3.17
  • [readahead](readahead) initiates a file "read-ahead" into page cache

DRM has been paramount for the development and implementations of well-defined and performant free and open-source graphics device drivers without which no rendering acceleration would be available at all, only the 2D drivers would be available in the X.Org Server. DRM was developed for Linux, and since has been ported to other operating systems as well.

Further libraries

Linux ABI

::figure[src="https://upload.wikimedia.org/wikipedia/commons/b/bb/Linux_API_and_Linux_ABI.svg" caption="The Linux API and ABI"] ::

Main article: x32 ABI, Linux Standard Base

The Linux ABI is a kernel–user space ABI. As ABI is a machine code interface, the Linux ABI is bound to the instruction set. Defining a useful ABI and keeping it stable is less the responsibility of the Linux kernel developers or of the developers of the GNU C Library, and more the task for Linux distributions and independent software vendors (ISVs) who wish to sell and provide support for their proprietary software as binaries only for such a single Linux ABI, as opposed to supporting multiple Linux ABIs.

An ABI has to be defined for every instruction set, such as x86, x86-64, MIPS, ARMv7-A (32-Bit), ARMv8-A (64-Bit), etc. with the endianness, if both are supported.

It should be able to compile the software with different compilers against the definitions specified in the ABI and achieve full binary compatibility. Compilers that are free and open-source software are e.g. GNU Compiler Collection, LLVM/Clang.

In-kernel APIs

Many kernel-internal APIs exist, allowing kernel subsystems to interface with one another. These are being kept fairly stable, but there is no guarantee for stability. A kernel-internal API can be changed when such a need is indicated by new research or insights; all necessary modifications and testing have to be done by the author.

The Linux kernel is a monolithic kernel, hence device drivers are kernel components. To ease the burden of companies maintaining their (proprietary) device drivers outside of the main kernel tree, stable APIs for the device drivers have been repeatedly requested. The Linux kernel developers have repeatedly denied guaranteeing stable in-kernel APIs for device drivers. Guaranteeing such would have faltered the development of the Linux kernel in the past and would still in the future and, due to the nature of free and open-source software, are not necessary. Ergo, by choice, the Linux kernel has no stable in-kernel API.

In-kernel ABIs

Since there are no stable in-kernel APIs, there cannot be stable in-kernel ABIs.

Abstraction APIs

::figure[src="https://upload.wikimedia.org/wikipedia/commons/9/99/Linux_kernel_and_OpenGL_video_games.svg" caption="OpenGL is indeed an abstraction API to make use of diverse GPUs of multiple vendors without the need to program for each one specifically."] ::

::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/e6/Division_of_labor_cpu_and_gpu.svg" caption="Vulkan]] was to make the "graphics driver", i.e. the implementation of the graphics API, do less."] ::

For many use cases, the Linux API is considered too low-level, so APIs of higher abstraction must be used. Higher-level APIs must be implemented on top of lower-level APIs. Examples:

References

References

  1. "ControlGroupInterface". [[freedesktop.org]].
  2. "libevdev". [[freedesktop.org]].
  3. (2011-03-02). "Choosing between portability and innovation". [[LWN.net]].
  4. (2011). "Interview: Lennart Poettering - Lennart Poettering will give a talk about "Systemd: beyond init" at FOSDEM 2011.". fosdem.org.
  5. Michael Kerrisk. (2016-01-31). "How to design a Linux kernel API".
  6. "System Call Organization".
  7. (2014-02-27). "Making a universal list of syscalls?". [[LKML]].
  8. (2014-02-12). "Flags as a system call API design pattern". [[LWN.net]].
  9. (2011-06-08). "On vsyscalls and the vDSO". [[LWN.net]].
  10. (2014-07-17). "[PATCH, RFC] random: introduce getrandom(2) system call". [[Linux kernel mailing list.
  11. "memfd.c".
  12. (2014-03-19). "NetBSD 7.0 Will Finally Have DRM/KMS Drivers". [[Phoronix]].
  13. "The Linux Kernel Driver Interface".
  14. (2016-03-15). "Analysis of ABI changes in the Linux kernel". Andrey Ponomarenko's ABI laboratory.

::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::

interfaces-of-the-linux-kernel