ANDROID: mm: shmem: use reclaim_pages() to recalim pages from a list

Static code analysis tool reported NULL pointer access in
shrink_page_list() as the commit 26aa2d199d ("mm/migrate: demote
pages during reclaim") expects valid pgdat.

There is already an existing api, reclaim_pages, that tries to reclaim
pages from the list. use it instead of creating custom function.

Bug: 201263305
Fixes: 96f80f6284 ("ANDROID: mm: add reclaim_shmem_address_space() for faster reclaims")
Change-Id: Iaa11feac94c9e8338324ace0276c49d6a0adeb0c
Signed-off-by: Charan Teja Reddy <quic_charante@quicinc.com>
This commit is contained in:
Charan Teja Reddy
2022-04-07 15:17:24 +05:30
committed by Suren Baghdasaryan
parent df9528ab15
commit eabd925e61
3 changed files with 1 additions and 36 deletions

View File

@@ -3296,7 +3296,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
extern int sysctl_nr_trim_pages; extern int sysctl_nr_trim_pages;
extern int reclaim_shmem_address_space(struct address_space *mapping); extern int reclaim_shmem_address_space(struct address_space *mapping);
extern int reclaim_pages_from_list(struct list_head *page_list);
#ifdef CONFIG_PRINTK #ifdef CONFIG_PRINTK
void mem_dump_obj(void *object); void mem_dump_obj(void *object);

View File

@@ -4215,7 +4215,6 @@ int reclaim_shmem_address_space(struct address_space *mapping)
pgoff_t start = 0; pgoff_t start = 0;
struct page *page; struct page *page;
LIST_HEAD(page_list); LIST_HEAD(page_list);
int reclaimed;
XA_STATE(xas, &mapping->i_pages, start); XA_STATE(xas, &mapping->i_pages, start);
if (!shmem_mapping(mapping)) if (!shmem_mapping(mapping))
@@ -4233,8 +4232,6 @@ int reclaim_shmem_address_space(struct address_space *mapping)
continue; continue;
list_add(&page->lru, &page_list); list_add(&page->lru, &page_list);
inc_node_page_state(page, NR_ISOLATED_ANON +
page_is_file_lru(page));
if (need_resched()) { if (need_resched()) {
xas_pause(&xas); xas_pause(&xas);
@@ -4242,9 +4239,8 @@ int reclaim_shmem_address_space(struct address_space *mapping)
} }
} }
rcu_read_unlock(); rcu_read_unlock();
reclaimed = reclaim_pages_from_list(&page_list);
return reclaimed; return reclaim_pages(&page_list);
#else #else
return 0; return 0;
#endif #endif

View File

@@ -1868,36 +1868,6 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone,
return nr_reclaimed; return nr_reclaimed;
} }
int reclaim_pages_from_list(struct list_head *page_list)
{
struct scan_control sc = {
.gfp_mask = GFP_KERNEL,
.priority = DEF_PRIORITY,
.may_writepage = 1,
.may_unmap = 1,
.may_swap = 1,
};
unsigned long nr_reclaimed;
struct reclaim_stat dummy_stat;
struct page *page;
list_for_each_entry(page, page_list, lru)
ClearPageActive(page);
nr_reclaimed = shrink_page_list(page_list, NULL, &sc,
&dummy_stat, false);
while (!list_empty(page_list)) {
page = lru_to_page(page_list);
list_del(&page->lru);
dec_node_page_state(page, NR_ISOLATED_ANON +
page_is_file_lru(page));
putback_lru_page(page);
}
return nr_reclaimed;
}
/* /*
* Attempt to remove the specified page from its LRU. Only take this page * Attempt to remove the specified page from its LRU. Only take this page
* if it is of the appropriate PageActive status. Pages which are being * if it is of the appropriate PageActive status. Pages which are being