mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
UPSTREAM: binder: initialize lru pages in mmap callback
Rather than repeatedly initializing some of the binder_lru_page members during binder_alloc_new_buf(), perform this initialization just once in binder_alloc_mmap_handler(), after the pages have been created. Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://lore.kernel.org/r/20231201172212.1813387-19-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Bug: 254650075 (cherry picked from commit 68aef12d094e4c96d972790f1620415460a4f3cf) Change-Id: I3197038683f76a5cb98a79d017d1515429df2d73 Signed-off-by: Carlos Llamas <cmllamas@google.com>
This commit is contained in:
@@ -274,9 +274,6 @@ static int binder_allocate_page_range(struct binder_alloc *alloc,
|
|||||||
|
|
||||||
trace_binder_alloc_page_start(alloc, index);
|
trace_binder_alloc_page_start(alloc, index);
|
||||||
|
|
||||||
page->alloc = alloc;
|
|
||||||
INIT_LIST_HEAD(&page->lru);
|
|
||||||
|
|
||||||
ret = binder_install_single_page(alloc, page, page_addr);
|
ret = binder_install_single_page(alloc, page, page_addr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
binder_free_page_range(alloc, start, page_addr);
|
binder_free_page_range(alloc, start, page_addr);
|
||||||
@@ -798,9 +795,9 @@ void binder_alloc_free_buf(struct binder_alloc *alloc,
|
|||||||
int binder_alloc_mmap_handler(struct binder_alloc *alloc,
|
int binder_alloc_mmap_handler(struct binder_alloc *alloc,
|
||||||
struct vm_area_struct *vma)
|
struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
const char *failure_string;
|
|
||||||
struct binder_buffer *buffer;
|
struct binder_buffer *buffer;
|
||||||
|
const char *failure_string;
|
||||||
|
int ret, i;
|
||||||
|
|
||||||
if (unlikely(vma->vm_mm != alloc->mm)) {
|
if (unlikely(vma->vm_mm != alloc->mm)) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@@ -829,6 +826,11 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
|
|||||||
goto err_alloc_pages_failed;
|
goto err_alloc_pages_failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < alloc->buffer_size / PAGE_SIZE; i++) {
|
||||||
|
alloc->pages[i].alloc = alloc;
|
||||||
|
INIT_LIST_HEAD(&alloc->pages[i].lru);
|
||||||
|
}
|
||||||
|
|
||||||
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
|
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
|||||||
Reference in New Issue
Block a user