loop device/swap problem?

dinon (dinon@csie.ncu.edu.tw)
Thu, 10 Jun 1999 20:48:57 +0800 (CST)


1) dd if=/dev/zero of=swap bs=1024k count=10
2) losetup /dev/loop0 swap
3) mkswap /dev/loop0
4) swapon /dev/loop0
5) run the following program.

then the machine stops to respond(no swap activities/no disk access)
except that console switch is ok and keyboard input is still echoed.

If I run this program without swap or with one normal swapfile or
swap partition enabled, It's ok.

Almost all kernel version(2.3.[035] and some 2.2.X, x <= 7) I tried
have similar problem when I swaponed one loop device, and tried to
make a new kernel source tarball. It is very likely reproducable.

BTW, if I start another process which will read disk, for example,
All what this process does is:
for (;;)
{
sleep(30);
system("ps axl");
}
then the machine stops to respond(no swap activities/no disk access)
and SOMETIMES, it will continue to respond after the ps is executed.

p.s.
1. I use only one IDE disk
2. The loop device support is loaded as kernel module.

----- PROGRAM BEGIN HERE -----
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>

#define DELAY (200000)
#define SIZE (4*1024*1024)

void child(void)
{
char *p;
for (;;)
{
usleep(DELAY);
p = malloc(SIZE);
if (p == NULL)
{
fprintf(stderr, __FUNCTION__ ": malloc(%d) failed\n", SIZE);
exit(1);
}
memset(p, 0, SIZE);
fprintf(stderr, __FUNCTION__ ": malloc(%d) = %p\n", SIZE, p);
fflush(stderr);
}
}

void parent(void)
{
for (;;)
{
sleep(1);
system("ps axl");
fprintf(stderr, "%s", __FUNCTION__);
fflush(stderr);
}
}

void sigchld(int signo)
{
exit(1);
}

int main()
{
signal(SIGCHLD, sigchld);
switch (fork())
{
case -1: perror("fork"); exit(1);
case 0: child();
default: parent();
}
return 0;
}
----- PROGRAM END -----

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/