12

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?

11

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. – mikmik Nov 28 '14 at 16:23
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.