Skip to contentSkip to conversation

2.6.22 -mm merge plans

PATCH In review Andrew Morton 62 participants 235 messages Apr 30, 2007 – May 23, 2007 1 message not in the archive Page 2 of 2

Subsystems (20)
lore
Share & tools
lore
#215 lore raw

Re: [PATCH] mm: swap prefetch improvements

In reply to Ingo Molnar
Quoted 24 lines · Ingo Molnar
Quoted 3 lines · Con Kolivas

It turns out that fixing swap prefetch was not that hard to fix and improve upon, and since Andrew hasn't dropped swap prefetch, instead here are a swag of fixes and improvements, [...]

it's a reliable win on my testbox too:

 # echo 1 > /proc/sys/vm/swap_prefetch

Timed portion 30279 milliseconds

versus:

 # echo 0 > /proc/sys/vm/swap_prefetch
 # ./sp_tester
 [...]

Timed portion 36605 milliseconds

i've repeated these tests to make sure it's a stable win and indeed it is:

# swap-prefetch-on:

Quoted 7 lines

Timed portion 29704 milliseconds

# swap-prefetch-off:

Timed portion 34863 milliseconds

Nice work Con!

Thanks!

Quoted 6 lines

A suggestion for improvement: right now swap-prefetch does a small bit of swapin every 5 seconds and stays idle inbetween. Could this perhaps be made more agressive (optionally perhaps), if the system is not swapping otherwise? If block-IO level instrumentation is needed to determine idleness of block IO then that is justified too i think.

Hmm.. The timer waits 5 seconds before trying to prefetch, but then only stops if it detects any activity elsewhere. It doesn't actually try to go idle in between but it doesn't take much activity to put it back to sleep, hence detecting yet another "not quite idle" period and then it goes to sleep again. I guess the sleep interval can actually be changed as another tunable from 5 seconds to whatever the user wanted.

Quoted 6 lines

Another suggestion: swap-prefetch seems to be doing all the right decisions in the sp_test.c case - so would it be possible to add statistics so that it could be verified how much of the swapped-in pages were indeed a 'hit' - and how many were recycled without them being reused? That could give a reliable, objective metric about how efficient swap-prefetch is in any workload.

Well the advantage is twofold potentially; 1. the pages that have been prefecthed and become minor faults when they would have been major faults, and 2. those that become minor faults (via 1) and then become major faults again (since a copy is kept on backing store with swap prefetch). The sp_tester only tests for 1, although it would be easy enough to simply do another big malloc at the end and see how fast it swapped out again as a marker of 2. As for an in-kernel option, it could get kind of expensive tracking pages that have done one or both of these. I'll think about an affordable way to do this, perhaps it could be just done as a debugging/testing patch, but if would be nice to make it cheap enough to have there permanently as well. The pages end up in swap cache (in the reverse direction pages normally get to swap cache) so the accounting could be done somewhere around there.

Quoted 1 line

Ingo

Thanks for comments!

Signature · 7 lines
-ck

--
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>
#216 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 7 lines · Con Kolivas
Quoted 6 lines

A suggestion for improvement: right now swap-prefetch does a small bit of swapin every 5 seconds and stays idle inbetween. Could this perhaps be made more agressive (optionally perhaps), if the system is not swapping otherwise? If block-IO level instrumentation is needed to determine idleness of block IO then that is justified too i think.

Quoted 7 lines

Hmm.. The timer waits 5 seconds before trying to prefetch, but then only stops if it detects any activity elsewhere. It doesn't actually try to go idle in between but it doesn't take much activity to put it back to sleep, hence detecting yet another "not quite idle" period and then it goes to sleep again. I guess the sleep interval can actually be changed as another tunable from 5 seconds to whatever the user wanted.

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

Ingo

--
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>

#217 lore raw

Re: [PATCH] mm: swap prefetch improvements

2007/5/21, Ingo Molnar <[email protected]>:

Quoted 18 lines · Con Kolivas
Quoted 8 lines
Quoted 7 lines

A suggestion for improvement: right now swap-prefetch does a small bit of swapin every 5 seconds and stays idle inbetween. Could this perhaps be made more agressive (optionally perhaps), if the system is not swapping otherwise? If block-IO level instrumentation is needed to determine idleness of block IO then that is justified too i think.

Quoted 7 lines

Hmm.. The timer waits 5 seconds before trying to prefetch, but then only stops if it detects any activity elsewhere. It doesn't actually try to go idle in between but it doesn't take much activity to put it back to sleep, hence detecting yet another "not quite idle" period and then it goes to sleep again. I guess the sleep interval can actually be changed as another tunable from 5 seconds to whatever the user wanted.

Quoted 3 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

Regards,

~ Antonio

--
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>

#218 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 17 lines · Antonino Ingargiola

2007/5/21, Ingo Molnar <[email protected]>:

Quoted 16 lines · Con Kolivas
Quoted 14 lines
Quoted 6 lines

A suggestion for improvement: right now swap-prefetch does a small bit of swapin every 5 seconds and stays idle inbetween. Could this perhaps be made more agressive (optionally perhaps), if the system is not swapping otherwise? If block-IO level instrumentation is needed to determine idleness of block IO then that is justified too i think.

Hmm.. The timer waits 5 seconds before trying to prefetch, but then only stops if it detects any activity elsewhere. It doesn't actually try to go idle in between but it doesn't take much activity to put it back to sleep, hence detecting yet another "not quite idle" period and then it goes to sleep again. I guess the sleep interval can actually be changed as another tunable from 5 seconds to whatever the user wanted.

Quoted 6 lines
Quoted 3 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

Signature · 7 lines
-ck

--
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>
#219 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 10 lines · Con Kolivas
Quoted 7 lines
Quoted 4 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

note that nothing like that happened on my system - in the swap-prefetch-off case there was _zero_ IO activity during the sleep period.

Ingo

--
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>

#220 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 9 lines · Ingo Molnar
Quoted 8 lines · Con Kolivas
Quoted 7 lines
Quoted 4 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

Quoted 6 lines
Quoted 2 lines

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

note that nothing like that happened on my system - in the swap-prefetch-off case there was _zero_ IO activity during the sleep period.

Ok, granted it's _very_ conservative. I really don't want to risk its presence being a burden on anything, and the iowait it induces probably makes it turn itself off for another PREFETCH_DELAY (5s). I really don't want to cross the line to where it is detrimental in any way. Not dropping out on a cond_resched and perhaps making the delay tunable should be enough to make it a little less "sleepy".

Signature · 7 lines
-ck

--
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>
#221 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 10 lines · Con Kolivas
Quoted 9 lines · Ingo Molnar
Quoted 8 lines · Con Kolivas
Quoted 7 lines
Quoted 4 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

note that nothing like that happened on my system - in the swap-prefetch-off case there was _zero_ IO activity during the sleep period.

Ok, granted it's _very_ conservative. [...]

but your first reaction was "it should not have slept for 5 seconds":

| Hmm.. The timer waits 5 seconds before trying to prefetch, but then 
| only stops if it detects any activity elsewhere. It doesn't actually 
| try to go idle in between

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

Ingo

--
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>

#222 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 5 lines · Ingo Molnar

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

When nothing else is happening anywhere on the system it reads in bursts and goes to sleep during journal writeout.

Signature · 7 lines
-ck

--
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>
#223 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 9 lines · Con Kolivas
Quoted 5 lines · Ingo Molnar

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

When nothing else is happening anywhere on the system it reads in bursts and goes to sleep during journal writeout.

hm, what do you call 'journal writeout' here that would be happening on my system?

Ingo

--
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>

#224 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 8 lines · Ingo Molnar
Quoted 7 lines · Con Kolivas
Quoted 5 lines · Ingo Molnar

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

Quoted 5 lines
Quoted 2 lines

When nothing else is happening anywhere on the system it reads in bursts and goes to sleep during journal writeout.

hm, what do you call 'journal writeout' here that would be happening on my system?

Not really sure what you have in terms of fs, but here even with nothing going on, ext3 writes to disk every 5 seconds with kjournald.

Signature · 7 lines
-ck

--
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>
#226 lore raw

Re: [PATCH] mm: swap prefetch improvements

In reply to a message not in the archive
Quoted 5 lines · Con Kolivas
Quoted 2 lines

hm, what do you call 'journal writeout' here that would be happening on my system?

Not really sure what you have in terms of fs, but here even with nothing going on, ext3 writes to disk every 5 seconds with kjournald.

i have ext3, but it doesnt do that on my box. Also, i would have noticed any IO activity in the 'swap prefetch off' case. When i said completely idle, i really meant it ;-)

so swap-prefetch stops for 5 seconds for no apparent reason.

Ingo

--
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>

#227 lore raw

Re: [ck] Re: [PATCH] mm: swap prefetch improvements

In reply to Ingo Molnar
Quoted 28 lines · Ingo Molnar
Quoted 10 lines · Con Kolivas
Quoted 9 lines · Ingo Molnar
Quoted 8 lines · Con Kolivas
Quoted 7 lines
Quoted 4 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

note that nothing like that happened on my system - in the swap-prefetch-off case there was _zero_ IO activity during the sleep period.

Ok, granted it's _very_ conservative. [...]

but your first reaction was "it should not have slept for 5 seconds":

| Hmm.. The timer waits 5 seconds before trying to prefetch, but then
| only stops if it detects any activity elsewhere. It doesn't actually
| try to go idle in between
Quoted 5 lines

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

The only "problem" I can see with this idea is in the potential case that it takes up all the IO activity, and so there is never enough IO activity from other progams to trigger the wait mechanism because they don't get a chance to run.

That could probably be "fixed" by capping the IO, though... (with one of those oh-so-lovable "magic numbers" or a tunable)

That said, I don't think there are any issues with the code compensating for its own activity in the "detect activity" mechanism -- assuming there wasn't a major impact in e.g. maintainability or something.

As for the burstyness... considering the "no negative impact" stance, I can understand that. But it seems inefficient, at best...

Signature · 11 lines
Michael Chang

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
Thank you.

--
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>
#228 lore raw

Re: [ck] Re: [PATCH] mm: swap prefetch improvements

Quoted 10 lines · Michael Chang
Quoted 5 lines

It clearly should not consider 'itself' as IO activity. This suggests some bug in the 'detect activity' mechanism, agreed? I'm wondering whether you are seeing the same problem, or is all swap-prefetch IO on your system continuous until it's done [or some other IO comes inbetween]?

The only "problem" I can see with this idea is in the potential case that it takes up all the IO activity, and so there is never enough IO activity from other progams to trigger the wait mechanism because they don't get a chance to run.

i dont understand what you mean. Any 'use only idle IO capacity' mechanism should immediately cease to be active the moment any other app tries to do IO - whether the IO subsystem is saturated or not.

Quoted 7 lines

That said, I don't think there are any issues with the code compensating for its own activity in the "detect activity" mechanism -- assuming there wasn't a major impact in e.g. maintainability or something.

As for the burstyness... considering the "no negative impact" stance, I can understand that. But it seems inefficient, at best...

well, it's a plain old bug (a not too serious one) in my book, i'm surprised that we are now at mail #7 about it :-) I reported it, and i guess Con will fix it eventually. There's really no need to deny that it exists or to try to talk it out of existence. Sheesh! :-)

Ingo

--
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>

#229 lore raw

Re: [ck] Re: [PATCH] mm: swap prefetch improvements

In reply to Con Kolivas
Quoted 17 lines · On Tue, 22 May 2007 20:37:54 +1000 Con Kolivas <[email protected]> wrote:
Quoted 9 lines · Ingo Molnar
Quoted 8 lines · Con Kolivas
Quoted 7 lines
Quoted 4 lines

there was nothing else running on the system - so i suspect the swapin activity flagged 'itself' as some 'other' activity and stopped? The swapins happened in 4 bursts, separated by 5 seconds total idleness.

I've noted burst swapins separated by some seconds of pause in my desktop system too (with sp_tester and an idle gnome).

Quoted 6 lines
Quoted 2 lines

That really is expected, as just about anything, including journal writeout, would be enough to put it back to sleep for 5 more seconds.

note that nothing like that happened on my system - in the swap-prefetch-off case there was _zero_ IO activity during the sleep period.

Quoted 9 lines

Ok, granted it's _very_ conservative. I really don't want to risk its presence being a burden on anything, and the iowait it induces probably makes it turn itself off for another PREFETCH_DELAY (5s). I really don't want to cross the line to where it is detrimental in any way. Not dropping out on a cond_resched and perhaps making the delay tunable should be enough to make it a little less "sleepy".

Signature · 1 line
-ck

Hi. I just did some video encoding on my desktop and I was noticing (for the first time in a while) that running apps had to hit swap quite a lot when I switched to them (the encoding was going at full blast for most of the day, and most of the time other running apps were idle). Now, a good half of my RAM appeared to be free during all this, so I was thinking at the time that it would be nice if swap prefetch could be tunably more aggressive. I guess it would be ideal in this case if it could kick in during tunably low disk-IO periods, even if the CPU is rather busy. I'm sure you've considered this, so I only butt in here to cast a vote for it. :)

Of course, I could be completely wrong about the possibility.. and I seem to remember that the disk cache can take up about half the ram by default without this showing up in 'gnome-system-monitor'... which I guess might happen during heavy encoding.. but even if it did, I could have set the limit lower, and would then have still appreciated prefetching.

Ash

#230 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 10 lines · Ash Milsted

Hi. I just did some video encoding on my desktop and I was noticing (for the first time in a while) that running apps had to hit swap quite a lot when I switched to them (the encoding was going at full blast for most of the day, and most of the time other running apps were idle). Now, a good half of my RAM appeared to be free during all this, so I was thinking at the time that it would be nice if swap prefetch could be tunably more aggressive. I guess it would be ideal in this case if it could kick in during tunably low disk-IO periods, even if the CPU is rather busy. I'm sure you've considered this, so I only butt in here to cast a vote for it. :)

In this case nicing the video encode should be enough to make it prefetch even during heavy cpu usage. It detects the total nice level rather than the cpu usage.

Quoted 6 lines

Of course, I could be completely wrong about the possibility.. and I seem to remember that the disk cache can take up about half the ram by default without this showing up in 'gnome-system-monitor'... which I guess might happen during heavy encoding.. but even if it did, I could have set the limit lower, and would then have still appreciated prefetching.

I plan to make it prefetch more aggressively by default soon and make it more tunable too.

Signature · 1 line
-ck
#231 lore raw

Re: [PATCH] mm: swap prefetch improvements

Quoted 12 lines · On Wed, 23 May 2007 08:50:01 +1000 Con Kolivas <[email protected]> wrote:
Quoted 10 lines · Ash Milsted

Hi. I just did some video encoding on my desktop and I was noticing (for the first time in a while) that running apps had to hit swap quite a lot when I switched to them (the encoding was going at full blast for most of the day, and most of the time other running apps were idle). Now, a good half of my RAM appeared to be free during all this, so I was thinking at the time that it would be nice if swap prefetch could be tunably more aggressive. I guess it would be ideal in this case if it could kick in during tunably low disk-IO periods, even if the CPU is rather busy. I'm sure you've considered this, so I only butt in here to cast a vote for it. :)

Quoted 4 lines

In this case nicing the video encode should be enough to make it prefetch even during heavy cpu usage. It detects the total nice level rather than the cpu usage.

Cunning, but I guess the regular (less than 5 seconds apart) reads/writes during the encoding process would cause prefetching to hold off, no? I had used nice and ionice to reduce the encoder priority, which made desktop apps pretty responsive, except when they had to hit swap. If swap prefetch is using the idle io-priority I suppose it would hardly affect performance if it kicked in during such use, since it would operate in between the encoder reads anyway (assuming the encoder is at higher ioprio), right ?

Quoted 4 lines

I plan to make it prefetch more aggressively by default soon and make it more tunable too.

'Sounds good!