linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]: 1/4 batch mark_page_accessed()
@ 2004-11-21 15:44 Nikita Danilov
  2004-11-21 21:12 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Nikita Danilov @ 2004-11-21 15:44 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Andrew Morton, Linux MM Mailing List

Batch mark_page_accessed() (a la lru_cache_add() and lru_cache_add_active()):
page to be marked accessed is placed into per-cpu pagevec
(page_accessed_pvec). When pagevec is filled up, all pages are processed in a
batch.

This is supposed to decrease contention on zone->lru_lock.

(Patch is for 2.6.10-rc2)

Signed-off-by: Nikita Danilov <nikita@clusterfs.com>

 mm/swap.c |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 deletions(-)

diff -puN mm/swap.c~batch-mark_page_accessed mm/swap.c
--- bk-linux/mm/swap.c~batch-mark_page_accessed	2004-11-21 17:01:02.061618792 +0300
+++ bk-linux-nikita/mm/swap.c	2004-11-21 17:01:02.063618488 +0300
@@ -113,6 +113,39 @@ void fastcall activate_page(struct page 
 	spin_unlock_irq(&zone->lru_lock);
 }
 
+static void __pagevec_mark_accessed(struct pagevec *pvec)
+{
+	int i;
+	struct zone *zone = NULL;
+
+	for (i = 0; i < pagevec_count(pvec); i++) {
+		struct page *page = pvec->pages[i];
+		struct zone *pagezone = page_zone(page);
+
+		if (pagezone != zone) {
+			if (zone)
+				local_unlock_irq(&zone->lru_lock);
+			zone = pagezone;
+			local_lock_irq(&zone->lru_lock);
+		}
+		if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
+			del_page_from_inactive_list(zone, page);
+			SetPageActive(page);
+			add_page_to_active_list(zone, page);
+			inc_page_state(pgactivate);
+			ClearPageReferenced(page);
+		} else if (!PageReferenced(page)) {
+			SetPageReferenced(page);
+		}
+	}
+	if (zone)
+		local_unlock_irq(&zone->lru_lock);
+	release_pages(pvec->pages, pvec->nr, pvec->cold);
+	pagevec_reinit(pvec);
+}
+
+static DEFINE_PER_CPU(struct pagevec, page_accessed_pvec) = { 0, };
+
 /*
  * Mark a page as having seen activity.
  *
@@ -122,14 +155,14 @@ void fastcall activate_page(struct page 
  */
 void fastcall mark_page_accessed(struct page *page)
 {
-	if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
-		activate_page(page);
-		ClearPageReferenced(page);
-	} else if (!PageReferenced(page)) {
-		SetPageReferenced(page);
-	}
-}
+	struct pagevec *pvec;
 
+	pvec = &get_cpu_var(page_accessed_pvec);
+	page_cache_get(page);
+	if (!pagevec_add(pvec, page))
+		__pagevec_mark_accessed(pvec);
+	put_cpu_var(page_accessed_pvec);
+}
 EXPORT_SYMBOL(mark_page_accessed);
 
 /**

_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2004-12-02  1:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-21 15:44 [PATCH]: 1/4 batch mark_page_accessed() Nikita Danilov
2004-11-21 21:12 ` Andrew Morton
2004-11-24 10:40   ` Marcelo Tosatti
2004-11-24 16:32 ` Marcelo Tosatti
2004-11-24 21:53   ` Nikita Danilov
2004-11-26 18:58 ` Marcelo Tosatti
2004-11-27  0:37   ` Nick Piggin
2004-11-30 16:29     ` Marcelo Tosatti
2004-12-01  1:33       ` Andrew Morton
2004-11-30 22:57         ` Marcelo Tosatti
2004-12-01 12:23         ` Nikita Danilov
2004-12-01 18:58           ` Marcelo Tosatti
2004-12-02  1:59             ` Andrew Morton
2004-11-27 10:41   ` Nikita Danilov
2004-11-27  8:19     ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox