swap-prefetch: A smart way to make good use of idle resources (was: updatedb)
Subsystems (13)
Quoted 18 lines · People
Quoted 7 lines
Quoted 2 lines
I believe the users who say their apps really do get paged back in though, so suspect that's not the case.
Stopping the bush-circumference beating, I do not. -ck (and gentoo) have this massive Calimero thing going among their users where people are much less interested in technology than in how the nasty big kernel meanies are keeping them down (*).
I think the problem is elsewhere. Users don't say: "My apps get paged back in." They say: "My system is more responsive". They really don't care *why* the reaction to a mouse click that takes three seconds with a mainline kernel is instantaneous with -ck. Nasty big kernel meanies, OTOH, want to understand *why* a patch helps in order to decide whether it is really a good idea to merge it. So you've got a bunch of patches (aka -ck) which visibly improve the overall responsiveness of a desktop system, but apparently no one can conclusively explain why or how they achieve that, and therefore they cannot be merged into mainline.
Quoted 1 line
I don't have a solution to that dilemma either.
IMHO, what everybody agrees on, is that swap-prefetch has a positive effect in some cases, and nobody can prove an adverse effect (excluding power consumption). The reason for this positive effect is also crystal clear:
It prefetches from swap on idle into free memory, ie: it doesn't force anybody out, and they are the first to be dropped without further swap-out, which sounds really smart.
Conclusion: Either prove swap-prefetch is broken, or get this merged quick.
Thanks!
--
Al
Quoted 5 lines
IMHO, what everybody agrees on, is that swap-prefetch has a positive effect in some cases, and nobody can prove an adverse effect (excluding power consumption). The reason for this positive effect is also crystal clear:
It prefetches from swap on idle into free memory, ie: it doesn't force
the fact that there is free memory is ... strange. IN principle, Linux keeps almost no memory free (except some emergency buffers) so that things you swap in prematurely will BY DEFINITION go at the expense of other things that could be there....
also, they take up seek time (5 to 10 msec), so if you were to read something else at the time you get additional latency.
so the conclusion that it only can be better (if you don't care about power) is imo premature.
Sure it still can be worth it, but it for sure is NOT an automatic thing.
Quoted 10 lines · Arjan van de Ven
Quoted 4 lines · Al Boldi
IMHO, what everybody agrees on, is that swap-prefetch has a positive effect in some cases, and nobody can prove an adverse effect (excluding power consumption). The reason for this positive effect is also crystal clear:
It prefetches from swap on idle into free memory, ie: it doesn't forcethe fact that there is free memory is ... strange. IN principle, Linux keeps almost no memory free (except some emergency buffers) so that things you swap in prematurely will BY DEFINITION go at the expense of other things that could be there....
It's not strange, the use case here is if something memory hungry process is shut down it leaves behind a lot of free memory. Having things swapped out while there's free memory is strange, so swap prefetch fills it up again.
Quoted 2 lines
also, they take up seek time (5 to 10 msec), so if you were to read something else at the time you get additional latency.
If there's other disk activity swap prefetch shouldn't do much, so this isn't really true.
Quoted 1 line
Quoted 1 line
Conclusion: Either prove swap-prefetch is broken, or get this merged quick.
There are a whole lot of other requirements too than that it isn't broken (of which most are fulfilled, but anyway). One reason could be that there's a better solution out there for the problem swap prefetch tries to solve. That said, as swap prefetch is here now for a while and that other solution not it's not such a great argument.
Personally I think that a more generic solution would be better, one that prefetches the lastly evicted pages back in, not favouring either of swap or file data, like swap prefetch does now.
Greetings,
Indan
On Fri, 2007-07-27 at 23:51 +0200, Indan Zupanci
Quoted 5 lines
Quoted 2 lines
also, they take up seek time (5 to 10 msec), so if you were to read something else at the time you get additional latency.
If there's other disk activity swap prefetch shouldn't do much, so this isn't really true.
how do you know there will be other activity? You start the IO and that basically blacks out the disk for 5 to 10 ms. If the "real" IO gets submitted in that time you add latency. You cannot predict that IO happening or not happening.
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 11 lines · Arjan van de Ven
On Fri, 2007-07-27 at 23:51 +0200, Indan Zupanci
Quoted 5 lines
Quoted 2 lines
also, they take up seek time (5 to 10 msec), so if you were to read something else at the time you get additional latency.
If there's other disk activity swap prefetch shouldn't do much, so this isn't really true.
how do you know there will be other activity? You start the IO and that basically blacks out the disk for 5 to 10 ms. If the "real" IO gets submitted in that time you add latency. You cannot predict that IO happening or not happening.
Ah, in that way. Yes, you right about that (though NCQ might help then?), but that's true for all disk activity. Though I think swap prefetch didn't want to run when there was CPU activity, so that would reduce the chance that new IO is submitted right at that moment. I think in practice this isn't worth worrying about, the real issue is the extra disk activity in the first place.
Greetings,
Indan
Quoted 4 lines · Arjan van de Ven
how do you know there will be other activity? You start the IO and that basically blacks out the disk for 5 to 10 ms. If the "real" IO gets submitted in that time you add latency. You cannot predict that IO happening or not happening.
If there hasn't be much IO for some time, it looks quite reasonable to expect that there won't be more in the near future. As most of heuristics can fail, but then this is a feature mostly for desktops, not servers.
There's an old saying that says something like "an open source project starts dying when new people can't participate in the project no matter how hard they try". It's hard to understand why there's so many people opposing to this when other more controversial features are merged much faster, (like, fe. the UIO driver framework).
Quoted 9 lines · grundig
Quoted 4 lines · Arjan van de Ven
how do you know there will be other activity? You start the IO and that basically blacks out the disk for 5 to 10 ms. If the "real" IO gets submitted in that time you add latency. You cannot predict that IO happening or not happening.
If there hasn't be much IO for some time, it looks quite reasonable to expect that there won't be more in the near future. As most of heuristics can fail
exactly this was my point: just saying "there are no downsides" isn't true.
Quoted 5 lines
There's an old saying that says something like "an open source project starts dying when new people can't participate in the project no matter how hard they try". It's hard to understand why there's so many people opposing to this when other more controversial features are merged much faster, (like, fe. the UIO driver framework).
I'm not opposing this or cheering for it. I'm opposing blindly saying "there are no downsides". This needs showing with data at minimum, and my reading of this saga seems to suggest data is the bit that is lacking from the start...
Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org
Quoted 9 lines · grundig
El Fri, 27 Jul 2007 15:06:14 -0700, Arjan van de Ven <[email protected]> escribi�:
Quoted 4 lines
how do you know there will be other activity? You start the IO and that basically blacks out the disk for 5 to 10 ms. If the "real" IO gets submitted in that time you add latency. You cannot predict that IO happening or not happening.
If there hasn't be much IO for some time, it looks quite reasonable to expect that there won't be more in the near future.
Good argument.
Quoted 2 lines
As most of heuristics can fail, but
then this is a feature mostly for desktops, not servers.
Bad argument. It doesn't matter for who the feature is intended, it matter what it does and if it does it well or not. In this case, prefetching swap without disturbing anything else.
Quoted 5 lines
There's an old saying that says something like "an open source project starts dying when new people can't participate in the project no matter how hard they try". It's hard to understand why there's so many people opposing to this when other more controversial features are merged much faster, (like, fe. the UIO driver framework).
Could people please stop this emotional crap non-argumentation? At best it reduces the chance of swap-prefetch to be merged.
Perhaps one of the reasons is that this is core kernel code. And that it isn't a new feature, but a performance improvement with doubtful trade-offs. The problem statement isn't clear either. It seems like a natural enhancement, but is that enough reason to merge it? Maybe, maybe not. But if slow swap-in is the problem, shouldn't that be fixed instead of bypassed?
Yes, there are people that say that it works for them, but of those a lot claim updatedb damage is fixed by it too, while that can't be true. And how many of those people did test swap prefetch stand-alone? The ck kernel has other mm patches too, perhaps those are the real goodies...
And there don't seem to be many people opposing swap prefetch either. A bunch seem in favour of it, and others seem unconvinced.
Me, I don't know if it should be merged or not, it solves one very specific workload, and nothing else (swap is used, and memory becomes free which won't be used in the near future). All in all it seems good, but doubtful, and when in doubt, don't merge.
Greetings,
Indan
Quoted 17 lines · Al Boldi
Quoted 16 lines · People
Quoted 6 lines
Quoted 2 lines
I believe the users who say their apps really do get paged back in though, so suspect that's not the case.
Stopping the bush-circumference beating, I do not. -ck (and gentoo) have this massive Calimero thing going among their users where people are much less interested in technology than in how the nasty big kernel meanies are keeping them down (*).
I think the problem is elsewhere. Users don't say: "My apps get paged back in." They say: "My system is more responsive". They really don't care *why* the reaction to a mouse click that takes three seconds with a mainline kernel is instantaneous with -ck. Nasty big kernel meanies, OTOH, want to understand *why* a patch helps in order to decide whether it is really a good idea to merge it. So you've got a bunch of patches (aka -ck) which visibly improve the overall responsiveness of a desktop system, but apparently no one can conclusively explain why or how they achieve that, and therefore they cannot be merged into mainline.
Quoted 5 lines
Quoted 1 line
I don't have a solution to that dilemma either.
IMHO, what everybody agrees on, is that swap-prefetch has a positive effect in some cases, and nobody can prove an adverse effect (excluding power consumption). The reason for this positive effect is also crystal clear: It prefetches from swap on idle into free memory, ie: it doesn't force anybody out, and they are the first to be dropped without further swap-out, which sounds really smart.
Conclusion: Either prove swap-prefetch is broken, or get this merged quick.
If you can't prove why it helps and doesn't hurt, then it's a hack, by definition. Behind any performance hack is some fundamental truth that can be exploited to greater effect if we reason about it. So let's reason about it. I'll start.
Resource size has been outpacing processing latency since the dawn of time. Disks get bigger much faster than seek times shrink. Main memory and cache keep growing, while single-threaded processing speed has nearly ground to a halt.
In the old days, it made lots of sense to manage resource allocation in pages and blocks. In the past few years, we started reserving blocks in ext3 automatically because it saves more in seek time than it costs in disk space. Now we're taking preallocation and antifragmentation to the next level with extent-based allocation in ext4.
Well, we're still using bitmap-style allocation for pages, and the prefetch-less swap mechanism adheres to this design as well. Maybe it's time to start thinking about memory in a somewhat more extent-like fashion.
With swap prefetch, we're only optimizing the case when the box isn't loaded and there's RAM free, but we're not optimizing the case when the box is heavily loaded and we need for RAM to be free. This is a complete reversal of sane development priorities. If swap batching is an optimization at all (and we have empirical evidence that it is) then it should also be an optimization to swap out chunks of pages when we need to free memory.
So, how do we go about this grouping? I suggest that if we keep per-VMA reference/fault/dirty statistics, we can tell which logically distinct chunks of memory are being regularly used. This would also us to apply different page replacement policies to chunks of memory that are being used in different fashions.
With such statistics, we could then page out VMAs in 2MB chunks when we're under memory pressure, also giving us the option of transparently paging them back in to hugepages when we have the memory free, once anonymous hugepage support is in place.
I'm inclined to view swap prefetch as a successful scientific experiment, and use that data to inform a more reasoned engineering effort. If we can design something intelligent which happens to behave more or less like swap prefetch does under the circumstances where swap prefetch helps, and does something else smart under the circumstances where swap prefetch makes no discernable difference, it'll be a much bigger improvement.
Because we cannot prove why the existing patch helps, we cannot say what impact it will have when things like virtualization and solid state drives radically change the coefficients of the equation we have not solved. Providing a sysctl to turn off a misbehaving feature is a poor substitute for doing it right the first time, and leaving it off by default will ensure that it only gets used by the handful of people who know enough to rebuild with the patch anyway.
Let's talk about how we can make page replacement smarter, so it naturally accomplishes what swap prefetch accomplishes, as part of a design we can reason about.
CC-ing linux-mm, since that's where I think we should take this next.
-- Chris
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
How can we make page replacement smarter (was: swap-prefetch)
Quoted 50 lines · Chris Snook
Resource size has been outpacing processing latency since the dawn of time. Disks get bigger much faster than seek times shrink. Main memory and cache keep growing, while single-threaded processing speed has nearly ground to a halt.
In the old days, it made lots of sense to manage resource allocation in pages and blocks. In the past few years, we started reserving blocks in ext3 automatically because it saves more in seek time than it costs in disk space. Now we're taking preallocation and antifragmentation to the next level with extent-based allocation in ext4.
Well, we're still using bitmap-style allocation for pages, and the prefetch-less swap mechanism adheres to this design as well. Maybe it's time to start thinking about memory in a somewhat more extent-like fashion.
With swap prefetch, we're only optimizing the case when the box isn't loaded and there's RAM free, but we're not optimizing the case when the box is heavily loaded and we need for RAM to be free. This is a complete reversal of sane development priorities. If swap batching is an optimization at all (and we have empirical evidence that it is) then it should also be an optimization to swap out chunks of pages when we need to free memory.
So, how do we go about this grouping? I suggest that if we keep per-VMA reference/fault/dirty statistics, we can tell which logically distinct chunks of memory are being regularly used. This would also us to apply different page replacement policies to chunks of memory that are being used in different fashions.
With such statistics, we could then page out VMAs in 2MB chunks when we're under memory pressure, also giving us the option of transparently paging them back in to hugepages when we have the memory free, once anonymous hugepage support is in place.
I'm inclined to view swap prefetch as a successful scientific experiment, and use that data to inform a more reasoned engineering effort. If we can design something intelligent which happens to behave more or less like swap prefetch does under the circumstances where swap prefetch helps, and does something else smart under the circumstances where swap prefetch makes no discernable difference, it'll be a much bigger improvement.
Because we cannot prove why the existing patch helps, we cannot say what impact it will have when things like virtualization and solid state drives radically change the coefficients of the equation we have not solved. Providing a sysctl to turn off a misbehaving feature is a poor substitute for doing it right the first time, and leaving it off by default will ensure that it only gets used by the handful of people who know enough to rebuild with the patch anyway.
Quoted 5 lines
Let's talk about how we can make page replacement smarter, so it naturally accomplishes what swap prefetch accomplishes, as part of a design we can reason about.
CC-ing linux-mm, since that's where I think we should take this next.
Good idea, but unless we understand the problems involved, we are bound to repeat it. So my first question would be: Why is swap-in so slow?
As I have posted in other threads, swap-in of consecutive pages suffers a 2x slowdown wrt swap-out, whereas swap-in of random pages suffers over 6x slowdown.
Because it is hard to quantify the expected swap-in speed for random pages, let's first tackle the swap-in of consecutive pages, which should be at least as fast as swap-out. So again, why is swap-in so slow?
Once we understand this problem, we may be able to suggest a smart improvement.
Thanks!
--
Al
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · Chris Snook
Quoted 7 lines · Al Boldi
IMHO, what everybody agrees on, is that swap-prefetch has a positive effect in some cases, and nobody can prove an adverse effect (excluding power consumption). The reason for this positive effect is also crystal
clear: It prefetches from swap on idle into free memory, ie: it doesn't force anybody out, and they are the first to be dropped without further swap-out, which sounds really smart.
Quoted 5 lines
Quoted 2 lines
Conclusion: Either prove swap-prefetch is broken, or get this merged quick.
If you can't prove why it helps and doesn't hurt, then it's a hack, by definition.
Ok, slow down: swap-prefetch isn't a hack. It's a kernel-thread that adds swap-prefetch functionality to the kernel.
Quoted 3 lines
With swap prefetch, we're only optimizing the case when the box isn't loaded and there's RAM free, but we're not optimizing the case when the box is heavily loaded and we need for RAM to be free.
Exactly, swap-prefetch is very specific, and that's why it's so successful:
It does one thing, and it does that very well.
Quoted 6 lines
I'm inclined to view swap prefetch as a successful scientific experiment, and use that data to inform a more reasoned engineering effort. If we can design something intelligent which happens to behave more or less like swap prefetch does under the circumstances where swap prefetch helps, and does something else smart under the circumstances where swap prefetch makes no discernable difference, it'll be a much bigger improvement.
Well, a swapless OS would really be the ultimate, but that's another thread entirely (see thread: '[RFC] VM: I have a dream...')
Don't mistake swap-prefetch as trying to additionally fix swap-in slowdown, and if it did, then that would be a hack, but it doesn't.
Instead, understand that swap-prefetch is viable even if all swapper issues have been solved, because swapping implies pages being swapped in when needed, and swap-prefetch smartly uses idle time to do so.
Quoted 7 lines
Because we cannot prove why the existing patch helps, we cannot say what impact it will have when things like virtualization and solid state drives radically change the coefficients of the equation we have not solved. Providing a sysctl to turn off a misbehaving feature is a poor substitute for doing it right the first time, and leaving it off by default will ensure that it only gets used by the handful of people who know enough to rebuild with the patch anyway.
But we do know why it helps: a proc eats memory, then page-cache, then swaps others out, and then dies to free its memory, and now swap-prefetch comes in if the system is idle. Sounds really smart.
While many people may definitely benefit, others may just want to turn it off. No harm done.
Thanks!
--
Al
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: How can we make page replacement smarter (was: swap-prefetch)
In reply to Al BoldiQuoted 54 lines · Al Boldi
Quoted 53 lines · Chris Snook
Resource size has been outpacing processing latency since the dawn of time. Disks get bigger much faster than seek times shrink. Main memory and cache keep growing, while single-threaded processing speed has nearly ground to a halt.
In the old days, it made lots of sense to manage resource allocation in pages and blocks. In the past few years, we started reserving blocks in ext3 automatically because it saves more in seek time than it costs in disk space. Now we're taking preallocation and antifragmentation to the next level with extent-based allocation in ext4.
Well, we're still using bitmap-style allocation for pages, and the prefetch-less swap mechanism adheres to this design as well. Maybe it's time to start thinking about memory in a somewhat more extent-like fashion.
With swap prefetch, we're only optimizing the case when the box isn't loaded and there's RAM free, but we're not optimizing the case when the box is heavily loaded and we need for RAM to be free. This is a complete reversal of sane development priorities. If swap batching is an optimization at all (and we have empirical evidence that it is) then it should also be an optimization to swap out chunks of pages when we need to free memory.
So, how do we go about this grouping? I suggest that if we keep per-VMA reference/fault/dirty statistics, we can tell which logically distinct chunks of memory are being regularly used. This would also us to apply different page replacement policies to chunks of memory that are being used in different fashions.
With such statistics, we could then page out VMAs in 2MB chunks when we're under memory pressure, also giving us the option of transparently paging them back in to hugepages when we have the memory free, once anonymous hugepage support is in place.
I'm inclined to view swap prefetch as a successful scientific experiment, and use that data to inform a more reasoned engineering effort. If we can design something intelligent which happens to behave more or less like swap prefetch does under the circumstances where swap prefetch helps, and does something else smart under the circumstances where swap prefetch makes no discernable difference, it'll be a much bigger improvement.
Because we cannot prove why the existing patch helps, we cannot say what
impact it will have when things like virtualization and solid state drives
radically change the coefficients of the equation we have not solved. Providing a sysctl to turn off a misbehaving feature is a poor substitute for doing it right the first time, and leaving it off by default will
ensure that it only gets used by the handful of people who know enough to
rebuild with the patch anyway.Let's talk about how we can make page replacement smarter, so it naturally accomplishes what swap prefetch accomplishes, as part of a design we can reason about.
Quoted 7 lines
Quoted 1 line
CC-ing linux-mm, since that's where I think we should take this next.
Good idea, but unless we understand the problems involved, we are bound to repeat it. So my first question would be: Why is swap-in so slow?
As I have posted in other threads, swap-in of consecutive pages suffers a 2x slowdown wrt swap-out, whereas swap-in of random pages suffers over 6x slowdown.
Because it is hard to quantify the expected swap-in speed for random pages, let's first tackle the swap-in of consecutive pages, which should be at least as fast as swap-out. So again, why is swap-in so slow?
If I'm writing 20 pages to swap, I can find a suitable chunk of swap and write them all in one place. If I'm reading 20 pages from swap, they could be anywhere. Also, writes get buffered at one or more layers of hardware. At best, reads can be read-ahead and cached, which is why sequential swap-in sucks less. On-demand reads are as expensive as I/O can get.
Quoted 1 line
Once we understand this problem, we may be able to suggest a smart improvement.
There are lots of page replacement schemes that optimize for different access patterns, and they all suck at certain other access patterns. We tweak our behavior slightly based on fadvise and madvise hints, but most of the memory we're managing is an opaque mass. With more statistics, we could do a better job of managing chunks of unhinted memory with disparate access patterns. Of course, this imposes overhead. I suggested VMA granularity because a VMA represents a logically distinct piece of address space, though this may not be suitable for shared mappings.
-- Chris
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: How can we make page replacement smarter (was: swap-prefetch)
Quoted 9 lines · Chris Snook
Quoted 3 lines · Al Boldi
Because it is hard to quantify the expected swap-in speed for random pages, let's first tackle the swap-in of consecutive pages, which should be at least as fast as swap-out. So again, why is swap-in so slow?
If I'm writing 20 pages to swap, I can find a suitable chunk of swap and write them all in one place. If I'm reading 20 pages from swap, they could be anywhere. Also, writes get buffered at one or more layers of hardware.
Ok, this explains swap-in of random pages. Makes sense, but it doesn't explain the awful tmpfs performance degradation of consecutive read-in runs from swap, which should have at least stayed constant
Quoted 3 lines
At best, reads can be read-ahead and cached, which is why sequential swap-in sucks less. On-demand reads are as expensive as I/O can get.
Which means that it should be at least as fast as swap-out, even faster because write to disk is usually slower than read on modern disks. But linux currently shows a distinct 2x slowdown for sequential swap-in wrt swap-out. And to prove this point, just try suspend to disk where you can see sequential swap-out being reported at about twice the speed of sequential swap-in on resume. Why is that?
Thanks!
--
Al
Quoted 5 lines · Indan Zupancic
Perhaps one of the reasons is that this is core kernel code. And that it isn't a new feature, but a performance improvement with doubtful trade-offs. The problem statement isn't clear either. It seems like a natural enhancement, but is that enough reason to merge it? Maybe, maybe not. But if slow swap-in is the problem, shouldn't that be fixed instead of bypassed?
The problem AFAIK it's clear: Swap in is slow by nature because it's random. Well, it "looks" like it should be random. Now that would be a interesting thing to analyze: locality of the swapped-in stuff for different worloads - if the swapped-in stuff has some locality, then it certainly should possible to fix the swapin code to do some kind of "swapahead". But if the stuff is swapped in completely randomly, only stuff like swap prefetch is going to help.
The good thing about swap prefetch is that it fixes the problem today without forbidding future improvements to the VM.
Re: How can we make page replacement smarter
In reply to Al BoldiQuoted 5 lines · Al Boldi
Good idea, but unless we understand the problems involved, we are bound to repeat it. So my first question would be: Why is swap-in so slow?
As I have posted in other threads, swap-in of consecutive pages suffers a 2x slowdown wrt swap-out, whereas swap-in of random pages suffers over 6x slowdown.
Because it is hard to quantify the expected swap-in speed for random pages, let's first tackle the swap-in of consecutive pages, which should be at least as fast as swap-out. So again, why is swap-in so slow?
I suspect that this is a locality of reference issue.
Anonymous memory can get jumbled up by repeated free and malloc cycles of many smaller objects. The amount of anonymous memory is often smaller than or roughly the same size as system memory.
Locality of refenence to anonymous memory tends to be temporal in nature, with the same sets of pages being accessed over and over again.
Files are different. File content tends to be grouped in large related chunks, both logically in the file and on disk. Generally there is a lot more file data on a system than what fits in memory.
Locality of reference to file data tends to be spatial in nature, with one file access leading up to the system accessing "nearby" data. The data is not necessarily touched again any time soon.
Quoted 1 line
Once we understand this problem, we may be able to suggest a smart improvement.
Like the one on http://linux-mm.org/PageoutFailureModes ?
I have the LRU lists split and am working on getting SEQ replacement implemented for the anonymous pages.
The most recent (untested) patches are attached.
Signature · 3 lines
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic.
drivers/base/node.c renamed from drivers/base/node.c.vmsplit +26 -22
@@ -44,33 +44,37 @@ static ssize_t node_read_meminfo(structsi_meminfo_node (&i, nid); n = sprintf(buf, "\n" - "Node %d MemTotal: %8lu kB\n" - "Node %d MemFree: %8lu kB\n" - "Node %d MemUsed: %8lu kB\n" - "Node %d Active: %8lu kB\n" - "Node %d Inactive: %8lu kB\n" + "Node %d MemTotal: %8lu kB\n" + "Node %d MemFree: %8lu kB\n" + "Node %d MemUsed: %8lu kB\n" + "Node %d Active(anon): %8lu kB\n" + "Node %d Inactive(anon): %8lu kB\n" + "Node %d Active(file): %8lu kB\n" + "Node %d Inactive(file): %8lu kB\n" #ifdef CONFIG_HIGHMEM - "Node %d HighTotal: %8lu kB\n" - "Node %d HighFree: %8lu kB\n" - "Node %d LowTotal: %8lu kB\n" - "Node %d LowFree: %8lu kB\n" + "Node %d HighTotal: %8lu kB\n" + "Node %d HighFree: %8lu kB\n" + "Node %d LowTotal: %8lu kB\n" + "Node %d LowFree: %8lu kB\n" #endif - "Node %d Dirty: %8lu kB\n" - "Node %d Writeback: %8lu kB\n" - "Node %d FilePages: %8lu kB\n" - "Node %d Mapped: %8lu kB\n" - "Node %d AnonPages: %8lu kB\n" - "Node %d PageTables: %8lu kB\n" - "Node %d NFS_Unstable: %8lu kB\n" - "Node %d Bounce: %8lu kB\n" - "Node %d Slab: %8lu kB\n" - "Node %d SReclaimable: %8lu kB\n" - "Node %d SUnreclaim: %8lu kB\n", + "Node %d Dirty: %8lu kB\n" + "Node %d Writeback: %8lu kB\n" + "Node %d FilePages: %8lu kB\n" + "Node %d Mapped: %8lu kB\n" + "Node %d AnonPages: %8lu kB\n" + "Node %d PageTables: %8lu kB\n" + "Node %d NFS_Unstable: %8lu kB\n" + "Node %d Bounce: %8lu kB\n" + "Node %d Slab: %8lu kB\n" + "Node %d SReclaimable: %8lu kB\n" + "Node %d SUnreclaim: %8lu kB\n", nid, K(i.totalram), nid, K(i.freeram), nid, K(i.totalram - i.freeram), - nid, node_page_state(nid, NR_ACTIVE), - nid, node_page_state(nid, NR_INACTIVE), + nid, node_page_state(nid, NR_ACTIVE_ANON), + nid, node_page_state(nid, NR_INACTIVE_ANON), + nid, node_page_state(nid, NR_ACTIVE_FILE), + nid, node_page_state(nid, NR_INACTIVE_FILE), #ifdef CONFIG_HIGHMEM nid, K(i.totalhigh), nid, K(i.freehigh),
fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c.vmsplit +35 -31
78 lines not on this page · raw message
fs/exec.c renamed from fs/exec.c.vmsplit +1 -1
@@ -327,7 +327,7 @@ void install_arg_page(struct vm_area_str goto out; }inc_mm_counter (mm, anon_rss); -lru_cache_add_active (page); +lru_cache_add_active_anon (page);set_pte_at (mm, address, pte,pte_mkdirty (pte_mkwrite (mk_pte ( page, vma->vm_page_prot))));page_add_new_anon_rmap (page, vma, address);
fs/mpage.c renamed from fs/mpage.c.vmsplit +2 -2
@@ -406,12 +406,12 @@ mpage_readpages(struct address_space *ma &first_logical_block, get_block);if (!pagevec_add (&lru_pvec, page)) -__pagevec_lru_add (&lru_pvec); +__pagevec_lru_add_file (&lru_pvec); }else {page_cache_release (page); } } -pagevec_lru_add (&lru_pvec); +pagevec_lru_add_file (&lru_pvec);BUG_ON (!list_empty (pages));if (bio)mpage_bio_submit (READ , bio);
include/linux/mm.h renamed from include/linux/mm.h.vmsplit +18 -0
@@ -617,6 +617,24 @@ static inline int PageAnon(struct page *return ((unsigned long )page->mapping &PAGE_MAPPING_ANON ) !=0 ; } +/* Returns true if this page is anonymous, tmpfs or otherwise swap backed. */ +extern const struct address_space_operations shmem_aops; +static inline int page_anon (struct page *page) +{ +struct address_space *mapping =page_mapping (page); + +if (PageAnon (page) ||PageSwapCache (page)) +return 1 ; +if (mapping->a_ops == &shmem_aops) +return 1 ; +/* Should ramfs pages go onto an mlocked list instead? */ +if ((unlikely (mapping->a_ops->writepage ==NULL ))) +return 1 ; + +/* The page is page cache backed by a normal filesystem. */ +return 0 ; +} +/* * Return the pagecache index of the passed page. Regular pagecache pages * use ->index whereas swapcache pages use ->private
include/linux/mm_inline.h renamed from include/linux/mm_inline.h.vmsplit +46 -12
84 lines not on this page · raw message
include/linux/mmzone.h renamed from include/linux/mmzone.h.vmsplit +17 -7
@@ -49,15 +49,17 @@ struct zone_padding {enum zone_stat_item {/* First 128 byte cacheline (assuming 64 bit words) */ NR_FREE_PAGES , -NR_INACTIVE , -NR_ACTIVE , +NR_ACTIVE_ANON , +NR_INACTIVE_ANON , +NR_ACTIVE_FILE , +NR_INACTIVE_FILE ,NR_ANON_PAGES ,/* Mapped anonymous pages */ NR_FILE_MAPPED ,/* pagecache pages mapped into pagetables. only modified from process context */ NR_FILE_PAGES , +/* Second 128 byte cacheline */ NR_FILE_DIRTY ,NR_WRITEBACK , -/* Second 128 byte cacheline */ NR_SLAB_RECLAIMABLE ,NR_SLAB_UNRECLAIMABLE ,NR_PAGETABLE ,/* used for pagetables */
@@ -218,10 +220,18 @@ struct zone {/* Fields commonly accessed by the page reclaim scanner */ spinlock_t lru_lock; -struct list_head active_list; -struct list_head inactive_list; -unsigned long nr_scan_active; -unsigned long nr_scan_inactive; +struct list_head active_anon_list; +struct list_head inactive_anon_list; +struct list_head active_file_list; +struct list_head inactive_file_list; +unsigned long nr_scan_active_anon; +unsigned long nr_scan_inactive_anon; +unsigned long nr_scan_active_file; +unsigned long nr_scan_inactive_file; +unsigned long recent_rotated_anon; +unsigned long recent_rotated_file; +unsigned long recent_scanned_anon; +unsigned long recent_scanned_file;unsigned long pages_scanned;/* since last reclaim */ int all_unreclaimable;/* All pages pinned */
include/linux/pagevec.h renamed from include/linux/pagevec.h.vmsplit +12 -4
@@ -23,8 +23,10 @@ struct pagevec {void __pagevec_release (struct pagevec *pvec);void __pagevec_release_nonlru (struct pagevec *pvec);void __pagevec_free (struct pagevec *pvec); -void __pagevec_lru_add (struct pagevec *pvec); -void __pagevec_lru_add_active (struct pagevec *pvec); +void __pagevec_lru_add_file (struct pagevec *pvec); +void __pagevec_lru_add_active_file (struct pagevec *pvec); +void __pagevec_lru_add_anon (struct pagevec *pvec); +void __pagevec_lru_add_active_anon (struct pagevec *pvec);void pagevec_strip (struct pagevec *pvec);unsigned pagevec_lookup (struct pagevec *pvec,struct address_space *mapping,pgoff_t start,unsigned nr_pages);
@@ -81,10 +83,16 @@ static inline void pagevec_free(struct p __pagevec_free(pvec); } -static inline void pagevec_lru_add (struct pagevec *pvec) +static inline void pagevec_lru_add_file (struct pagevec *pvec) {if (pagevec_count (pvec)) -__pagevec_lru_add (pvec); +__pagevec_lru_add_file (pvec); +} + +static inline void pagevec_lru_add_anon (struct pagevec *pvec) +{ +if (pagevec_count (pvec)) +__pagevec_lru_add_anon (pvec); }#endif /* _LINUX_PAGEVEC_H */
include/linux/swap.h renamed from include/linux/swap.h.vmsplit +6 -3
@@ -178,9 +178,12 @@ extern unsigned int nr_free_pagecache_pa/* linux/mm/swap.c */ -extern void FASTCALL (lru_cache_add (struct page *)); -extern void FASTCALL (lru_cache_add_active (struct page *)); -extern void FASTCALL (activate_page (struct page *)); +extern void FASTCALL (lru_cache_add_file (struct page *)); +extern void FASTCALL (lru_cache_add_anon (struct page *)); +extern void FASTCALL (lru_cache_add_active_file (struct page *)); +extern void FASTCALL (lru_cache_add_active_anon (struct page *)); +extern void FASTCALL (activate_page_anon (struct page *)); +extern void FASTCALL (activate_page_file (struct page *));extern void FASTCALL (mark_page_accessed (struct page *));extern void lru_add_drain (void );extern int lru_add_drain_all (void );
mm/filemap.c renamed from mm/filemap.c.vmsplit +3 -3
@@ -462,7 +462,7 @@ int add_to_page_cache_lru(struct page *p {int ret =add_to_page_cache (page, mapping, offset, gfp_mask);if (ret ==0 ) -lru_cache_add (page); +lru_cache_add_file (page);return ret; }
@@ -1870,7 +1870,7 @@ repeat: page = *cached_page;page_cache_get (page);if (!pagevec_add (lru_pvec, page)) -__pagevec_lru_add (lru_pvec); +__pagevec_lru_add_file (lru_pvec); *cached_page =NULL ; } }
@@ -2231,7 +2231,7 @@ zero_length_segment:if (unlikely (file->f_flags &O_DIRECT ) && written) status =filemap_write_and_wait (mapping); -pagevec_lru_add (&lru_pvec); +pagevec_lru_add_file (&lru_pvec);return written ? written : status; }EXPORT_SYMBOL (generic_file_buffered_write);
mm/memory.c renamed from mm/memory.c.vmsplit +3 -3
@@ -1745,7 +1745,7 @@ gotten:ptep_clear_flush (vma, address, page_table);set_pte_at (mm, address, page_table, entry);update_mmu_cache (vma, address, entry); -lru_cache_add_active (new_page); +lru_cache_add_active_anon (new_page);page_add_new_anon_rmap (new_page, vma, address);/* Free the old page.. */
@@ -2242,7 +2242,7 @@ static int do_anonymous_page(struct mm_sif (!pte_none (*page_table)) goto release;inc_mm_counter (mm, anon_rss); -lru_cache_add_active (page); +lru_cache_add_active_anon (page);page_add_new_anon_rmap (page, vma, address); }else {/* Map the ZERO_PAGE - vm_page_prot is readonly */
@@ -2389,7 +2389,7 @@ retry:set_pte_at (mm, address, page_table, entry);if (anon) {inc_mm_counter (mm, anon_rss); -lru_cache_add_active (new_page); +lru_cache_add_active_anon (new_page);page_add_new_anon_rmap (new_page, vma, address); }else {inc_mm_counter (mm, file_rss);
mm/migrate.c renamed from mm/migrate.c.vmsplit +19 -6
@@ -53,10 +53,17 @@ int isolate_lru_page(struct page *page, ret =0 ;get_page (page);ClearPageLRU (page); -if (PageActive (page)) -del_page_from_active_list (zone, page); -else -del_page_from_inactive_list (zone, page); +if (PageActive (page)) { +if (page_anon (page)) +del_page_from_active_anon_list (zone, page); +else +del_page_from_active_file_list (zone, page); + }else { +if (page_anon (page)) +del_page_from_inactive_anon_list (zone, page); +else +del_page_from_inactive_file_list (zone, page); + }list_add_tail (&page->lru, pagelist); }spin_unlock_irq (&zone->lru_lock);
@@ -89,9 +96,15 @@ static inline void move_to_lru(struct pa* the PG_active bit is off. */ ClearPageActive (page); -lru_cache_add_active (page); +if (page_anon (page)) +lru_cache_add_active_anon (page); +else +lru_cache_add_active_file (page); }else { -lru_cache_add (page); +if (page_anon (page)) +lru_cache_add_anon (page); +else +lru_cache_add_file (page); }put_page (page); }
mm/page_alloc.c renamed from mm/page_alloc.c.vmsplit +24 -11
@@ -1544,10 +1544,13 @@ void show_free_areas(void) } } - printk("Active:%lu inactive:%lu dirty:%lu writeback:%lu unstable:%lu\n" + printk("Active_anon:%lu active_file:%lu inactive_anon%lu\n" + " inactive_file:%lu dirty:%lu writeback:%lu unstable:%lu\n" " free:%lu slab:%lu mapped:%lu pagetables:%lu bounce:%lu\n", - global_page_state(NR_ACTIVE), - global_page_state(NR_INACTIVE), + global_page_state(NR_ACTIVE_ANON), + global_page_state(NR_ACTIVE_FILE), + global_page_state(NR_INACTIVE_ANON), + global_page_state(NR_INACTIVE_FILE), global_page_state(NR_FILE_DIRTY), global_page_state(NR_WRITEBACK), global_page_state(NR_UNSTABLE_NFS),
@@ -1570,8 +1573,10 @@ void show_free_areas(void)" min:%lukB" " low:%lukB" " high:%lukB" -" active:%lukB" -" inactive:%lukB" +" active_anon:%lukB" +" inactive_anon:%lukB" +" active_file:%lukB" +" inactive_file:%lukB" " present:%lukB" " pages_scanned:%lu" " all_unreclaimable? %s"
@@ -1581,8 +1586,10 @@ void show_free_areas(void)K (zone->pages_min),K (zone->pages_low),K (zone->pages_high), -K (zone_page_state (zone,NR_ACTIVE )), -K (zone_page_state (zone,NR_INACTIVE )), +K (zone_page_state (zone,NR_ACTIVE_ANON )), +K (zone_page_state (zone,NR_INACTIVE_ANON )), +K (zone_page_state (zone,NR_ACTIVE_FILE )), +K (zone_page_state (zone,NR_INACTIVE_FILE )),K (zone->present_pages), zone->pages_scanned, (zone->all_unreclaimable ?"yes" :"no" )
@@ -2647,10 +2654,16 @@ static void __meminit free_area_init_cor zone->prev_priority =DEF_PRIORITY ;zone_pcp_init (zone); -INIT_LIST_HEAD (&zone->active_list); -INIT_LIST_HEAD (&zone->inactive_list); - zone->nr_scan_active =0 ; - zone->nr_scan_inactive =0 ; +INIT_LIST_HEAD (&zone->active_anon_list); +INIT_LIST_HEAD (&zone->inactive_anon_list); +INIT_LIST_HEAD (&zone->active_file_list); +INIT_LIST_HEAD (&zone->inactive_file_list); + zone->nr_scan_active_anon =0 ; + zone->nr_scan_inactive_anon =0 ; + zone->nr_scan_active_file =0 ; + zone->nr_scan_inactive_file =0 ; + zone->recent_rotated_anon =0 ; + zone->recent_rotated_file =0 ;zap_zone_vm_stats (zone);atomic_set (&zone->reclaim_in_progress,0 );if (!size)
mm/readahead.c renamed from mm/readahead.c.vmsplit +5 -5
@@ -147,14 +147,14 @@ int read_cache_pages(struct address_spac } ret =filler (data, page);if (!pagevec_add (&lru_pvec, page)) -__pagevec_lru_add (&lru_pvec); +__pagevec_lru_add_file (&lru_pvec);if (ret) {put_pages_list (pages);break ; }task_io_account_read (PAGE_CACHE_SIZE ); } -pagevec_lru_add (&lru_pvec); +pagevec_lru_add_file (&lru_pvec);return ret; }
@@ -182,11 +182,11 @@ static int read_pages(struct address_spa page->index, GFP_KERNEL)) { mapping->a_ops->readpage (filp, page);if (!pagevec_add (&lru_pvec, page)) -__pagevec_lru_add (&lru_pvec); +__pagevec_lru_add_file (&lru_pvec); } elsepage_cache_release (page ); } -pagevec_lru_add (&lru_pvec); +pagevec_lru_add_file (&lru_pvec); ret =0 ; out:return ret;
@@ -578,6 +578,6 @@ void handle_ra_miss(struct address_space*/ unsigned long max_sane_readahead (unsigned long nr) { -return min (nr, (node_page_state (numa_node_id (),NR_INACTIVE ) +return min (nr, (node_page_state (numa_node_id (),NR_INACTIVE_FILE ) +node_page_state (numa_node_id (),NR_FREE_PAGES )) /2 ); }
mm/shmem.c renamed from mm/shmem.c.vmsplit +2 -2
@@ -176,7 +176,7 @@ static inline void shmem_unacct_blocks(u }static const struct super_operations shmem_ops; -static const struct address_space_operations shmem_aops; +const struct address_space_operations shmem_aops;static const struct file_operations shmem_file_operations;static const struct inode_operations shmem_inode_operations;static const struct inode_operations shmem_dir_inode_operations;
@@ -2382,7 +2382,7 @@ static void destroy_inodecache(void)kmem_cache_destroy (shmem_inode_cachep); } -static const struct address_space_operations shmem_aops = { +const struct address_space_operations shmem_aops = { .writepage = shmem_writepage, .set_page_dirty = __set_page_dirty_no_writeback, #ifdef CONFIG_TMPFS
mm/swap_state.c renamed from mm/swap_state.c.vmsplit +1 -1
@@ -354,7 +354,7 @@ struct page *read_swap_cache_async(swp_e/* * Initiate read into locked page and return. */ -lru_cache_add_active (new_page); +lru_cache_add_anon (new_page);swap_readpage (NULL , new_page);return new_page; }
mm/vmscan.c renamed from mm/vmscan.c.vmsplit +253 -143
563 lines not on this page · raw message
mm/vmstat.c renamed from mm/vmstat.c.vmsplit +9 -4
@@ -477,8 +477,10 @@ const struct seq_operations fragmentatiostatic const char *const vmstat_text[] = {/* Zoned VM counters */ "nr_free_pages" , -"nr_active" , -"nr_inactive" , +"nr_active_anon" , +"nr_inactive_anon" , +"nr_active_file" , +"nr_inactive_file" ,"nr_anon_pages" ,"nr_mapped" ,"nr_file_pages" ,
@@ -554,7 +556,7 @@ static int zoneinfo_show(struct seq_file"\n min %lu" "\n low %lu" "\n high %lu" -"\n scanned %lu (a: %lu i: %lu)" +"\n scanned %lu (ao: %lu io: %lu af: %lu if: %lu)" "\n spanned %lu" "\n present %lu" , zone_page_state(zone, NR_FREE_PAGES),
@@ -562,7 +564,10 @@ static int zoneinfo_show(struct seq_file zone->pages_low, zone->pages_high, zone->pages_scanned, - zone->nr_scan_active, zone->nr_scan_inactive, + zone->nr_scan_active_anon, + zone->nr_scan_inactive_anon, + zone->nr_scan_active_file, + zone->nr_scan_inactive_file, zone->spanned_pages, zone->present_pages);
mm/page-writeback.c renamed from mm/page-writeback.c.vmsplit +2 -2
@@ -151,8 +151,8 @@ static unsigned long determine_dirtyableunsigned long x; x =global_page_state (NR_FREE_PAGES ) - +global_page_state (NR_INACTIVE ) - +global_page_state (NR_ACTIVE ); + +global_page_state (NR_INACTIVE_FILE ) + +global_page_state (NR_ACTIVE_FILE ); x -=highmem_dirtyable_memory (x);return x +1 ;/* Ensure that we never return 0 */ }
mm/swap.c renamed from mm/swap.c.vmsplit +124 -24
223 lines not on this page · raw message
mm/swapfile.c renamed from mm/swapfile.c.vmsplit +2 -2
@@ -519,7 +519,7 @@ static void unuse_pte(struct vm_area_str* Move the page to the active list so it is not * immediately swapped out again after swapon. */ -activate_page (page); +activate_page_anon (page); } static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
@@ -621,7 +621,7 @@ static int unuse_mm(struct mm_struct *mm* Activate page so shrink_cache is unlikely to unmap its * ptes while lock is dropped, so swapoff can make progress. */ -activate_page (page); +activate_page_anon (page);unlock_page (page);down_read (&mm->mmap_sem);lock_page (page);
mm/vmscan.c renamed from mm/vmscan.c.swapfree +7 -0
@@ -892,6 +892,13 @@ static void get_scan_ratio(struct zone *unsigned long anon_prio, file_prio;unsigned long rotate_sum; +/* If there is no free swap space, do not scan anonymous pages. */ +if (nr_swap_pages <=0 ) { + *anon_percent =0 ; + *file_percent =100 ; +return ; + } + anon =zone_page_state (zone,NR_ACTIVE_ANON ) +zone_page_state (zone,NR_INACTIVE_ANON ); file = zone_page_state(zone, NR_ACTIVE_FILE) +
Re: How can we make page replacement smarter (was: swap-prefetch)
In reply to Al BoldiQuoted 7 lines · Al Boldi
Quoted 3 lines · Chris Snook
At best, reads can be read-ahead and cached, which is why sequential swap-in sucks less. On-demand reads are as expensive as I/O can get.
Which means that it should be at least as fast as swap-out, even faster because write to disk is usually slower than read on modern disks. But linux currently shows a distinct 2x slowdown for sequential swap-in wrt swap-out.
That's because writes are faster than reads in moderate quantities.
The disk caches writes, allowing the OS to write a whole bunch of data into the disk cache and the disk can optimize the IO a bit internally.
The same optimization is not possible for reads.
Signature · 9 lines
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: How can we make page replacement smarter (was: swap-prefetch)
Inline..
Mitchell Erblich
Quoted 8 lines · Rik van Riel
Quoted 6 lines · Al Boldi
Quoted 3 lines · Chris Snook
At best, reads can be read-ahead and cached, which is why sequential swap-in sucks less. On-demand reads are as expensive as I/O can get.
Quoted 8 lines
Quoted 4 lines
Which means that it should be at least as fast as swap-out, even faster because write to disk is usually slower than read on modern disks. But linux currently shows a distinct 2x slowdown for sequential swap-in wrt swap-out.
That's because writes are faster than reads in moderate quantities.
Assuming that the write is not a partial write based on first doing a read..
Yes, a COW FS minimes this condition (ex: ZFS)
However, since writes are mostly asynch in nature most writers shouldn't care when the write is actually commited, just that the data is stable at some point in the future..
Thus, who would care (as long as we are not waiting for the write to complete) if the write was slower. IMO, it would make sense to ALMOST always generate a certain amount of writable data before the write is completed to attempt for the write to be as "sequential" on the disk, so any later reads would have minimal seeks..
Quoted 7 lines
The disk caches writes, allowing the OS to write a whole bunch of data into the disk cache and the disk can optimize the IO a bit internally.
The same optimization is not possible for reads.
Quoted 9 lines
--
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: How can we make page replacement smarter
In reply to Rik van RielQuoted 4 lines
Files are different. File content tends to be grouped in large related chunks, both logically in the file and on disk. Generally there is a lot more file data on a system than what fits in memory.
Binary paging patterns don't always look like that unfortunately although I suspect we might want to be weighing towards paging out R/O file mapped pages earlier simply because they are bigger linear chunks
Re: How can we make page replacement smarter
In reply to Rik van RielQuoted 12 lines · Rik van Riel
Quoted 10 lines · Al Boldi
Good idea, but unless we understand the problems involved, we are bound to repeat it. So my first question would be: Why is swap-in so slow?
As I have posted in other threads, swap-in of consecutive pages suffers a 2x slowdown wrt swap-out, whereas swap-in of random pages suffers over 6x slowdown.
Because it is hard to quantify the expected swap-in speed for random pages, let's first tackle the swap-in of consecutive pages, which should be at least as fast as swap-out. So again, why is swap-in so slow?
Quoted 6 lines
I suspect that this is a locality of reference issue.
Anonymous memory can get jumbled up by repeated free and malloc cycles of many smaller objects. The amount of anonymous memory is often smaller than or roughly the same size as system memory.
Sounds exactly like the tmpfs problem.
Quoted 14 lines
Locality of refenence to anonymous memory tends to be temporal in nature, with the same sets of pages being accessed over and over again.
Files are different. File content tends to be grouped in large related chunks, both logically in the file and on disk. Generally there is a lot more file data on a system than what fits in memory.
Locality of reference to file data tends to be spatial in nature, with one file access leading up to the system accessing "nearby" data. The data is not necessarily touched again any time soon.
Quoted 4 lines
Quoted 2 lines
Once we understand this problem, we may be able to suggest a smart improvement.
Like the one on http://linux-mm.org/PageoutFailureModes ?
Interesting to see that there are known problems, but it doesn't seem to list the resume-from-disk swap-in slowdown.
Quoted 4 lines
I have the LRU lists split and am working on getting SEQ replacement implemented for the anonymous pages.
The most recent (untested) patches are attached.
Applied against 2.6.22; the kernel crashes out on boot.
Thanks!
--
Al
Re: How can we make page replacement smarter
In reply to Alan CoxQuoted 8 lines · Alan Cox
Quoted 4 lines
Files are different. File content tends to be grouped in large related chunks, both logically in the file and on disk. Generally there is a lot more file data on a system than what fits in memory.
Binary paging patterns don't always look like that unfortunately although I suspect we might want to be weighing towards paging out R/O file mapped pages earlier simply because they are bigger linear chunks
A properly implemented use-once algorithm should be able to filter out the spatial locality of reference pages from the temporal locality of reference ones, though...
Signature · 9 lines
Politics is the struggle between those who want to make their country the best in the world, and those who believe it already is. Each group calls the other unpatriotic. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>