From owner-freebsd-current Thu Feb 4 20:18:24 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id UAA21698 for freebsd-current-outgoing; Thu, 4 Feb 1999 20:18:24 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from janus.syracuse.net (janus.syracuse.net [205.232.47.15]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id UAA21691 for ; Thu, 4 Feb 1999 20:18:23 -0800 (PST) (envelope-from green@unixhelp.org) Received: from localhost (green@localhost) by janus.syracuse.net (8.8.8/8.8.7) with ESMTP id XAA08106 for ; Thu, 4 Feb 1999 23:18:25 -0500 (EST) Date: Thu, 4 Feb 1999 23:18:24 -0500 (EST) From: Brian Feldman X-Sender: green@janus.syracuse.net To: current@FreeBSD.ORG Subject: swapper BIG problems Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Okay, here's the situation: I've got an old program from when I was first learning C lying around, and I converted it to be a very rudimentary memory tester. #include #include #include #define SIZE 1024*1024 void main(void) { int count, yep = 0; void *stfu[SIZE]; void *mem; for (count = 0; count < SIZE; count++) { if ((mem = stfu[count] = malloc(1024))) { int where; printf("%p (%i) malloc'd\n", stfu[count], count); for (where = 0; where < (1024 / sizeof(unsigned)); where++) ((unsigned *)mem)[where] = 0xdeadbeef; yep++; } else break; } for (count = 0; count < yep; count++) { int where; mem = stfu[count]; for (where = 0; where < (1024 / sizeof(unsigned)); where++) if (((unsigned *)mem)[where] != 0xdeadbeef) { fprintf(stderr, "memory check failed at %i of %i\n", count, yep); exit(2); } free(stfu[count]); printf("%i free'd\n", count); } if (yep != SIZE) { printf("mallocs failed at %i\n", yep); exit (1); } else exit (0); } It succeeds as per allocating the memory until the swap is full. But, when it starts the reading/freeing, the swapins cause hundreds of swap_pager_getswapspace: failed This will put the system in a deadlock if, for instance, this program is run in an xterm and an X server is running locally, and it's too swapped out to be used, but the memory program displays things to the term (catch-22). What I see this as is (but I'm just guessing, I'm not a real kernel hacker yet): The mallocations fail where the swap runs out. Fine, whatever. The printf's in the free routines call malloc() after free()ing the kilobyte, but malloc does not have the memory for it (or does but complains) and so complains a LOT. The printfs work so it _SEEMS_ to be that the only thing bringing the system to a halt is the printfs is the kernel itself, most likely the printf's. Does this seem correct? If it's actually the kernel printf that's hanging the system, what's the solution? What if it's not? Brian Feldman _ __ ___ ___ ___ green@unixhelp.org _ __ ___ | _ ) __| \ http://www.freebsd.org/ _ __ ___ ____ | _ \__ \ |) | FreeBSD: The Power to Serve! _ __ ___ ____ _____ |___/___/___/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message