2.4.10 swap behaviour
Subsystems (5)
Cheers,
Yesterday, after upgrading to 2.4.10 and deciding it was significantly better about memory usage under light load than 2.4.9, I ran a pathological test case with rather interesting results..
My machine is a 900MHz P3 laptop with 512MB of memory (just upgraded from 256M - most of my experience with earlier 2.4 kernels up to 2.4.9 is with 256M, which adds some variability into the subjective experience..). I ran these tests with a vanilla 2.4.9 kernel and 2.4.10 patched with Robert Love's 2.4.10-preempt patches.
Under both kernels, I ran a simulated medium-load session (Ximian Gnome, Evolution, a Java server, XEmacs and a 128MB VMware session open but not particularly active, no net connection), and then started a cat /dev/dvd
Quoted 1 line
/dev/nullprocess, watching the memory usage pattern with vmstat and
free. Before the cat, I had about 190 megs of memory used (disregarding buffers/cache) - the VMware session had not allocated all of it's 128MB limit, remaining around 80 megs at the point.
2.4.9 would gradually increase its buffer and cache memory until were around 150-200 megs. At this point, a lot of the applications had been swapped out, with 60 megs of swap in use, and the system was very sluggish. I aborted the cat with a ctrl-c and the system regained responsiveness fairly quickly (paging heavily until most code was back in).
2.4.10 remained more responsive in the beginning, and I noticed that the buffer allocation would actually drop from the initial 15 megs to under
5. However, the cache usage kept on going up, until about 440 megs of RAM was used by the cache (and less than a meg in buffers!). At this point, about 90 megs of swap had been allocated, and the machine quite quickly lost all response. The mouse pointer would not move, the active terminal window showed no response to keyboard, I could not switch to another VC. Except for the constant disk access, the machine might as well been completely hung, and for a moment I thought it was. Eventually I was forced to eject the entire DVD drive from the machine (good thing I was testing on a laptop! :)), at which point the cat process obviously would be aborted. After that, it took about 20-30 seconds until the terminal started to respond (slowly), and a couple of minutes before the all the applications were again usable (after heavy paging again, obviously).
Conclusion: 2.4.10 buffer behaviour is dramatically different, and the system remains responsive somewhat longer under medium load - some of that might be attributed to the preempt patches, however. Under heavy sequential IO load, the cache still has a pathological behaviour of forcing everything else out of memory, which can make the system act as if completely dead, unless the IO process can be aborted. The improved behaviour under moderate load makes the transition from "paging but decent" to "completely unusable" somewhat delayed but more sudden when it does happen.
let me know if you want me to test something different..
Signature · 1 line
Osma Ahvenlampi <[email protected]>
Re: 2.4.10 swap behaviour (with vm-tweaks-2)
Quoted 1 line · Osma Ahvenlampi
quickly lost all response. The mouse pointer would not move, the active
You really want to apply vm-tweaks-1, (or better vm-tweaks-2 inlined here with the bugfix for Cary's div by zero, woops) and try again. It applies cleanly to vanilla 2.4.10.
Linus I'd suggest for inclusion, I know you hate it but think at least at the huge benefit in light vm-pressure load when just heavy non-mapped cache pollution is going on, even if you disagree about the pageout-trigger condition (but swapout behaviour is much better too this way, and I disagree in constantly wasting cpu to know when to swap anyways).
(btw, after this patch we can also drop the "survive" cruft into the page fault handler, not included here since not very important cleanup)
include/linux/fs.h +1 -1
@@ -282,7 +282,7 @@extern void set_bh_page (struct buffer_head *bh,struct page *page,unsigned long offset); -#define touch_buffer (bh) SetPageReferenced(bh->b_page) +#define touch_buffer (bh) mark_page_accessed(bh->b_page)#include <linux/pipe_fs_i.h>
mm/filemap.c +1 -1
@@ -1704,7 +1704,7 @@* and possibly copy it over to another page.. */ old_page = page; -mark_page_accessed (page); +activate_page (page);if (no_share) {struct page *new_page =alloc_page (GFP_HIGHUSER );
mm/swap.c +2 -0
@@ -54,6 +54,7 @@del_page_from_active_list (page);add_page_to_inactive_list (page); } +SetPageReferenced (page); }void deactivate_page (struct page * page)
@@ -72,6 +73,7 @@del_page_from_inactive_list (page);add_page_to_active_list (page); } +ClearPageReferenced (page); }void activate_page (struct page * page)
mm/vmscan.c +36 -17
104 lines not on this page · raw message
Andrea
Re: 2.4.10 swap behaviour (with vm-tweaks-2)
Thanks Andrea,
after applying the patch, I repeated the experiment. Since the cat /dev/dvd >/dev/null no longer really made any difference, I started at the same time a dd if=/dev/hda2 of=/dev/null (a 6 GB partition) and eight find / processes at slightly difference points in time (to excercise the same disk blocks repeatedly). I let the whole thing run for about 5 times longer than the original test, and while the system still pushed a lot of programs onto swap (from an initial used memory of 190 megs, up to 80 was pushed onto swap while I kept "using" most of the programs by clicking on buttons etc), the system remained fairly responsive (a couple of individual apps became sluggish enough to categorize as unresponsive, but a couple of other programs kept responding almost as well as in a no-load condition). To top it off, I tried to play some .ogg files with XMMS - there were breakups in the output every 10-15 seconds, but other than that, XMMS worked fine as well. I don't run XMMS with realtime priority, so that might have fixed even the sound output problems.
I'd have to say I now (finally!) have a kernel which doesn't eat up all my memory.. :) For the record, the setup now is 2.4.10 + rml-preempt-kernel-1 + aa-vm-tweaks-2.
Cheers,
Osma
Quoted 3 lines · Andrea Arcangeli
You really want to apply vm-tweaks-1, (or better vm-tweaks-2 inlined here with the bugfix for Cary's div by zero, woops) and try again. It applies cleanly to vanilla 2.4.10.
Signature · 1 line
Osma Ahvenlampi <[email protected]>