I'm trying to install a kernel with the RT_PREEMPT patch on a Lubuntu 16.04 distro and running into some issues I'm not sure how to deal with. I've downloaded the sources for kernel v4.4.12 (linux-4.4.12.tar.xz) and what I believe to be the appropriate RT_PREEMPT patch (patches-4.4.12-rt20.tar.xz), both from kernel.org. I've extracted the kernel sources with tar xf, cd'd into the directory, then I try to apply the patch with xzcat ../patches-4.4.12.tar.xz | patch -p1 (per recommendations here: https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO). This command just generates a slew of errors complaining about patches for files that don't exist, previously applied patches, failed hunks, etc. Some of the patch hunks seem to succeed but so many of them fail.

This can't be the correct means to patch this kernel can it? Any idea where I'm going wrong?

EDIT: Here's a sample that covers the kinds of errors I'm seeing:

rush@lubuntuvm:~/preempt-rt/linux-4.4.12$ xzcat ../patches-4.4.12-rt20.tar.xz | patch -p1
patching file arch/x86/kernel/nmi.c
Hunk #1 FAILED at 231.
Hunk #2 FAILED at 256.
Hunk #3 FAILED at 305.
3 out of 3 hunks FAILED -- saving rejects to file arch/x86/kernel/nmi.c.rej
patching file arch/x86/kernel/reboot.c
patching file include/linux/kernel.h
Hunk #1 succeeded at 255 (offset -4 lines).
Hunk #2 FAILED at 460.
1 out of 2 hunks FAILED -- saving rejects to file include/linux/kernel.h.rej
patching file kernel/panic.c
Hunk #1 FAILED at 61.
1 out of 1 hunk FAILED -- saving rejects to file kernel/panic.c.rej
patching file kernel/watchdog.c
Hunk #1 FAILED at 361.
1 out of 1 hunk FAILED -- saving rejects to file kernel/watchdog.c.rej
patching file kernel/stop_machine.c
Hunk #12 succeeded at 482 (offset -10 lines).
Hunk #13 succeeded at 544 (offset -10 lines).
Hunk #14 succeeded at 648 (offset -10 lines).
patching file block/blk-mq.c
Reversed (or previously applied) patch detected!  Assume -R? [n] n
Apply anyway? [n] 
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file block/blk-mq.c.rej
patching file block/blk-mq.h
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
3 out of 3 hunks ignored -- saving rejects to file block/blk-mq.h.rej
patching file net/core/dev.c
Hunk #1 succeeded at 3542 (offset -3 lines).
Hunk #2 succeeded at 3552 (offset -3 lines).
patching file arch/arm64/Kconfig
patching file arch/arm64/include/asm/thread_info.h
patching file arch/arm64/kernel/asm-offsets.c
patching file arch/arm64/kernel/entry.S
can't find file to patch at input line 794
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
|patches/0026-hwlat-detector-Use-trace_clock_local-if-available.patch0000644001303100130310000000625512741715155025466 0ustar  rostedtrostedtFrom c184dd4a4a5d88b3223704297a42d1aaab973811 Mon Sep 17 00:00:00 2001
|From: Steven Rostedt <rostedt@goodmis.org>
|Date: Mon, 19 Aug 2013 17:33:26 -0400
|Subject: [PATCH 026/351] hwlat-detector: Use trace_clock_local if available
|As ktime_get() calls into the timing code which does a read_seq(), it
|may be affected by other CPUS that touch that lock. To remove this
|dependency, use the trace_clock_local() which is already exported
|for module use. If CONFIG_TRACING is enabled, use that as the clock,
|otherwise use ktime_get().
|Signed-off-by: Steven Rostedt <srostedt@redhat.com>
|Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
| drivers/misc/hwlat_detector.c | 34 +++++++++++++++++++++++++---------
| 1 file changed, 25 insertions(+), 9 deletions(-)
|diff --git a/drivers/misc/hwlat_detector.c b/drivers/misc/hwlat_detector.c
|index c07e85932cbf..0fcc0e38df42 100644
|--- a/drivers/misc/hwlat_detector.c
|+++ b/drivers/misc/hwlat_detector.c
  • I would suggest posting at least a couple of the error messages you get literally as they appear along with the command(s) you used. (Which you mostly already did, but the context is important also.)
    – ilkkachu
    Jul 14, 2016 at 21:21
  • I've just edited some of the actual stdout into my question. Errors like that continue on for several pages of fullscreen terminal output.
    – Kyle Rush
    Jul 14, 2016 at 21:34
  • Oh, now I see it. That's patches-NN.tar.xz, not patch-NN.xz.
    – ilkkachu
    Jul 14, 2016 at 21:43

1 Answer 1


You probably wanted to take patch-4.4.12-rt20.patch.xz, not patches-4.4.12-rt20.tar.xz. As the extension hints, the latter is a tar archive, not a single patch file. Apparently it contains the same patches as the single-file version, but with commit messages etc.

patch is smart enough to ignore useless stuff (like the tar file structure, apparently), so some of the patches work. But I suppose the component patches might depend on each other, and be in the wrong order in the tar file, so it doesn't apply cleanly.

  • Yep, that was it! Now that I look at it the guide even specifies patch-NN (though it doesn't mention the existence of patches-NN). The whole thing just applied. Now to get to the real meat and potatoes of configuring and compiling this thing. Thanks for the help!
    – Kyle Rush
    Jul 14, 2016 at 21:53

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.