mm: Turn deactivate_file_page() into deactivate_file_folio()
This function has one caller which already has a reference to the page, so we don't need to use get_page_unless_zero(). Also move the prototype to mm/internal.h. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
This commit is contained in:
parent
b4545f4653
commit
261b6840ed
@ -372,7 +372,6 @@ extern void lru_add_drain(void);
|
|||||||
extern void lru_add_drain_cpu(int cpu);
|
extern void lru_add_drain_cpu(int cpu);
|
||||||
extern void lru_add_drain_cpu_zone(struct zone *zone);
|
extern void lru_add_drain_cpu_zone(struct zone *zone);
|
||||||
extern void lru_add_drain_all(void);
|
extern void lru_add_drain_all(void);
|
||||||
extern void deactivate_file_page(struct page *page);
|
|
||||||
extern void deactivate_page(struct page *page);
|
extern void deactivate_page(struct page *page);
|
||||||
extern void mark_page_lazyfree(struct page *page);
|
extern void mark_page_lazyfree(struct page *page);
|
||||||
extern void swap_setup(void);
|
extern void swap_setup(void);
|
||||||
|
@ -66,6 +66,7 @@ static inline void wake_throttle_isolated(pg_data_t *pgdat)
|
|||||||
vm_fault_t do_swap_page(struct vm_fault *vmf);
|
vm_fault_t do_swap_page(struct vm_fault *vmf);
|
||||||
void folio_rotate_reclaimable(struct folio *folio);
|
void folio_rotate_reclaimable(struct folio *folio);
|
||||||
bool __folio_end_writeback(struct folio *folio);
|
bool __folio_end_writeback(struct folio *folio);
|
||||||
|
void deactivate_file_folio(struct folio *folio);
|
||||||
|
|
||||||
void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
|
void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
|
||||||
unsigned long floor, unsigned long ceiling);
|
unsigned long floor, unsigned long ceiling);
|
||||||
|
35
mm/swap.c
35
mm/swap.c
@ -630,32 +630,33 @@ void lru_add_drain_cpu(int cpu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* deactivate_file_page - forcefully deactivate a file page
|
* deactivate_file_folio() - Forcefully deactivate a file folio.
|
||||||
* @page: page to deactivate
|
* @folio: Folio to deactivate.
|
||||||
*
|
*
|
||||||
* This function hints the VM that @page is a good reclaim candidate,
|
* This function hints to the VM that @folio is a good reclaim candidate,
|
||||||
* for example if its invalidation fails due to the page being dirty
|
* for example if its invalidation fails due to the folio being dirty
|
||||||
* or under writeback.
|
* or under writeback.
|
||||||
|
*
|
||||||
|
* Context: Caller holds a reference on the page.
|
||||||
*/
|
*/
|
||||||
void deactivate_file_page(struct page *page)
|
void deactivate_file_folio(struct folio *folio)
|
||||||
{
|
{
|
||||||
|
struct pagevec *pvec;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In a workload with many unevictable page such as mprotect,
|
* In a workload with many unevictable pages such as mprotect,
|
||||||
* unevictable page deactivation for accelerating reclaim is pointless.
|
* unevictable folio deactivation for accelerating reclaim is pointless.
|
||||||
*/
|
*/
|
||||||
if (PageUnevictable(page))
|
if (folio_test_unevictable(folio))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (likely(get_page_unless_zero(page))) {
|
folio_get(folio);
|
||||||
struct pagevec *pvec;
|
local_lock(&lru_pvecs.lock);
|
||||||
|
pvec = this_cpu_ptr(&lru_pvecs.lru_deactivate_file);
|
||||||
|
|
||||||
local_lock(&lru_pvecs.lock);
|
if (pagevec_add_and_need_flush(pvec, &folio->page))
|
||||||
pvec = this_cpu_ptr(&lru_pvecs.lru_deactivate_file);
|
pagevec_lru_move_fn(pvec, lru_deactivate_file_fn);
|
||||||
|
local_unlock(&lru_pvecs.lock);
|
||||||
if (pagevec_add_and_need_flush(pvec, page))
|
|
||||||
pagevec_lru_move_fn(pvec, lru_deactivate_file_fn);
|
|
||||||
local_unlock(&lru_pvecs.lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -527,7 +527,7 @@ static unsigned long __invalidate_mapping_pages(struct address_space *mapping,
|
|||||||
* of interest and try to speed up its reclaim.
|
* of interest and try to speed up its reclaim.
|
||||||
*/
|
*/
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
deactivate_file_page(&folio->page);
|
deactivate_file_folio(folio);
|
||||||
/* It is likely on the pagevec of a remote CPU */
|
/* It is likely on the pagevec of a remote CPU */
|
||||||
if (nr_pagevec)
|
if (nr_pagevec)
|
||||||
(*nr_pagevec)++;
|
(*nr_pagevec)++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user