LWN: Comments on "Sharing page tables with msharefs" https://lwn.net/Articles/901059/ This is a special feed containing comments posted to the individual LWN article titled "Sharing page tables with msharefs". en-us Thu, 11 Sep 2025 07:05:17 +0000 Thu, 11 Sep 2025 07:05:17 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Sharing page tables with msharefs https://lwn.net/Articles/924131/ https://lwn.net/Articles/924131/ mpr22 <div class="FormattedComment"> When someone who cares does the work.<br> </div> Wed, 22 Feb 2023 23:46:15 +0000 Sharing page tables with msharefs https://lwn.net/Articles/924124/ https://lwn.net/Articles/924124/ smooth1x <div class="FormattedComment"> <p> "those who do not understand unix are condemned to reinvent it poorly"<br> <p> Solaris already had this since the 1990s, Intimate Shared Memory (ISM) - shmat with the SHM_SHARE_MMU flag.<br> <p> Solaris even now has Dynamic Intimate Shared Memory - <a href="https://docs.oracle.com/cd/E19683-01/817-3801/whatsnew-s9fcs-101/index.html">https://docs.oracle.com/cd/E19683-01/817-3801/whatsnew-s9...</a><br> <p> When will Linux get with the program and get this added, only 30 years later?!!<br> <p> <p> </div> Wed, 22 Feb 2023 22:35:17 +0000 Sharing page tables with msharefs https://lwn.net/Articles/902160/ https://lwn.net/Articles/902160/ flussence <div class="FormattedComment"> It sounds like there&#x27;s a lot of overlap here with Transparent Hugepages, which had to deal with similar merging and splitting.<br> </div> Fri, 22 Jul 2022 10:13:00 +0000 Sharing page tables with msharefs https://lwn.net/Articles/902030/ https://lwn.net/Articles/902030/ rwmj &gt; <i>Automatic sharing would need to have different semantics, though; otherwise applications will be surprised when an mprotect() or mremap() call in another process changes their mappings.</i> <p> Wouldn't any automatic sharing solution have to spot this case and "unshare" the PTEs? Thu, 21 Jul 2022 14:45:54 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901700/ https://lwn.net/Articles/901700/ corbet Pathological cases can always be constructed. But if you're trying to map GB of memory scattered through memory as individual pages, you're going to have other problems as well, and PTE overhead is still unlikely to be the constraining factor. Mon, 18 Jul 2022 13:52:55 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901594/ https://lwn.net/Articles/901594/ ddevault <div class="FormattedComment"> <font class="QuotedText">&gt;In the pathological case, the addresses are distributed throughout memory, in which case you might need 512*3 = 1536 page tables = 6 MiB to map all of them (*3 because you only ever need one PML4 per address space).</font><br> <p> One other note: this situation calls for 6 MiB of page tables to map 2 MiB worth of actual pages.<br> </div> Mon, 18 Jul 2022 11:54:44 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901593/ https://lwn.net/Articles/901593/ ddevault <div class="FormattedComment"> <font class="QuotedText">&gt;A page-table entry (PTE) is relatively small, requiring just eight bytes to refer to a 4096-byte page on most systems.</font><br> <p> This is a little bit misleading. On x86_64, there are four levels of page tables: PML4, PDPT, PD, and PT; the latter contains PTEs (you also have PDE, PDPTE, and PML4E&#x27;s going up the chain). A virtual address essentially contains four indexes into these tables, and the CPU follows the tables to resolve the physical address for a given virtual address, such that address 0x111222333444 will look up index 0x111 from the PML4 and so on (simplified representation) to find the appropriate physical memory address. Each page table is 4 KiB each and holds 512 of these 8-byte entries, be it PDEs or otherwise. If you map fewer than 512 pages, you still need to use at least 4K*4 = 16K bytes for the four page tables, each of which takes up a single page.<br> <p> In the simple case, you can map up to 512 pages with just the four page tables -- assuming the addresses are contiguous. In the pathological case, the addresses are distributed throughout memory, in which case you might need 512*3 = 1536 page tables = 6 MiB to map all of them (*3 because you only ever need one PML4 per address space).<br> </div> Mon, 18 Jul 2022 11:53:28 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901532/ https://lwn.net/Articles/901532/ butlerm <div class="FormattedComment"> If your database server can handle the load in terms of number of connections, and your application can afford to be tightly coupled to the database design, and the connection latency is typical of a local area network, it is probably almost always faster to connect directly rather than running through extra tiers that mostly shuffle things around en route. In so many cases that is not possible any more though, even old school web applications multiplex database connections across concurrent users (and often do a outstanding job of it, but that is another story).<br> </div> Sat, 16 Jul 2022 18:32:26 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901514/ https://lwn.net/Articles/901514/ flussence <div class="FormattedComment"> I&#x27;ve seen articles about database designs that, instead of routing things through a frontend web API or whatever, expose Postgres users and use its security rules model directly. I imagine that&#x27;d cause some scaling headaches if done to a medium-large website...<br> </div> Sat, 16 Jul 2022 09:58:03 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901512/ https://lwn.net/Articles/901512/ edeloget <div class="FormattedComment"> <font class="QuotedText">&gt; Doesn&#x27;t PostgreSQL also use fork per client model?</font><br> <p> Yes, but then, correct system architecture tells you to limit the number of clients to something that the machine can handle :)<br> <p> If you cannot have 1500 clients on a signe machine, then maybe you shouldn&#x27;t have 1500 clients on the same machine :)<br> </div> Sat, 16 Jul 2022 09:44:04 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901497/ https://lwn.net/Articles/901497/ mokki <div class="FormattedComment"> Doesn&#x27;t PostgreSQL also use fork per client model?<br> <p> I was under the impression that thread per client model is faster, but less safe. In process per client model a bug in one client cannot corrupt memory in the process, outside the explicitly shared memory area.<br> </div> Sat, 16 Jul 2022 06:20:32 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901486/ https://lwn.net/Articles/901486/ nickodell <div class="FormattedComment"> Yes, exactly. From the May 17 article about this patchset:<br> <p> <font class="QuotedText">&gt; That raises an obvious question, he said: why not just use threads? The answer was that &quot;mmap_lock sucks&quot;. It is also not possible to change the existing behavior of MAP_SHARED, since that would break programs, so there would need to be, at a minimum, a new mmap() flag if not a new system call. Aziz said that the separate system call makes the page-table sharing explicit rather than it just being a side effect. That makes the decision to opt into this behavior explicit as well. </font><br> <p> <a href="https://lwn.net/Articles/895217/">https://lwn.net/Articles/895217/</a><br> </div> Fri, 15 Jul 2022 22:59:16 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901473/ https://lwn.net/Articles/901473/ bartoc <div class="FormattedComment"> Perhaps they want to COW some regions of memory while sharing others. This is quite difficult to do without fork/clone because as far as I can tell there&#x27;s no other good way to create a COW mapping of another COW mapping. (On windows this is completely impossible, which is why you can&#x27;t easily do things like forking game saves without implementing COW as part of your application&#x27;s data structures). I&#x27;m not 100% sure how to do this on linux (without using fork/clone), maybe you can reflink tempfs files together or something.<br> </div> Fri, 15 Jul 2022 20:52:07 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901470/ https://lwn.net/Articles/901470/ malmedal <div class="FormattedComment"> I&#x27;m totally onboard with the no-one should be running Oracle sentiment :) <br> <p> Several years out of the loop now, but I remember that Oracle, at least used to be, up to twice as fast as<br> PostgreSQL and MySQL on the same hardware and also the Magic Money Tree would provide far more money for<br> Oracle hardware since the license was so expensive :(<br> </div> Fri, 15 Jul 2022 20:20:08 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901466/ https://lwn.net/Articles/901466/ josh <div class="FormattedComment"> What makes it lower performance when using threads? Lock contention on the process mm? Something else?<br> </div> Fri, 15 Jul 2022 19:55:00 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901448/ https://lwn.net/Articles/901448/ k8to <div class="FormattedComment"> But also, if you do care about performance you really shouldn&#x27;t be running Oracle.<br> <p> (Sort of a joke, because no one should be. But sort of true because they tend only win in the case of very fragile tuning that cannot be done in a timely way. And because of course if you spent that same money on hardware, you&#x27;d usually be better off with postgresql.)<br> </div> Fri, 15 Jul 2022 18:11:00 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901444/ https://lwn.net/Articles/901444/ malmedal <div class="FormattedComment"> If you don&#x27;t care about performance you really shouldn&#x27;t be running Oracle. <br> </div> Fri, 15 Jul 2022 17:11:24 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901429/ https://lwn.net/Articles/901429/ clugstj <div class="FormattedComment"> Well, when given the choice between a performance hit and it crashing, I&#x27;d say you should pick performance hit.<br> </div> Fri, 15 Jul 2022 15:28:05 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901421/ https://lwn.net/Articles/901421/ willy <div class="FormattedComment"> The database can work in a threaded mode, but performance on Linux is worse than the fork model.<br> </div> Fri, 15 Jul 2022 14:38:15 +0000 Sharing page tables with msharefs https://lwn.net/Articles/901420/ https://lwn.net/Articles/901420/ clugstj <div class="FormattedComment"> Maybe Oracle should not spawn a process for each client.<br> </div> Fri, 15 Jul 2022 14:32:28 +0000