All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@saeurebad.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Rik van Riel <riel@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-mm@kvack.org
Subject: [patch 1/3] swap: use an array for all pagevecs
Date: Thu, 23 Oct 2008 00:50:07 +0200	[thread overview]
Message-ID: <20081022225512.717773617@saeurebad.de> (raw)
In-Reply-To: 20081022225006.010250557@saeurebad.de

[-- Attachment #1: swap-use-an-array-for-all-pagevecs.patch --]
[-- Type: text/plain, Size: 2613 bytes --]

Use an array for all pagevecs, not just for those we cache new LRU
pages on.  This will ease further refactoring.

Signed-off-by: Johannes Weiner <hannes@saeurebad.de>
---
 include/linux/pagevec.h |    7 +++++++
 mm/swap.c               |   15 +++++++--------
 2 files changed, 14 insertions(+), 8 deletions(-)

--- a/mm/swap.c
+++ b/mm/swap.c
@@ -36,8 +36,7 @@
 /* How many pages do we try to swap or page in/out together? */
 int page_cluster;
 
-static DEFINE_PER_CPU(struct pagevec[NR_LRU_LISTS], lru_add_pvecs);
-static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
+static DEFINE_PER_CPU(struct pagevec[NR_LRU_PAGEVECS], lru_pvecs);
 
 /*
  * This path almost never happens for VM activity - pages are normally
@@ -144,7 +143,7 @@ void  rotate_reclaimable_page(struct pag
 
 		page_cache_get(page);
 		local_irq_save(flags);
-		pvec = &__get_cpu_var(lru_rotate_pvecs);
+		pvec = &__get_cpu_var(lru_pvecs)[PAGEVEC_ROTATE];
 		if (!pagevec_add(pvec, page))
 			pagevec_move_tail(pvec);
 		local_irq_restore(flags);
@@ -198,12 +197,12 @@ EXPORT_SYMBOL(mark_page_accessed);
 
 void __lru_cache_add(struct page *page, enum lru_list lru)
 {
-	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs)[lru];
+	struct pagevec *pvec = &get_cpu_var(lru_pvecs)[PAGEVEC_ADD + lru];
 
 	page_cache_get(page);
 	if (!pagevec_add(pvec, page))
 		____pagevec_lru_add(pvec, lru);
-	put_cpu_var(lru_add_pvecs);
+	put_cpu_var(lru_pvecs);
 }
 
 /**
@@ -272,17 +271,17 @@ void lru_cache_add_active_or_unevictable
  */
 static void drain_cpu_pagevecs(int cpu)
 {
-	struct pagevec *pvecs = per_cpu(lru_add_pvecs, cpu);
+	struct pagevec *pvecs = per_cpu(lru_pvecs, cpu);
 	struct pagevec *pvec;
 	int lru;
 
 	for_each_lru(lru) {
-		pvec = &pvecs[lru - LRU_BASE];
+		pvec = &pvecs[PAGEVEC_ADD + lru];
 		if (pagevec_count(pvec))
 			____pagevec_lru_add(pvec, lru);
 	}
 
-	pvec = &per_cpu(lru_rotate_pvecs, cpu);
+	pvec = &pvecs[PAGEVEC_ROTATE];
 	if (pagevec_count(pvec)) {
 		unsigned long flags;
 
--- a/include/linux/pagevec.h
+++ b/include/linux/pagevec.h
@@ -20,6 +20,13 @@ struct pagevec {
 	struct page *pages[PAGEVEC_SIZE];
 };
 
+enum lru_pagevec {
+	PAGEVEC_BASE,
+	PAGEVEC_ADD = PAGEVEC_BASE,
+	PAGEVEC_ROTATE = NR_LRU_LISTS,
+	NR_LRU_PAGEVECS
+};
+
 void __pagevec_release(struct pagevec *pvec);
 void __pagevec_release_nonlru(struct pagevec *pvec);
 void __pagevec_free(struct pagevec *pvec);


--
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:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2008-10-22 22:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-22 22:50 [patch 0/3] activate pages in batch Johannes Weiner
2008-10-22 22:50 ` Johannes Weiner [this message]
2008-10-22 22:50 ` [patch 2/3] swap: refactor pagevec flushing Johannes Weiner
2008-10-27  6:50   ` Andrew Morton
2008-10-27  8:08     ` Johannes Weiner
2008-10-27 12:18       ` [patch 2/3 v2] " Johannes Weiner
2008-10-22 22:50 ` [patch 3/3] swap: cache page activation Johannes Weiner
2008-10-23  1:41 ` [patch 0/3] activate pages in batch KOSAKI Motohiro
2008-10-23  2:00   ` Johannes Weiner
2008-10-23  2:10     ` KOSAKI Motohiro
2008-10-23 16:21       ` Johannes Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081022225512.717773617@saeurebad.de \
    --to=hannes@saeurebad.de \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.