Re: buffers vs. pages vs. kernel speed

Matthias Urlichs (smurf@work.smurf.noris.de)
Wed, 11 Jun 1997 11:19:38 +0200 (Funky)


David S. Miller wrote:
>
> What this patch does is to try all methods of freeing memory in turn,
> instead of trying one until it fails.
>
>Funny, that seems to be the intention of the code, but it was not
>coded that way perfectly ;-)

It was once coded the "right" way, but somebody apparently thought it
should be optimized, because in my version GCC doesn't remove the redundant
assignments to 'state'... not that that is necessary, as I think this
gets lost in the noise -- for the terminally greedy, below is a version
that's guaranteed to yield between 0.00001% and 0.01% better performance. ;-)

>But, firstly I want to get a new revision of my buffer cache and low
>memory fixes for 2.0.x out to people for testing, I will do that when
>I next wake up in the evening EST time.
>
Do both. I suspect that the two may not be entirely unrelated.

Index: mm/vmscan.c
===================================================================
RCS file: /usr/src/cvs/kernel/linux/mm/vmscan.c,v
retrieving revision 1.8
diff -u -r1.8 vmscan.c
--- vmscan.c 1997/05/19 21:23:07 1.8
+++ vmscan.c 1997/06/11 09:15:17
@@ -344,19 +344,23 @@
switch (state) {
do {
case 0:
- if (shrink_mmap(i, dma))
+ if (shrink_mmap(i, dma)) {
+ state = 1;
return 1;
- state = 1;
+ }
case 1:
- if (shm_swap(i, dma))
+ if (shm_swap(i, dma)) {
+ state = 2;
return 1;
- state = 2;
+ }
default:
- if (swap_out(i, dma, wait))
+ if (swap_out(i, dma, wait)) {
+ state = 0;
return 1;
- state = 0;
+ }
i--;
} while ((i - stop) >= 0);
+ state = 0;
}
/* This should never return failure, instead it should sleep
* and try again.

-- 
When pleasure remains, does it remain a pleasure?
-- 
Matthias Urlichs         \  noris network GmbH  /  Xlink-POP Nürnberg 
Schleiermacherstraße 12   \   Linux+Internet   /   EMail: urlichs@noris.de
90491 Nürnberg (Germany)   \    Consulting+Programming+Networking+etc'ing
   PGP: 1024/4F578875   1B 89 E2 1C 43 EA 80 44  15 D2 29 CF C6 C7 E0 DE
       Click <A HREF="http://info.noris.de/~smurf/finger">here</A>.    42