VMA management in device driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



VMA management in device driver

Need some help on Virtual Memory developing a Linux Device driver for use on a
small device.


We are making a chip that is working on the same global memory as the CPU. To start
the the chip our driver (library) makes some variable size lists, the
device driver will update the MMU on our chip, and write to its start register.


The problem is how to allocate and deallocate memory. We use a number of lists that can vary
quite much in size. Our internal user space malloc function uses mmap, and the device driver
keeps track of the allocated VMA's. Our user space driver mmaps a huge memory area, knowing
that the nopage function will provide only the necessary pages. When our chip is done
and we get the interrupt we will erase some of the pages but not all of them.


The normal way to do this is to use mremap, but this approach can be problematic:
-If we mmap a huge memory area, mremaps it to a small area, and then mremaps it to
a huge area again, we risk that some other thread/function maps an other VMA just
after our small VMA, so that it cannot expand to its big size again.


What I want is to be able to make an IOCTL function in the device driver that are
capable of removing a page (range) from the mmaped VMA, without changing the size of
the VMA itself. If the process needs the page again, the nopage function will bring
a clean one back in place.


Since we work on a small multimedia device, speed and memory usage is an issue.

My question is then: how can I remove a page (range) from a known VMA within a module?


What I have tried:
Looking in Linux/memory.c I found the function
void zap_page_range(struct mm_struct *mm, unsigned long address, unsigned long size)
that does pretty much what I want (I think). The problem is that I get an
"Unresolved Symbol" if I try to use it. The function can be found here:
"cat /boot/System.map |grep zap_page_range"
but not here:
"cat /proc/ksyms |grep zap_page_range"
Looks like the function that I want to use is not exported for use by modules.
Any known workarounds?



Thanks in advance,

Mikael Valen-Sendstad
Norway


-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux