Subject: Re: Allocating page frames
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Eduardo E. Horvath <eeh@one-o.com>
List: tech-kern
Date: 03/28/1997 13:21:22
On Fri, 28 Mar 1997, Jason Thorpe wrote:

> On Fri, 28 Mar 1997 10:04:47 -0800 (PST) 
>  "Eduardo E. Horvath" <eeh@one-o.com> wrote:
> 
>  > Are there any facilities for allocating physical page frames witout
>  > mapping them in?  Since I will only be accessing the pages though physical
>  > addresses, I don't want to maintain the info about any virtual mappings
>  > just so I can free them later on.  
> 
> I am currently working on a machine-independent interface for this.  I
> assume you need this for some DMA application, perhaps a framegrabber?

No, actually it's for MMU page table mappings.  I'm trying to prevent
potential TLB misses in the TLB miss handler.  While I could try to make
the trap handlers re-entrant, that can cause other problems like infinite
loopbacks, etc.

> I expect to post another revision of my design document soon, once I
> get some of the details worked out.  (My i386 bus dma implementation
> is about 45% complete, and the allocation of DMA-safe memory is the
> current hurdle).

I just want to be able to borrow a physical page for a while from the vm
system and then give it back later.  I don't need it mapped in.  In fact I
prefer not to have it mapped in because that would involve an awful lot of
useless overhead.  

BTW, about your bus-specific allocators:

Have you considered keeping segregated memory lists for different areas of
memory?  For instance, each bus has a separate active, inactive, and free
list and the pager iterates over all the different lists when it runs. 
That way any memory that is not being used for DMA can be used to run
programs.

It could potentially help solve the memory flush problem when NetBSD goes
to a unified buffer cache.  The buffer cache would have a separate set of
lists from the normal vm.  When pages are needed by the vm system they
are taken from all the free queues, round robin.  When the buffer cache
gets full (say 50% physmem) it starts taking pages only from the buffer
cache free list.  That way when Joe User does a `cp -r' of an entire disk
he won't evict all of the programs sitting in RAM.  If you have memory in
some special bus or address range, it stays in its own memory lists so you
can always pluck a page from the free list or iterate the pager for that
type of memory if needed.

=========================================================================
Eduardo Horvath				eeh@btr.com
"Cliffs are for climbing.  That's why God invented grappling hooks."
					- Benton Frasier