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 26aa2d199d6f2 ("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: 96f80f628451 ("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:

committed by
Suren Baghdasaryan

parent
6719763187
commit
1002747429
@@ -3362,7 +3362,6 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping,
|
||||
extern int sysctl_nr_trim_pages;
|
||||
extern bool pte_map_lock_addr(struct vm_fault *vmf, unsigned long addr);
|
||||
extern int reclaim_shmem_address_space(struct address_space *mapping);
|
||||
extern int reclaim_pages_from_list(struct list_head *page_list);
|
||||
|
||||
/**
|
||||
* seal_check_future_write - Check for F_SEAL_FUTURE_WRITE flag and handle it
|
||||
|
@@ -4311,7 +4311,6 @@ int reclaim_shmem_address_space(struct address_space *mapping)
|
||||
pgoff_t start = 0;
|
||||
struct page *page;
|
||||
LIST_HEAD(page_list);
|
||||
int reclaimed;
|
||||
XA_STATE(xas, &mapping->i_pages, start);
|
||||
|
||||
if (!shmem_mapping(mapping))
|
||||
@@ -4329,8 +4328,6 @@ int reclaim_shmem_address_space(struct address_space *mapping)
|
||||
continue;
|
||||
|
||||
list_add(&page->lru, &page_list);
|
||||
inc_node_page_state(page, NR_ISOLATED_ANON +
|
||||
page_is_file_lru(page));
|
||||
|
||||
if (need_resched()) {
|
||||
xas_pause(&xas);
|
||||
@@ -4338,9 +4335,8 @@ int reclaim_shmem_address_space(struct address_space *mapping)
|
||||
}
|
||||
}
|
||||
rcu_read_unlock();
|
||||
reclaimed = reclaim_pages_from_list(&page_list);
|
||||
|
||||
return reclaimed;
|
||||
return reclaim_pages(&page_list);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
30
mm/vmscan.c
30
mm/vmscan.c
@@ -1564,36 +1564,6 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone,
|
||||
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
|
||||
* if it is of the appropriate PageActive status. Pages which are being
|
||||
|
Reference in New Issue
Block a user