aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mlock.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/mlock.c')
-rw-r--r--mm/mlock.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/mm/mlock.c b/mm/mlock.c
index c59c420fd6e1..192e6eebe4f2 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -298,10 +298,12 @@ static void __munlock_pagevec(struct pagevec *pvec, struct zone *zone)
298{ 298{
299 int i; 299 int i;
300 int nr = pagevec_count(pvec); 300 int nr = pagevec_count(pvec);
301 int delta_munlocked = -nr; 301 int delta_munlocked;
302 struct pagevec pvec_putback; 302 struct pagevec pvec_putback;
303 int pgrescued = 0; 303 int pgrescued = 0;
304 304
305 pagevec_init(&pvec_putback, 0);
306
305 /* Phase 1: page isolation */ 307 /* Phase 1: page isolation */
306 spin_lock_irq(&zone->lru_lock); 308 spin_lock_irq(&zone->lru_lock);
307 for (i = 0; i < nr; i++) { 309 for (i = 0; i < nr; i++) {
@@ -330,18 +332,21 @@ skip_munlock:
330 /* 332 /*
331 * We won't be munlocking this page in the next phase 333 * We won't be munlocking this page in the next phase
332 * but we still need to release the follow_page_mask() 334 * but we still need to release the follow_page_mask()
333 * pin. 335 * pin. We cannot do it under lru_lock however. If it's
336 * the last pin, __page_cache_release would deadlock.
334 */ 337 */
338 pagevec_add(&pvec_putback, pvec->pages[i]);
335 pvec->pages[i] = NULL; 339 pvec->pages[i] = NULL;
336 put_page(page);
337 delta_munlocked++;
338 } 340 }
339 } 341 }
342 delta_munlocked = -nr + pagevec_count(&pvec_putback);
340 __mod_zone_page_state(zone, NR_MLOCK, delta_munlocked); 343 __mod_zone_page_state(zone, NR_MLOCK, delta_munlocked);
341 spin_unlock_irq(&zone->lru_lock); 344 spin_unlock_irq(&zone->lru_lock);
342 345
346 /* Now we can release pins of pages that we are not munlocking */
347 pagevec_release(&pvec_putback);
348
343 /* Phase 2: page munlock */ 349 /* Phase 2: page munlock */
344 pagevec_init(&pvec_putback, 0);
345 for (i = 0; i < nr; i++) { 350 for (i = 0; i < nr; i++) {
346 struct page *page = pvec->pages[i]; 351 struct page *page = pvec->pages[i];
347 352