Linux Kernel

Linux Kernel: The Great RCU Rescue Mission

Today we're diving into a fascinating rescue mission in the Linux kernel where the team had to fix some serious deadlock issues introduced by recent RCU changes. Linus merged several critical fixes from Boqun Feng and Paul McKenney that involved converting spinlocks to raw spinlocks and adding clever workarounds using irq_work to prevent BPF tracing from causing system lockups.

Duration: PT3M55S

https://podlog.io/listen/linux-kernel-654e5f31/episode/linux-kernel-the-great-rcu-rescue-mission-c0469830

Transcript

Hey there, fellow code adventurers! Welcome back to another episode of our Linux Kernel podcast. I'm your host, and wow, do we have an interesting story for you today - March 26th, 2026. You know those moments in software development where you make a change that seems perfectly reasonable, but then it creates this cascade of unexpected problems? Well, that's exactly what we're unpacking today, and honestly, the solution is pretty elegant.

So here's what happened. The kernel team recently reimplemented RCU Tasks Trace using something called SRCU-fast, which sounds great in theory, right? But here's the plot twist - this change meant that BPF tracing, which can literally happen anywhere in the kernel, started calling into SRCU code in places where scheduler locks were already held. And when you try to acquire more scheduler locks while you're already holding them? Yeah, that's a recipe for deadlock city.

The heroes of our story today are Boqun Feng and Paul McKenney, who basically had to perform kernel surgery to fix this. They merged a series of RCU fixes that are honestly pretty clever. The main fix involved converting SRCU's regular spinlocks to raw spinlocks. Now, if you're wondering what the difference is, raw spinlocks are the hardcore version - they can be used even when preemption is disabled, which is exactly what BPF contexts need.

But wait, there's more! They couldn't just swap the locks and call it a day. The team had to get creative with something called irq_work - basically deferring some of the heavy lifting to interrupt work contexts to avoid those nasty scheduler lock acquisitions. It's like saying "hey, I can't do this right now because my hands are full, but let me set a reminder to do it in just a moment when I'm free."

What I love about this fix is how it shows the interconnected nature of kernel development. You change one thing over here for perfectly good reasons, and suddenly you're dealing with BPF contexts and scheduler locks and memory allocation timing. It's like a really complex game of Jenga where moving one piece affects the whole tower.

We also saw some nice platform driver updates for x86 systems. Nothing earth-shattering, but solid support additions for various ASUS and HP gaming laptops, plus some important hibernation fixes for Intel HID devices. There's something satisfying about seeing support for specific hardware models getting added - it means real people with real machines are going to have a better experience.

The EROFS filesystem got some attention too, with fixes for file-backed mounts and improvements to how it handles page cache sharing. These might seem like small technical details, but they're the kind of reliability improvements that make the whole system more robust.

For our Today's Focus section, if you're working on kernel code or any low-level systems programming, this episode has a great lesson about lock ordering and context awareness. When you're writing code that might be called from interrupt contexts, tracing contexts, or with locks already held, you need to think carefully about what locks you're acquiring and in what order. Raw spinlocks exist for a reason, and understanding when to use them versus regular spinlocks is crucial.

Also, the irq_work pattern they used here is worth studying. Sometimes the best solution isn't to force something to work in a difficult context, but to defer the work to a more suitable context. It's like that old saying - if you can't bring the mountain to you, go to the mountain.

That's a wrap for today's kernel adventures! Keep coding, keep learning, and remember - even the most experienced kernel developers sometimes need to go back and fix the fixes. It's all part of the journey. Until next time, happy coding!