Subject: Re: kernel mem
To: Jason R Thorpe <thorpej@wasabisystems.com>
From: David Ferlier <david@netbsd-fr.org>
List: tech-kern
Date: 01/10/2003 00:19:34
On Thu, Jan 09, 2003 at 02:37:50PM -0800, Jason R Thorpe wrote:
> On Thu, Jan 09, 2003 at 11:34:32PM +0100, David Ferlier wrote:
> 
>  > But let me ask another question. Does uvm_km_alloc alloc contiguous
>  > pages ? (it's not said in the man page, and i am unsure of the meaning
>  > of wired)
> 
> No, it does not.  You should not need to allocate physically contiguous
> pages, in general.  You usually only need to do this for specific devices
> that have stupid DMA controllers, and in that case, you use the bus_dma(9)
> memory allocation primitives to do that.

I just need to copy 4ko from the disk (it's a block bitmap) in ram.

I'll show you what i did. don't pay attention to size, it costs
~ 12 ko (3 x86 pages)

struct vm_map vm_bbmap;
vaddr_t addr;
struct vm_map_entry *lmap;
int oc, len2;
long *ptr;
int written = 0;
void *data;

addr = uvm_km_zalloc (vm_bbmap, size);

now that i allocated, i copy previously readen data from disk stored in
bp->b_data in each space pointed by the member start of each vm_map_entry.

data = bp->b_data;

for (*lmap = vm_bbmap->header, oc = 0; written != SBSIZE && oc <
		vm_bbmap->nentries; oc += 1) {
	ptr = (long *) lmap->start; /* get adress of segment */
	len2 = lmap->end - lmap->start;
	memcpy ((void *)ptr, data, len);
	written += len;
	data += len;
	lmap = lmap->next;
}

What i want to know is : could i throw out all this stuff, and just do a :

memcpy (addr, bp->b_data, size);

Since pages allocated by uvm_km_alloc are not contiguous, what i think
is that it won't work (other memory will be written)

So what's the preferred way for what i want ?

Thanks in advance,

David

> 
> -- 
>         -- Jason R. Thorpe <thorpej@wasabisystems.com>
> 

-- 

David Ferlier	- david@netbsd-fr.org     || 
		  dferlier@BonBon.net

www.NetBSD.org	- Of Course It Runs NetBSD