The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
Posted Apr 15, 2010 22:02 UTC (Thu) by i3839 (guest, #31386)Parent article: The case of the overly anonymous anon_vma
What was it needed for again? To have a reverse mapping? Isn't that mostly useful for swapping and not much else? It seems silly to always add the overhead when it's almost never needed. Why not only have the overhead when actually swapping or whenever it's needed? Then this whole mess disappears from the common case and the complex stuff can be separated and isolated.
I have to read more code and think more about it, preferably with a clear mind.
Posted Apr 23, 2010 13:41 UTC (Fri)
by rilder (guest, #59804)
[Link] (1 responses)
Posted Apr 23, 2010 16:17 UTC (Fri)
by i3839 (guest, #31386)
[Link]
In addition to that, anon_vma apparently didn't solve the problem well, but instead of replacing it with something that does, more kludges are added on top of it. I got the feeling that there's some much more elegant solution waiting for someone to find it.
Posted Apr 24, 2010 20:59 UTC (Sat)
by efexis (guest, #26355)
[Link] (6 responses)
Posted Apr 24, 2010 22:48 UTC (Sat)
by i3839 (guest, #31386)
[Link] (5 responses)
I don't have time to look further into the details, at least not this month. Hopefully next month.
Posted Apr 26, 2010 3:03 UTC (Mon)
by efexis (guest, #26355)
[Link] (4 responses)
Posted Apr 26, 2010 19:09 UTC (Mon)
by i3839 (guest, #31386)
[Link] (3 responses)
This seems more a gradual development, with every thing on its own making sense at the time, but together still going in the wrong direction. It for sure isn't a big enough problem yet.
It would be nice to know what the reverse mapping is used for besides swapping. It seems that the reverse mapping of files is a solved problem, but that all this complexity is only for anonymous memory. Which can only go away is you have swap enabled, or some obscure option like memory hotplug. (In the case of hibernation you need to scan all pages anyway, so no need for this either.) So I guess that my main complaint is that this is done even when not needed.
For swap you only need a reverse mapping for pages that might get swapped out soon. I wonder if it's possible to create that mapping only for inactive pages instead of all of them all the time. Alternatively, swapping out can be done per-process, then there's no need for a reverse map. Shared pages are swapped out less quickly, but that's usually better anyway.
The swapping system needs an overhaul anyway, it's very slow currently. This way both the VM and the swap systems can be improved.
Improving the current code may not be easy, but it for sure is possible.
Posted Apr 30, 2010 20:02 UTC (Fri)
by efexis (guest, #26355)
[Link] (2 responses)
Posted May 1, 2010 12:17 UTC (Sat)
by i3839 (guest, #31386)
[Link] (1 responses)
You don't need a reverse mapping to do COW, when you get a pagefault you know the virtual address which caused it.
Reverse mapping is needed to find all virtual pages belonging to a certain physical one. That isn't needed often for anonymous memory.
Posted May 3, 2010 16:51 UTC (Mon)
by efexis (guest, #26355)
[Link]
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
"I don't have time to look further into the details"The case of the overly anonymous anon_vma
Well my guess is that they did, and that code that mostly slowed the memory manager down for savings only in a corner case would have been thrown out by Linus, as is often the way.
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
The case of the overly anonymous anon_vma
Reverse mapping for file backed pages don't need anon_vma stuff obviously, because they're not anon. What they use isn't simpler though, as, for example, a library will often be shared by more address spaces than an anon page, it makes more sense to use a search tree (at least this used to be the case, according to a slightly dated early 2.6.x book detailing it. If it's now simpler than this, that would show kernel devs in fact simplifying things, not adding complexity).
If you use none of these, go into your kernel conf and disable CONFIG_SWAP, CONFIG_NUMA and any CONFIG_HIGHMEM entries. If nothing else uses it, it'll either be removed, or worst case, a few greps will show you where the functions are being used elsewhere to throw a few #ifdef's around (I imagine embedded comunity would have interest in already doing this).