]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/android/binder_alloc.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
[linux.git] / drivers / android / binder_alloc.c
index 6f6f745605afc44861c22c29b55f8a74f42f3dd6..5a426c877dfb21696dad149c86a447e216909542 100644 (file)
@@ -281,6 +281,9 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
                        goto err_vm_insert_page_failed;
                }
 
+               if (index + 1 > alloc->pages_high)
+                       alloc->pages_high = index + 1;
+
                trace_binder_alloc_page_end(alloc, index);
                /* vm_insert_page does not seem to increment the refcount */
        }
@@ -324,11 +327,12 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
        return vma ? -ENOMEM : -ESRCH;
 }
 
-struct binder_buffer *binder_alloc_new_buf_locked(struct binder_alloc *alloc,
-                                                 size_t data_size,
-                                                 size_t offsets_size,
-                                                 size_t extra_buffers_size,
-                                                 int is_async)
+static struct binder_buffer *binder_alloc_new_buf_locked(
+                               struct binder_alloc *alloc,
+                               size_t data_size,
+                               size_t offsets_size,
+                               size_t extra_buffers_size,
+                               int is_async)
 {
        struct rb_node *n = alloc->free_buffers.rb_node;
        struct binder_buffer *buffer;
@@ -666,7 +670,7 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
                goto err_already_mapped;
        }
 
-       area = get_vm_area(vma->vm_end - vma->vm_start, VM_IOREMAP);
+       area = get_vm_area(vma->vm_end - vma->vm_start, VM_ALLOC);
        if (area == NULL) {
                ret = -ENOMEM;
                failure_string = "get_vm_area";
@@ -853,6 +857,7 @@ void binder_alloc_print_pages(struct seq_file *m,
        }
        mutex_unlock(&alloc->mutex);
        seq_printf(m, "  pages: %d:%d:%d\n", active, lru, free);
+       seq_printf(m, "  pages high watermark: %zu\n", alloc->pages_high);
 }
 
 /**
@@ -1002,8 +1007,14 @@ void binder_alloc_init(struct binder_alloc *alloc)
        INIT_LIST_HEAD(&alloc->buffers);
 }
 
-void binder_alloc_shrinker_init(void)
+int binder_alloc_shrinker_init(void)
 {
-       list_lru_init(&binder_alloc_lru);
-       register_shrinker(&binder_shrinker);
+       int ret = list_lru_init(&binder_alloc_lru);
+
+       if (ret == 0) {
+               ret = register_shrinker(&binder_shrinker);
+               if (ret)
+                       list_lru_destroy(&binder_alloc_lru);
+       }
+       return ret;
 }