Skip to contentSkip to conversation

Questions on mmap()

DISCUSSION Martin Frey 2 participants 2 messages Jan 23, 2001 Memory management

lore
Share & tools
lore
#0 lore raw

Dear all,

I'm trying to write an example on how to export kmalloc() and vmalloc() allocated areas from a device driver into user space. The example is running so far, but I want to make sure to have all the details right.

So here I have couple of questions:
- for kmalloc, I just call remap_page_range() in my drivers mmap method. Do I have to grab any locks before doing so (kernel 2.4.x), e.g. big kernel lock?
- Do I have to set any flags in vm_area_struct->vm_flags? I see some drivers setting VM_LOCKED while others don't. As far as I understand the kernel will try to swap the area out starting in swp_out_mm, calling swp_out_vma. If VM_LOCKED I will return if VM_LOCKED is set. If not, I will fall into swap_out_pXX until I finally hit the reserve bit of the page that should go out. If I understand the code right, setting VM_LOCKED is not necessary, I will be safe without. But performancewise have VM_LOCKED set will make me fall out of the swap-out attempt earlier. Is this correct?
- To map a vmalloc() allocated area, I set up my own page fault handler (vm_ops). Again, are any flags needed in the vm_flags field?
- In my pagefault handler I parse the pagetables as e.g. done in uvirt_to_kva in the bttv-driver. Do I need to grab a lock before doing so?
- What is the purpose and usage of the VMALLOC_VMADDR macro?

Any help is appreciated.

Thanks and best regards,

Martin Frey

Signature · 9 lines
Supercomputing Systems AG       email: [email protected]
Martin Frey                     web:   http://www.scs.ch/~frey/
at Compaq Computer Corporation  phone: +1 603 884 4266
ZKO2-3N25, 110 Spit Brook Road, Nashua, NH 03062

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/
#1 lore raw
Quoted 8 lines · Martin Frey

Dear all,

I'm trying to write an example on how to export kmalloc() and vmalloc() allocated areas from a device driver into user space. The example is running so far, but I want to make sure to have all the details right.

[...]

How about:
ftp://ftp.de.kernel.org/pub/linux/kernel/people/sct/raw-io/kiobuf.2.3.99.pre9-2.tar.gz?

Christoph

Signature · 5 lines
Whip me.  Beat me.  Make me maintain AIX.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux.eu.org/Linux-MM/