]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] reduced locking in release_pages()
authorAndrew Morton <akpm@digeo.com>
Thu, 19 Sep 2002 15:37:21 +0000 (08:37 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 19 Sep 2002 15:37:21 +0000 (08:37 -0700)
From Marcus Alanen <maalanen@ra.abo.fi>

Don't retake the zone lock after spilling a batch of pages into the
buddy.

Instead, just clear local variable `zone' to indicate that no lock is
held.

This is actually a common case - whenever release_pages() is called
with exactly 16 pages (truncate, page reclaim..) Marcus' patch will
save a lock and an unlock.

Also, remove some lock-avoidance heuristics in
pagevec_deactivate_inactive(): the caller has already made these
checks, and the chance of the check here actually doing anything useful
is negligible.

mm/swap.c

index 4e88784e20457e0d155cbc34bbdcc0d4f44adc1c..4528369df0840768a4748ba8964ac0abdf926b6c 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -124,9 +124,9 @@ void release_pages(struct page **pages, int nr)
                if (page_count(page) == 0) {
                        if (!pagevec_add(&pages_to_free, page)) {
                                spin_unlock_irq(&zone->lru_lock);
-                               pagevec_free(&pages_to_free);
+                               __pagevec_free(&pages_to_free);
                                pagevec_init(&pages_to_free);
-                               spin_lock_irq(&zone->lru_lock);
+                               zone = NULL;    /* No lock is held */
                        }
                }
        }
@@ -165,8 +165,8 @@ void __pagevec_release_nonlru(struct pagevec *pvec)
 }
 
 /*
- * Move all the inactive pages to the head of the inactive list
- * and release them.  Reinitialises the caller's pagevec.
+ * Move all the inactive pages to the head of the inactive list and release
+ * them.  Reinitialises the caller's pagevec.
  */
 void pagevec_deactivate_inactive(struct pagevec *pvec)
 {
@@ -180,8 +180,6 @@ void pagevec_deactivate_inactive(struct pagevec *pvec)
                struct zone *pagezone = page_zone(page);
 
                if (pagezone != zone) {
-                       if (PageActive(page) || !PageLRU(page))
-                               continue;
                        if (zone)
                                spin_unlock_irq(&zone->lru_lock);
                        zone = pagezone;