Skip to content

Commit

Permalink
mm, pagevec: release/reacquire lru_lock on pgdat change
Browse files Browse the repository at this point in the history
With node-lru, the locking is based on the pgdat.  Previously it was
required that a pagevec drain released one zone lru_lock and acquired
another zone lru_lock on every zone change.  Now, it's only necessary if
the node changes.  The end-result is fewer lock release/acquires if the
pages are all on the same node but in different zones.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Mel Gorman <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
gormanm authored and torvalds committed Jul 28, 2016
1 parent 9cb937e commit 68eb073
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions mm/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,26 +179,26 @@ static void pagevec_lru_move_fn(struct pagevec *pvec,
void *arg)
{
int i;
struct zone *zone = NULL;
struct pglist_data *pgdat = NULL;
struct lruvec *lruvec;
unsigned long flags = 0;

for (i = 0; i < pagevec_count(pvec); i++) {
struct page *page = pvec->pages[i];
struct zone *pagezone = page_zone(page);
struct pglist_data *pagepgdat = page_pgdat(page);

if (pagezone != zone) {
if (zone)
spin_unlock_irqrestore(zone_lru_lock(zone), flags);
zone = pagezone;
spin_lock_irqsave(zone_lru_lock(zone), flags);
if (pagepgdat != pgdat) {
if (pgdat)
spin_unlock_irqrestore(&pgdat->lru_lock, flags);
pgdat = pagepgdat;
spin_lock_irqsave(&pgdat->lru_lock, flags);
}

lruvec = mem_cgroup_page_lruvec(page, zone->zone_pgdat);
lruvec = mem_cgroup_page_lruvec(page, pgdat);
(*move_fn)(page, lruvec, arg);
}
if (zone)
spin_unlock_irqrestore(zone_lru_lock(zone), flags);
if (pgdat)
spin_unlock_irqrestore(&pgdat->lru_lock, flags);
release_pages(pvec->pages, pvec->nr, pvec->cold);
pagevec_reinit(pvec);
}
Expand Down

0 comments on commit 68eb073

Please sign in to comment.