From owner-freebsd-hackers Thu Apr 29 14:14:15 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from home.dragondata.com (home.dragondata.com [204.137.237.2]) by hub.freebsd.org (Postfix) with ESMTP id B617214DB2 for ; Thu, 29 Apr 1999 14:14:11 -0700 (PDT) (envelope-from toasty@home.dragondata.com) Received: (from toasty@localhost) by home.dragondata.com (8.9.2/8.9.2) id QAA00336 for hackers@freebsd.org; Thu, 29 Apr 1999 16:14:09 -0500 (CDT) From: Kevin Day Message-Id: <199904292114.QAA00336@home.dragondata.com> Subject: mmaping /dev/mem then spawning children To: hackers@freebsd.org Date: Thu, 29 Apr 1999 16:14:09 -0500 (CDT) X-Mailer: ELM [version 2.4ME+ PL43 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I'm completely at a loss as to why this happens, but it just sprang up when we upgraded from 3.0-RELEASE to 3.1-RELEASE. I have a process that mmap's a device. (Our own custom driver). It then spawns some children that don't really need access to it. However, top/ps/etc show that the child is eating 32760 megabytes of ram. This also seems to happen if you mmap /dev/mem, or a few other devices. Am I just doing something stupid here, or is this an honest bug? Here's sample code to reproduce this. Compile them both, then run '1'. 1.c: #include #include #include #include #include #include void main(void) { int k; char *low; int devmem; devmem = open("/dev/mem",O_RDWR); low1mb = (char *)mmap(0, 0x800000, (PROT_READ | PROT_WRITE), MAP_INHERIT | MAP_SHARED, devmem, 0); printf("Starting 2...\n"); if (rfork(RFCFDG|RFPROC)) { usleep(100); } else { k = execl("./2", "2", (char *) 0); if (k) { printf("io returned %d errno %d\n",k, errno); } _exit(0); } } 2.c: void main(void) { while(1) sleep(10000); } I run ./1 top shows: PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND 899 root 10 0 748K 32760M nanslp 0:00 0.00% 0.00% 2 ps shows: root 899 0.0 53622.9 748 -7960 p1 I 6:14AM 0:00.00 2 0 899 1 0 10 0 748 -7960 nanslp I p1 0:00.00 2 -7960k.... which is about 8M (from the mmap) minus how much '2' should really be taking up. Is this a real bug? Kevin To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message