13

I want to check if my Linux kernel is preemptive or non-preemptive. How can I check this using a command, something such as uname -a?

3 Answers 3

12

Whether a kernel is preemptive or not depends on what you want to preempt, as in the Linux kernel, there are various things that can have preemption enabled/disabled separately.

If your kernel has CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC enabled, you can find out your preemption configuration through /proc/config.gz (if you don't have this, some distributions ship the kernel config in /boot instead):

$ gzip -cd /proc/config.gz | grep PREEMPT
CONFIG_TREE_PREEMPT_RCU=y
CONFIG_PREEMPT_RCU=y
CONFIG_PREEMPT_NOTIFIERS=y
# CONFIG_PREEMPT_NONE is not set
# CONFIG_PREEMPT_VOLUNTARY is not set
CONFIG_PREEMPT=y
CONFIG_PREEMPT_COUNT=y
# CONFIG_DEBUG_PREEMPT is not set
# CONFIG_PREEMPT_TRACER is not set

If you have CONFIG_IKCONFIG, but not CONFIG_IKCONFIG_PROC, you can still get it out of the kernel image with extract-ikconfig.

1
  • I made a kernel module in raspberry which dialog with external sensor to ask for temperature. to talk with the sensor, i should set gpio pins input and output for specified amount of time (in ms). and the module work fine. so are kernel modules not preempted by other processes by the scheduler, since if it's preempted, the timing will be wrong, and the result get from sensor will be wrong. Nov 28, 2014 at 16:23
3

A preemptible kernel (low-latency desktop) has PREEMPT tagged in its version name (uname -a). This also appears in /proc/version and in the "version magic" string used to decide whether modules can/cannot be loaded on a given kernel, e.g.

mymodule: version magic '3.4.35 mod_unload ARMv7 p2v8 ' 
              should be '3.4.35 preempt mod_unload ARMv7 p2v8 '

No such tagging exist for CONFIG_PREEMPT_VOLUNTARY, afaik.

1

The accepted answer mentions that some distributions ship the kernel information in /boot. On Ubuntu 20.04 and at least some other systems, you can get additional information from looking in /boot/config-$(uname -r). For example:

$ grep PREEMPT_RT /boot/config-$(uname -r)
CONFIG_PREEMPT_RT=y

That does not give you any more info than uname -a as suggested by PypeBros, but if there are other settings you want to check, this gives you much more information if you open the file and browse it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .