Linux 7.0 Broke PostgreSQL: The Preemption Regression Explained

(read.thecoder.cafe)

89 points | by 0xKelsey 3 hours ago

12 comments

  • ameliaquining 1 hour ago
    This post comes uncomfortably close to plagiarizing https://thebuild.com/blog/2026/04/23/preempt_none-is-dead-yo..., which it cites as a source; almost all the technical explanation is in there and some of the wording is extremely similar. Compare, e.g., "What Linux 7.0 actually changed" in Pettus's post to "What Is Preemption?" in this one. I think this link should have been to Pettus's post instead.
    • jdonaldson 12 minutes ago
      That post comes uncomfortably close to how Opus writes this kind of prose. It's a good idea to acknowledge all stakeholders.
  • ozgrakkurt 59 minutes ago
    It is a crime that postgres isn't able to allocate with 1GB huge pages by changing a config parameter in 2026

    Also a crime that people are still running databases with 4kb pages.

    To put it in perspective, this means you will have more than 30 million pages on a server with 128GB RAM. As an example, if there is 16bytes of metadata for memory page. The metadata itself would take more than half a gigabyte.

    • dezgeg 45 minutes ago
      Even worse, the actual struct page on Linux is 64 bytes, so 4x your example
    • bonzini 46 minutes ago
      There is 64 bytes of metadata per memory page indeed.
  • buster 1 hour ago
    I'd rather like to know if any real world usage broke, before coming to the conclusion that an edge case synthetic benchmark is worth changing the kernel (back or wherever) where supposedly the change that broke the benchmark had real world benefits.

    Since we will never know it might be a good idea to feature gate the change, change the default and let users decide to change it back. This may give some feedback on the lkml or else to decide if the change is worthwhile?

    • nijave 1 hour ago
      "synthetic benchmark" is doing some heavy lifting here. Pgbench just runs a bunch of SQL statements against a real Postgres instance.

      It's very close to a real world simulation of a production workload

      • buster 43 minutes ago
        I am not questioning the benchmark. But the benchmark is NOT measuring a real world application in a real world setting. Anyway, I am merely wondering IF there is a company out there affected, at all. I understand that this was only measured on a graviton 4 setting with very heavy lifting, without huge tables.

        For example, this issue aside, I'd rather split such a workload into multiple smaller instances, naturally. Because the impact of a crash on this single node, heavy load, many cores, many clients scenario would be huge.

  • MBCook 1 hour ago
    This only happened under a very odd configuration. Yeah it wasn’t great but it was not the normal case.

    The headline implies it broke PG everywhere. It didn’t.

  • selckin 2 hours ago
  • jeltz 13 minutes ago
    Moderators should change this headline because it is nowhere near true. It only regressed performance on some incorrect configurations.
  • ahartmetz 47 minutes ago
    PREEMPT_LAZY triggering on page faults seems like a bad idea in light of this. It is probably not a good idea to suspend processes right when they get unexpectedly bogged down. The logic makes a little more sense for syscalls that are expected to take long compared to a scheduling quantum (a few milliseconds). But page faults are mostly invisible and unplannable.

    It only took a few decades for Linux to get a good CPU scheduler and good I/O schedulers, too. I don't get how such an important area can be so bad for so long. But then, bad scheduling is everywhere. I find it to be a pretty fun area to work in, but, judging by how much it is less than half-assed in much existing software, most developers seem to hate dealing with it?

    • bobmcnamara 24 minutes ago
      Userspace spinlocks seem like a bad idea too.

      What if it was on a VM and the core holding the lock got descheduled from the hypervisor?

  • nijave 1 hour ago
    Right on the heels of 6.19 breaking tcmalloc and Mongo
    • matharmin 2 minutes ago
      Yup - interesting to see so much written about Postgres having a performance regression on Linux 7.0, in a scenario that affects almost no-one in practice. Meanwhile MongoDB refuses to run at all on Linux 7.0 due to some issue with tcmalloc.

      https://jira.mongodb.org/browse/SERVER-121885

  • ApolloFortyNine 50 minutes ago
    I can't help but think of the classic XKCD example of breaking a user's workflow [1].

    Doing research though a spinlock actually doesn't seem as unusual a hack as it would first seem, do drivers and the like not have similar issues because they don't trigger a page fault I guess?

    [1] https://xkcd.com/1172/

  • baq 1 hour ago
    TLDR of the LMKL thread: 120GB RAM postgres with hugepages=off, lock contention went from terrible to abysmal. nothing to see here except that amazon for whatever reason runs DB tests with huge pages disabled. (hope I'm not paying for RDS and auroras like that in production!)
    • Twirrim 1 hour ago
      Huge pages has had a spotty history, that lead to people being paranoid about it, and no doubt a whole bunch of folks just disable it "because that's what we've always done". It has been stable and reliable for quite a while now, would really hope folks could move away from that perspective.
      • jeltz 10 minutes ago
        Are you sure you are not thinking of transparent huge pages? They have a spotty history but you are supposed to run big PostgreSQL instances with huge pages, not transparent huge pages.
      • nijave 1 hour ago
        I tested it once about 2 years ago on Azure VM and got a nice 10-15% perf boost on pgbench (I want to say at least 64GB shared mem)
      • lstodd 7 minutes ago
        I remember when support for them just appeared and you had to LD_PRELOAD a shim IIRC to make Postgres actually use them we jumped on it, enabled them immediately and got a pretty significant boost, around 15-20%, yes.

        That was idk, 2008-9 -ish? I don't know what spotty history you are talking about, if you have multigigabyte address spaces floating on a machine it's stupid not to use hugepages.

    • nijave 1 hour ago
      In fairness, AWS could (and almost certainly is) using their own kernel build that does who-knows-what
    • mplanchard 1 hour ago
      Also was only on ARM, wasn’t it?
    • dist-epoch 1 hour ago
      Many people have desktops with 128 GB RAM. Should they enable hugepages? I've never heard this recommendation for a desktop.
      • nijave 1 hour ago
        Huge pages is good when a single process is reserving a giant block of memory which I think isnt that common.

        You might have transparent huge pages on by default depending on the distro

  • dataflow 1 hour ago
    An X% performance regression is basically a (100 - X)% feature breakage, so whatever that implies in terms of breaking userspace...
  • PunchyHamster 1 hour ago
    Seems Linus needs to yell at someone again.

    Especially with containers around you might very well hit the case of running new kernel but older version of PostgreSQL with no code mitigation for the problem

    • nobleach 1 hour ago
      I get that folks love a good Linus rant. But as someone who's been at the end of that style of "feedback", nothing can be more humiliating or demotivating. Certainly there are contributors that are making "rookie mistakes". There are folks that aren't willing to ingest the entire context of what was tried back in 2.0.36, 2.2, 2.4... etc. And perhaps it's wise to simply stay away until you're completely certain you've got the chops to contribute. More than half the folks that enjoy that sort of abuse don't have those chops.

      I can defend someone who is unwilling to yield on quality. Afterall, this truly is his baby. Issuing scathing rebukes to well-intentioned contributors is like slapping my kid when he brings me the wrong type of screwdriver.

      • ecshafer 1 hour ago
        I don't think a Linus rant ever hit anyone that was a rookie, they are always AFAIK against people "who should know better". Veteran developers, with multiple commits merged.
      • slackfan 6 minutes ago
        Code quality does not care about your feelings.
      • colechristensen 1 hour ago
        If you're at the level of delivering to Linus, I'm sorry but humiliation and demotivation are earned.

        You don't talk like this to junior or even senior engineers, but you do reach a level at which gently telling isn't necessary.

        If you don't like it go fork Linux and try being the nice benevolent dictator and we'll applaud your success.

      • themafia 36 minutes ago
        > scathing rebukes

        Would you be able to point one out?

        > to well-intentioned contributors

        This is a system used and relied upon by billions of people around the world. Your intentions, while good, are not material to the problem. Put another way we have an endless supply of people with "good intentions" but we don't enjoy the same largess of people with "good skills."

    • bonzini 44 minutes ago
      Nope, there was and will be no yelling.