• teleforce 2 months ago

    Wow finally, it seems like yesterday when first encountered the real-time Linux kernel proposal.

    It's a long time overdue and congrats to the real-time Linux time for the tenacity. The fact that it's included after eBPF being accepted to the Linux kernel but better late than never. Now we can preempt eBPF codes to make it even faster and responsive.

    It will be very interesting to run real-time Linux on Raspberry Pi interfacing with Pi Pico for IoT monitoring, sensing and actuating communicating over bidirectional BiSS interface [1].

    [1] BiSS: High speed open-source digital interface for IoT sensors and actuators:

    https://news.ycombinator.com/item?id=41516826

    • zaptheimpaler 2 months ago

      Wow that sounds like a hell of an achievement. Here is the commit to the print_k function they mentioned as the final hurdle [1]. I have no idea what it does but maybe someone else here does. I wonder if the RT stuff will remain behind a config flag or become the default eventually. Is there any reason to not just have RT on by default?

      I remember I had some nasty sound distortion issues on a Windows VFIO VM and it came down to events/interrupts not being handled quickly enough. I wonder what happens with an RT kernel and the VM thread having high priority in that situation.

      [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/lin...

      • viraptor 2 months ago

        > Is there any reason to not just have RT on by default?

        It's a latency vs throughput trade-off usually. Ideally you'd want both to improve, but the more you switch between the processes, the more time you waste on busywork and cache invalidation rather than what the processes want to achieve. For example if RT wants to guarantee that your audio is more in sync, you're going to switch from your app to the audio system more often.

        • cwillu 2 months ago

          That's a bit of a red-herring though, as the audio system will only preempt other processes if it's configured for very small buffers and given real-time permissions. A server's audio subsystem won't preempt actual work because a server won't _have_ an audio subsystem running, let alone be configured for sub-millisecond latency.

          The real trade-off is the overhead required to make all kernel operations potentially safe WRT maximum wait times.

          • viraptor 2 months ago

            This is a qualified example. Yes, if you're not doing audio, audio is not going to interrupt. But that's a moot point...

      • ttshaw1 2 months ago

        Anyone know if this will have any impact on low-latency linux audio? The article calls out JACK, but I'd guess the new standard for musicians recording on Linux is pipewire. So if pipewire either found some workaround or has been enabling a real-time module, I suppose those end users wouldn't see a difference.

        • orbital-decay 2 months ago

          There are already realtime/low latency kernels in many distros, very useful for low-latency audio processing. Usually you have to install them separately.

          • seba_dos1 2 months ago

            > Usually you have to install them separately.

            ...and that won't change now either. You'll just be able to build the RT kernel from the same upstream sources as the regular one.

          • cwillu 2 months ago

            Pipewire will benefit in exactly the same way as jack.

          • tetris11 2 months ago

            If anyone wants to try multiple kernels on their machine, here's how you'd do it with systemd-boot

                ## install mainline, bleeding, secure, stable, and stable realtime, mainline realtime
                pacman -S linux linux-zen linux-hardened linux-lts linux-rt-lts, linux-rt
                ## and I guess, soon to be: linux-rt
            
            And then add the following 5 bootloader entries as separate files

                #/boot/loader/entries/linux{,-zen,-hardened,-lts,-rt-lts,-rt}.conf
                title Linux {Main,Zen,Hard,LTS,RT-LTS,RT}
                linux /vmlinuz-linux{,-zen,-hardened,-lts,-rt-lts,-rt}
                initrd /initramfs-linux{,-zen,-hardened,-lts,-rt-lts,-rt}.img
                options root=PARTUUID="the-part-uuid-of-your-root-partition" rw
            
            and after those 5 files are in place, do a `bootctl update`
            • josephcsible 2 months ago

              Does Arch really not integrate bootloader config into the package manager? Or is this a shortcoming of systemd-boot? Because on, e.g., Ubuntu and Fedora, when I install a new kernel from a .deb or .rpm, it automatically does everything with GRUB for it to be there when I reboot.

              • tetris11 2 months ago

                I do agree that systemd-boot should have a post installation hook that generates these automatically.

                • enva2712 2 months ago

                  you install the bootloader yourself on arch

              • Animats 2 months ago

                Nice. Real-time Linux used to be a joke, but apparently now it works.

                The sheer complexity of making much of kernel space preemptable is scary. There's too much running in kernel space.

                • goodcanadian 2 months ago

                  Real-time Linux used to be a joke, but apparently now it works.

                  When was that? I used it over a decade ago, and it worked pretty well even then.

                  • akikoo 2 months ago

                    Here's when:

                    https://help.ubuntu.com/community/UbuntuStudio/RealTimeKerne...

                    > Security Implications

                    > All it would take is one malicious process to execute and take advantage of the real-time code to completely lock-out a user from their machine, turning that machine into part of a botnet or other malicious purpose. Real-Time processes have the potential to completely take-over a machine. This is the number one reason Ubuntu does not carry a Real-Time kernel.

                    • Snild 2 months ago

                      That page seems to be describing SCHED_FIFO processes, which are already a thing without PREEMPT_RT. Maybe they weren't back in the pre-2.6 days? Anyway, they are usually limited to 95% of total runtime by the sched_rt_runtime_us tunable, to avoid accidental self-DoSing. Maybe that, too, was later invention -- 2.6 is very very old.

                      The page goes on:

                      > A patch does exist to enable process to have real-time process access to any process requesting it.

                      According to the sched(7) man page, this has never been the case: before 2.6.12, the process had to have CAP_SYS_NICE; after, it was limited by policy through RLIMIT_RTPRIO. I guess it's possible that this was not the case for the original out-of-tree patch set.

                      But it's been there for many years, well before the 2020 edit that added the bulk of the current text on that wiki page.

                      • PhilipRoman 2 months ago

                        >completely lock-out a user from their machine, turning that machine into part of a botnet or other malicious purpose

                        There seems to be a pretty big leap from beginning of that sentence to the end, I personally wouldn't consider local DoS a problem.

                  • Tomte 2 months ago

                    Lots of testing (and funding, I think) by OSADL, who nobody seems to know: https://www.osadl.org/OSADL-QA-Farm-Real-time.linux-real-tim...

                    • londons_explore 2 months ago

                      > the Linux kernel is fully preemptible,

                      So this means there are no critical sections or interrupts being disabled anywhere in kernel code when PREEMPT_RT is enabled?

                      • oasisaimlessly 2 months ago

                        I would assume it means something a bit weaker: that all critical sections have a bounded length, being guaranteed to end after a given finite number of clock cycles.

                      • ahazred8ta 2 months ago

                        A buddy of mine used Trinux RTK and Wind River RTLinux in a commercial audio console product back in the 00's. There were several efforts back then.

                        • nirav72 2 months ago

                          I don’t know much about RTOS. But am aware that JPL uses VxWorks for planetary rovers and orbiters. So wondering if JPL or other entities will replace VxWorks with a Linux RTOS implementation at some point.

                          • skovati 2 months ago

                            If you haven't already, look into the avionics and flight software of the Ingenuity helicopter. First time Linux ran on Mars!

                          • undefined 2 months ago
                            [deleted]
                            • penguin_booze 2 months ago

                              > Unlike general-purpose operating systems like Windows or macOS.

                              FYI, there appears to be minor one, too: it's called Linux.

                              • jellykid 2 months ago

                                I wonder if this will improve emulation compatibility?