OSDN Git Service

ashmem: Don't install fault handler for private mmaps.
authorArve Hjønnevåg <arve@android.com>
Tue, 28 Apr 2009 01:20:59 +0000 (18:20 -0700)
committerArve Hjønnevåg <arve@android.com>
Tue, 28 Apr 2009 22:25:16 +0000 (15:25 -0700)
Ashmem is used to create named private heaps. If this heap is backed
by a tmpfs file it will allocate two pages for every page touched.
In 2.6.27, the extra page would later be freed, but 2.6.29 does not
scan anonymous pages when running without swap so the memory is not
freed while the file is referenced. This change changes the behavior
of private ashmem mmaps to match /dev/zero instead tmpfs.

Signed-off-by: Arve Hjønnevåg <arve@android.com>
mm/ashmem.c

index 96062cf..83ecd00 100644 (file)
@@ -242,7 +242,13 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
        }
        get_file(asma->file);
 
-       shmem_set_file(vma, asma->file);
+       if (vma->vm_flags & VM_SHARED)
+               shmem_set_file(vma, asma->file);
+       else {
+               if (vma->vm_file)
+                       fput(vma->vm_file);
+               vma->vm_file = asma->file;
+       }
        vma->vm_flags |= VM_CAN_NONLINEAR;
 
 out: