From owner-cvs-bin Sat Dec 30 09:12:56 1995 Return-Path: owner-cvs-bin Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id JAA25493 for cvs-bin-outgoing; Sat, 30 Dec 1995 09:12:56 -0800 (PST) Received: from Root.COM (implode.Root.COM [198.145.90.17]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id JAA25485 Sat, 30 Dec 1995 09:12:51 -0800 (PST) Received: from corbin.Root.COM (corbin [198.145.90.50]) by Root.COM (8.6.12/8.6.5) with ESMTP id JAA15663; Sat, 30 Dec 1995 09:12:43 -0800 Received: from localhost (localhost [127.0.0.1]) by corbin.Root.COM (8.7.3/8.6.5) with SMTP id JAA03238; Sat, 30 Dec 1995 09:12:49 -0800 (PST) Message-Id: <199512301712.JAA03238@corbin.Root.COM> To: Ollivier Robert cc: peter@jhome.dialix.com (Peter Wemm), joerg@freefall.freebsd.org, cvs-bin@freefall.freebsd.org, CVS-committers@freefall.freebsd.org Subject: Re: cvs commit: src/bin/ps ps.1 In-reply-to: Your message of "Sat, 30 Dec 95 15:50:42 +0100." <199512301450.PAA16695@keltia.freenix.fr> From: David Greenman Reply-To: davidg@Root.COM Date: Sat, 30 Dec 1995 09:12:48 -0800 Sender: owner-cvs-bin@FreeBSD.ORG Precedence: bulk >It seems that Peter Wemm said: >> Hmm. this was a suprise to me... I thought procfs was optional, but it >> doesn't look like, since libkvm reads the /proc//mem files. > >On the same subject, is it expected to all the "files" in /proc/ to be >of size 0 ? > >total 0 >--w------- 1 root staff 0 Dec 30 15:50 ctl >---------- 1 root staff 0 Dec 30 15:50 fpregs >----r----- 1 root kmem 0 Dec 30 15:50 mem >--w------- 1 root staff 0 Dec 30 15:50 note >--w------- 1 root staff 0 Dec 30 15:50 notepg >---------- 1 root staff 0 Dec 30 15:50 regs >-r--r--r-- 1 root staff 0 Dec 30 15:50 status > >I'd expect mem to be the size of the binary in the VM system... Yes, it's expected to be zero. "mem" is the process's virtual memory and thus it is sparse. It would have to be nearly 4GB before the number would be accurate. Our kernel allows seeking/reading the file even though it's beyond the EOF. If we change the size to be non-zero, then ordinary things like grep will read the contents...this can be BAD, especially when they are part of a "find / | xargs grep foo". :-) It also prevents people from mmaping the file contents, and this is desired for various reasons (which is the reason that the rest of the files are 0 length). The main reason mmap of procfs files is undesired is that they aren't real files and the data changes dynamically. You don't want to cache that and you don't want to get a fault for _every_ access. There's no way to win, so we don't allow it. -DG