swap weirdness

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Mon, 25 Nov 1996 13:40:29 +0100 (MET)


running 2.0.26 (tested 2.1.7/2.0.12/2.0.22 too) on AXP I see the following
weirdness with free swap space; can't see for x86 2.0.22 or 2.0.26:

while doing heavy swaping (e.g. run "eatmem" below as "eatmem 40000 loop"
or similar) the free/used swap memory isn't constant at all for AXP.
shown by

# while true; do sleep 5 ; grep Swap: /proc/meminfo ;done
Swap: 53469184 19890176 33579008
Swap: 53469184 23830528 29638656
Swap: 53469184 27598848 25870336
Swap: 53469184 31555584 21913600
Swap: 53469184 35176448 18292736
Swap: 53469184 38903808 14565376
Swap: 53469184 42557440 10911744

Swap: 53469184 11141120 42328064
Swap: 53469184 14974976 38494208
Swap: 53469184 18898944 34570240
Swap: 53469184 22863872 30605312
Swap: 53469184 26902528 26566656
Swap: 53469184 31260672 22208512
Swap: 53469184 34881536 18587648
Swap: 53469184 38985728 14483456
Swap: 53469184 42983424 10485760

Swap: 53469184 10444800 43024384
Swap: 53469184 12312576 41156608
Swap: 53469184 16252928 37216256

[empty lines inserted by me]. this is for a XL266 (alpha) with 48MB ram
and no other process other than "eatmem" running; X11 not started.

whenever the amount of used swap spaces (2nd number) cycles from
max. to min. value, the disk sounds swapping "much heavier" and for
some seconds the system is even much slower than during "normal" swaping.

any idea ?

Harald
-------------------------------------------------------------------------------
/*
* eatmem.c -- allocate a junk of memory and make it dirty
* Copyright Harald Koenig <koenig@tat.physik.uni-tuebingen.de> 1994
*
* Permission is hereby granted to copy, modify and redistribute this code
* in terms of the GNU Library General Public License, Version 2 or later,
* at your option.
*
* to compile use
* cc -O2 -Wall -o eatmem eatmem.c
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <malloc.h>

void main(int argc, char *argv[])
{
int i;
char *b=NULL,*pb;
int n=(-1);
int err=0, exit_flag=0, loop_flag=0;

if (argc >= 2) {
n = atoi(argv[1]);
if (argc == 3) {
if (!strcmp(argv[2],"pause")) exit_flag = 0;
else if (!strcmp(argv[2],"exit" )) exit_flag = 1;
else if (!strcmp(argv[2],"loop" )) loop_flag = 1;
else err=1;
}
else if (argc > 3) err=1;
}
if (n<=0 || err) {
fprintf(stderr,"usage: eatmem size_in_kb [ pause | exit | loop ]\n");
exit(1);
}

b = malloc(n*1024);
if (b == NULL) {
fprintf(stderr,"malloc failed.\n");
exit(1);
}

do {
pb = b;
for (i=0; i<n; i++) {
(*pb)++;
pb += 1024;
}
} while (loop_flag);

write(1,"\007",1);
if (!exit_flag)
kill(0,SIGSTOP);
exit(0);
}

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^