Re: mlockall and mmap of IO devices don't mix

Joe Korty
2003-10-03T23:58:36Z

On Fri, Oct 03, 2003 at 04:15:40PM -0700, Andrew Morton wrote:
>> Sigh. No go; it *looks* good but my app still locks up....
>
> Or we could use that VM_RESERVED thing?

Hi Andrew,
Your third patch worked perfectly for all the tested cases:
o /dev/mem at offset fd000000 (my video card mem addr)
o /dev/mem at offset 0
o with an mmapable device driver.

I did have to make two changes to get it to compile:

--- mm/memory.c.am3 2003-10-03 19:44:17.000000000 -0400
+++ mm/memory.c 2003-10-03 19:43:47.000000000 -0400
@@ -738,7 +738,7 @@
#endif

special = vma->vm_flags & (VM_IO | VM_RESERVED);
- if (!vma || (pages && vm_io) || !(flags & vma->vm_flags))
+ if (!vma || (pages && special) || !(flags & vma->vm_flags))
return i ? : -EFAULT;

if (is_vm_hugetlb_page(vma)) {
@@ -755,7 +755,7 @@
* mappings of /dev/mem - they may have no pageframes.
* And the caller passed NULL for `pages' anyway.
*/
- while (!special && !(map=follow_page(mm,start,write)) {
+ while (!special && !(map=follow_page(mm,start,write))) {
spin_unlock(&mm->page_table_lock);
switch (handle_mm_fault(mm,vma,start,write)) {
case VM_FAULT_MINOR:

In the first change, 'special' != '(vma->vma_flags & VM_IO)' which
was what was originally being tested. Could that cause a problem?

Also, could the use of VM_RESERVED cause in some cases memory with
pageframes to skip adjustment/use of those pageframes?

Regards, and thanks,
Joe