3
votes

I am developing a real-time application for Linux 3.5.7. The application needs to manage a PCI-E device.

In order to access the PCI-E card spaces, I have been using mmap in combination with /dev/mem. However (please correct me if I am wrong) each time I read or write the mapped memory, a system call is required for the /dev/mem pseudo-driver to handle the memory access.

To avoid the overhead of this system call, I think it should be possible to write a kernel module so that, within e.g. a ioctl call I can modify the process page table, in order to map the physical device pages to userspace pages and avoid the system call.

Can you give me some orientation on this?

Thanks and regards

1
Once the necessary mapping to access a page is actually programmed into the MMU, I don't believe that further kernel intervention would be needed to simply access that memory (excepting whatever reprogramming is needed for context switches), unless the physical implementation is one that requires the access to be trapped and proxied through some more indirect mechanism. - Chris Stratton

1 Answers

7
votes

However (please correct me if I am wrong) each time I read or write the mapped memory, a system call is required

You are wrong.

it should be possible to write a kernel module so that, within e.g. a ioctl call I can modify the process page table

This is precisely what mmap() does.