From owner-freebsd-current Wed Sep 2 19:08:34 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA22383 for freebsd-current-outgoing; Wed, 2 Sep 1998 19:08:34 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA22378 for ; Wed, 2 Sep 1998 19:08:32 -0700 (PDT) (envelope-from tlambert@usr07.primenet.com) Received: (from daemon@localhost) by smtp02.primenet.com (8.8.8/8.8.8) id TAA11554; Wed, 2 Sep 1998 19:07:30 -0700 (MST) Received: from usr07.primenet.com(206.165.6.207) via SMTP by smtp02.primenet.com, id smtpd011528; Wed Sep 2 19:07:25 1998 Received: (from tlambert@localhost) by usr07.primenet.com (8.8.5/8.8.5) id TAA05776; Wed, 2 Sep 1998 19:07:19 -0700 (MST) From: Terry Lambert Message-Id: <199809030207.TAA05776@usr07.primenet.com> Subject: Re: VM question To: abial@nask.pl (Andrzej Bialecki) Date: Thu, 3 Sep 1998 02:07:19 +0000 (GMT) Cc: freebsd-current@FreeBSD.ORG In-Reply-To: from "Andrzej Bialecki" at Sep 2, 98 10:32:41 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG [ ... RAM and "fast swap" (RAM) ... ] > ...and here's what I'd like to achieve: > > * to free pages aggressively, so that only a very few pages (a fraction of > .text and .data, the stack and bss) are paged in, and then as soon as > possible freed - it's relatively cheap to do pagein when the media that > holds binaries is very fast, It makes no sense to do this. These pages aren't bothering anyone, and will go away when it is necessary for them to do so. > (As a side note: probably what I'd like to use is execution in place, > especially in case of MFS, but I remember someone telling me it's very > difficult to do...) Yes. It's rather hard. In the current implementation, the page in the MFS that is in the file is actually *not* the page paged from the MFS. In other words, the pages are doubled. This is only bad for clean pages; for dirty pages, it's absolutely necessary to not corrupt the binaries in the MFS. This could be handled by defining an MFS to be an FS on a VM "device", and then modifying (significantly) the MFS getpage/putpages routines to return direct mappings. I estimate that you will save, on average, on text page by doing this. > * to limit killing of random user processes - instead the VM should try > first to free as much pages as possible (and it should try better than it > is doing now :-) There are two problems glossed together here: 1) What if you really *are* out of memory? and 2) What if memory is fragmented? The second should only be a problem in the case where you need to allocate contiguous pages (for example, loading an LKM driver for a device that uses a contiguous physical memory segment to DMA into, like the QCAM driver). To solve the second, you would need to move around pages by discarding clean pages and copying dirty pages and modifying page table entries to point to the dirty page copies, in order to free up the originals. This has been discussed on this list before, as an alternative to grabbing large chunks of contiguous memory for devices at driver attach time. To solve the first, you will have to invent a mechanism, whereby an application can be asked to free up "dirty" pages, which contain cached data that can be regenerated or otherwise recovered without keeping them, and to free allocated memory, defrag it, and sbrk the freed memory back to the system. These are both asking a lot. 8-(. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message