Con Kolivas [interview] posted an updated version of his Swappiness Autoregulation patch [story], this time "done the right way (tm)". Instead of updating swappiness at every tick (which is either 100 or 1000 or 1024 times per second, depending on architecture) the swappiness is updated only when there is pressure to swap. This has the double benefit of avoiding a possible divide-by-zero error, and reduced overhead. It also makes swappiness read-only to user-space.
From: Con Kolivas [email blocked] To: linux-kernel Subject: [PATCH] Autoregulate vm swappiness cleanup Date: 2003-10-25 6:58:22 On Fri, 24 Oct 2003 01:03, Con Kolivas wrote: > On Friday 24 October 2003 00:42, Martin J. Bligh wrote: > > It seems that you don't need si_swapinfo here, do you? i.freeram, > > i.bufferram, and i.totalram all come from meminfo, as far as I can > > see? Maybe I'm missing a bit ... > > Well I did do it a while ago and it seems I got carried away adding and > subtracting info indeed. :-) Here's a simpler patch that does the same > thing. The off-list enthusiasm has been rather strong so here is a patch done the right way (tm). There is no need for the check of totalram being zero (the original version of this patch modified the swappiness every tick which was wasteful and had a divide by zero on init). Adjusting vm_swappiness only when there is pressure to swap means totalram shouldn't be ever be zero. The sysctl is made read only since writing to it would be ignored now. Con [patch can be found here]