Re: Translating VM address to physical addresses in a non-root app

From: Ensco (ensconews.deller_at_smsail.com)
Date: 11/19/03


Date: Wed, 19 Nov 2003 15:56:59 -0500

Kasper,
Thanks for your reply.

> I think the "normal" aproach for such a driver is to let the
> driver do the allocation of memory. The driver then implements
> a char device which the user space app can mmap into it's own
> address space. If multiple apps mmap simultaneously the memory
> will be shared, as that is how you are going to write the
> driver.

If I'm not mistaken, this approach requires the driver to allocate kernel
memory using kmalloc. It was not clear to me that kernel pages can be
mapped into user pages (don't see why not, just haven't seen any such
example).

Also, that solution has limits that are problematic. The allocation size is
run-to-run dependent, and I wouldn't want to "reserve" enough kmem for the
worst case when I might not be running a worst case, not to mention the
question of how to tell the driver how much memory to allocate for a given
run.

Also, I believe mmap is normally used for mapping "device addresses". The
smart device only as about 20 "control words". Those controls then cause
the device to become a bus master and start data transfers. Those transfers
have to go into "real" memory as the device does not have any significant
buffering.

We already mmap the control word addresses to make I/O control fast, but
there is no "buffer memory" to be mapped.

Regards,
Steve



Relevant Pages

  • Re: malloc problems with MySQL?
    ... Most likely, your problems will go away if you reduce the heap size, so that mmap has more address space to work with. ... By keeping a cache of unmapped chunks, we can avoid the extra system calls most of the time, and we are also able to reduce memory fragmentation in many cases. ... allocation greater than chunk_size. ... Whereas given that you allocate chunk_size from brk now, ...
    (freebsd-current)
  • Re: Problem mapping small PCI memory space.
    ... If I try to expose it through mmap, ... > access that 512 bytes memory by using ioremapon the physical address ... > Are there any lower limits on the size of a PCI memory region? ... You impliment mmapin your driver. ...
    (Linux-Kernel)
  • Re: Reserved Memory Access Question CE 6.0 vs. 5.0
    ... If you want to do the allocation in the driver, ... but you should be able to allocate memory in the ... loaded into the kernel memory space. ...
    (microsoft.public.windowsce.platbuilder)
  • How to use "offset" parameter in mmap() system call
    ... I wrote a device driver, it supports mmap(), but I met some ... How to use the offset parameter of mmapcorrectly? ... My driver is a char device driver, when it is loaded, it allocates ... 64 MB contiguous physical memory using contigmalloc, ...
    (freebsd-hackers)
  • Re: numpy.memmap advice?
    ... In other words, given a huge file, a memmap object ... amount of memory is allocated for the memmap operation, ... memory allocation occurs when I generate my final numpy sub-array by ... in the mmap. ...
    (comp.lang.python)