Here is the latest preemptible kernel patch. It's much cleaner andsmaller than previous versions, so I've appended it to this mail. Thispatch is against 2.4.2, although it's not intended for 2.4. I'd likecomments from anyone interested in a low-latency Linux kernel solutionfor the 2.5 development tree.

Kernel preemption is not allowed while spinlocks are held, which meansthat this patch alone cannot guarantee low preemption latencies. Butas long held locks (in particular the BKL) are replaced by finer-grainedlocks, this patch will enable lower latencies as the kernel also becomesmore scalable on large SMP systems.

Notwithstanding the comments in the Configure.help section forCONFIG_PREEMPT, I think this patch has a negligible effect onthroughput. In fact, I got better average results from running 'dbench16' on a 750MHz PIII with 128MB with kernel preemption turned on(~30MB/s) than on the plain 2.4.2 kernel (~26MB/s).

(I had to rearrange three headers files that are needed in sched.h beforetask_struct is defined, but which include inline functions that cannotnow be compiled until after task_struct is defined. I chose not tomove them into sched.h, like d_path(), as I don't want to make it moredifficult to apply kernel patches to my kernel source tree.)

+Preemptible Kernel+CONFIG_PREEMPT+ This option reduces the latency of the kernel when reacting to+ real-time or interactive events by allowing a low priority process to+ be preempted even if it is in kernel mode executing a system call.+ This allows applications that need real-time response, such as audio+ and other multimedia applications, to run more reliably even when the+ system is under load due to other, lower priority, processes.++ This option is currently experimental if used in conjuction with SMP+ support.++ Say Y here if you are building a kernel for a desktop system, embedded+ system or real-time system. Say N if you are building a kernel for a+ system where throughput is more important than interactive response,+ such as a server system. Say N if you are unsure.+ Kernel math emulation CONFIG_MATH_EMULATION Linux can emulate a math coprocessor (used for floating pointdiff -Nur 2.4.2/arch/i386/config.in linux/arch/i386/config.in--- 2.4.2/arch/i386/config.in Wed Mar 14 12:14:18 2001+++ linux/arch/i386/config.in Wed Mar 14 12:20:02 2001@@ -161,6 +161,11 @@ define_bool CONFIG_X86_IO_APIC y define_bool CONFIG_X86_LOCAL_APIC y fi+ bool 'Preemptible Kernel' CONFIG_PREEMPT+else+ if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then+ bool 'Preemptible SMP Kernel (EXPERIMENTAL)' CONFIG_PREEMPT+ fi fi