binder: select correct nid for pages in LRU
authorCarlos Llamas <cmllamas@google.com>
Tue, 10 Dec 2024 14:30:59 +0000 (14:30 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Dec 2024 08:35:23 +0000 (09:35 +0100)
The numa node id for binder pages is currently being derived from the
lru entry under struct binder_lru_page. However, this object doesn't
reflect the node id of the struct page items allocated separately.

Instead, select the correct node id from the page itself. This was made
possible since commit 0a97c01cd20b ("list_lru: allow explicit memcg and
NUMA node selection").

Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20241210143114.661252-4-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder_alloc.c

index f26283c2c7680aeca8d25cf5d5bde7c4d2e50abd..1f02bec784511935322d185ef6affc9187bd103d 100644 (file)
@@ -210,7 +210,10 @@ static void binder_lru_freelist_add(struct binder_alloc *alloc,
 
                trace_binder_free_lru_start(alloc, index);
 
-               ret = list_lru_add_obj(&binder_freelist, &page->lru);
+               ret = list_lru_add(&binder_freelist,
+                                  &page->lru,
+                                  page_to_nid(page->page_ptr),
+                                  NULL);
                WARN_ON(!ret);
 
                trace_binder_free_lru_end(alloc, index);
@@ -334,7 +337,10 @@ static void binder_lru_freelist_del(struct binder_alloc *alloc,
                if (page->page_ptr) {
                        trace_binder_alloc_lru_start(alloc, index);
 
-                       on_lru = list_lru_del_obj(&binder_freelist, &page->lru);
+                       on_lru = list_lru_del(&binder_freelist,
+                                             &page->lru,
+                                             page_to_nid(page->page_ptr),
+                                             NULL);
                        WARN_ON(!on_lru);
 
                        trace_binder_alloc_lru_end(alloc, index);
@@ -947,8 +953,10 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc)
                        if (!alloc->pages[i].page_ptr)
                                continue;
 
-                       on_lru = list_lru_del_obj(&binder_freelist,
-                                                 &alloc->pages[i].lru);
+                       on_lru = list_lru_del(&binder_freelist,
+                                             &alloc->pages[i].lru,
+                                             page_to_nid(alloc->pages[i].page_ptr),
+                                             NULL);
                        binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC,
                                     "%s: %d: page %d %s\n",
                                     __func__, alloc->pid, i,