@@ -724,8 +724,7 @@ void release_pages(struct page **pages, int nr)
{
int i;
LIST_HEAD(pages_to_free);
- struct pglist_data *locked_pgdat = NULL;
- struct lruvec *lruvec;
+ struct lruvec *locked_lruvec = NULL;
unsigned long uninitialized_var(flags);
unsigned int uninitialized_var(lock_batch);
@@ -737,19 +736,19 @@ void release_pages(struct page **pages, int nr)
* excessive with a continuous string of pages from the
* same pgdat. The lock is held only if pgdat != NULL.
*/
- if (locked_pgdat && ++lock_batch == SWAP_CLUSTER_MAX) {
- spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags);
- locked_pgdat = NULL;
+ if (locked_lruvec && ++lock_batch == SWAP_CLUSTER_MAX) {
+ spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags);
+ locked_lruvec = NULL;
}
if (is_huge_zero_page(page))
continue;
if (is_zone_device_page(page)) {
- if (locked_pgdat) {
- spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock,
+ if (locked_lruvec) {
+ spin_unlock_irqrestore(&locked_lruvec->lru_lock,
flags);
- locked_pgdat = NULL;
+ locked_lruvec = NULL;
}
/*
* ZONE_DEVICE pages that return 'false' from
@@ -766,27 +765,30 @@ void release_pages(struct page **pages, int nr)
continue;
if (PageCompound(page)) {
- if (locked_pgdat) {
- spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags);
- locked_pgdat = NULL;
+ if (locked_lruvec) {
+ spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags);
+ locked_lruvec = NULL;
}
__put_compound_page(page);
continue;
}
if (PageLRU(page)) {
+ struct lruvec *lruvec;
struct pglist_data *pgdat = page_pgdat(page);
- if (pgdat != locked_pgdat) {
- if (locked_pgdat)
- spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock,
+ lruvec = mem_cgroup_page_lruvec(page, pgdat);
+
+ if (lruvec != locked_lruvec) {
+ if (locked_lruvec)
+ spin_unlock_irqrestore(&locked_lruvec->lru_lock,
flags);
lock_batch = 0;
- locked_pgdat = pgdat;
- spin_lock_irqsave(&locked_pgdat->lruvec.lru_lock, flags);
+ locked_lruvec = lruvec;
+ spin_lock_irqsave(&locked_lruvec->lru_lock, flags);
+ sync_lruvec_pgdat(lruvec, pgdat);
}
- lruvec = mem_cgroup_page_lruvec(page, locked_pgdat);
VM_BUG_ON_PAGE(!PageLRU(page), page);
__ClearPageLRU(page);
del_page_from_lru_list(page, lruvec, page_off_lru(page));
@@ -798,8 +800,8 @@ void release_pages(struct page **pages, int nr)
list_add(&page->lru, &pages_to_free);
}
- if (locked_pgdat)
- spin_unlock_irqrestore(&locked_pgdat->lruvec.lru_lock, flags);
+ if (locked_lruvec)
+ spin_unlock_irqrestore(&locked_lruvec->lru_lock, flags);
mem_cgroup_uncharge_list(&pages_to_free);
free_unref_page_list(&pages_to_free);
Replace pgdat lru_lock with lruvec lru_lock. Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Jason Gunthorpe <jgg@ziepe.ca> Cc: Matthew Wilcox <willy@infradead.org> Cc: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Cc: Peng Fan <peng.fan@nxp.com> Cc: Nikolay Borisov <nborisov@suse.com> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/swap.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)