linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Bob Picco <bob.picco@hp.com>, Andrew Morton <akpm@osdl.org>,
	IWAMOTO Toshihiro <iwamoto@valinux.co.jp>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Christoph Lameter <christoph@lameter.com>,
	Wu Fengguang <wfg@mail.ustc.edu.cn>,
	Nick Piggin <npiggin@suse.de>, Linus Torvalds <torvalds@osdl.org>,
	Rik van Riel <riel@redhat.com>,
	Marcelo Tosatti <marcelo.tosatti@cyclades.com>
Subject: [PATCH 05/34] mm: page-replace-generic-pagevec.patch
Date: Wed, 22 Mar 2006 23:32:30 +0100	[thread overview]
Message-ID: <20060322223158.12658.73621.sendpatchset@twins.localnet> (raw)
In-Reply-To: <20060322223107.12658.14997.sendpatchset@twins.localnet>

From: Peter Zijlstra <a.p.zijlstra@chello.nl>

Since PG_active is already used to discriminate between active and inactive
lists, use it to collapse the two pagevec add functions and make it a generic
helper function.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Marcelo Tosatti <marcelo.tosatti@cyclades.com>

---

 include/linux/mm_page_replace.h    |    2 +
 include/linux/mm_use_once_policy.h |   16 ++++++++
 mm/swap.c                          |   31 ++++++++++++++++
 mm/useonce.c                       |   68 ++-----------------------------------
 4 files changed, 53 insertions(+), 64 deletions(-)

Index: linux-2.6-git/include/linux/mm_use_once_policy.h
===================================================================
--- linux-2.6-git.orig/include/linux/mm_use_once_policy.h
+++ linux-2.6-git/include/linux/mm_use_once_policy.h
@@ -8,6 +8,22 @@ static inline void page_replace_hint_act
 	SetPageActive(page);
 }
 
+static inline void
+add_page_to_inactive_list(struct zone *zone, struct page *page)
+{
+	list_add(&page->lru, &zone->policy.inactive_list);
+	zone->policy.nr_inactive++;
+}
+
+static inline void
+__page_replace_add(struct zone *zone, struct page *page)
+{
+	if (PageActive(page))
+		add_page_to_active_list(zone, page);
+	else
+		add_page_to_inactive_list(zone, page);
+}
+
 static inline void page_replace_hint_use_once(struct page *page)
 {
 }
Index: linux-2.6-git/include/linux/mm_page_replace.h
===================================================================
--- linux-2.6-git.orig/include/linux/mm_page_replace.h
+++ linux-2.6-git/include/linux/mm_page_replace.h
@@ -6,10 +6,12 @@
 #include <linux/mmzone.h>
 #include <linux/mm.h>
 #include <linux/pagevec.h>
+#include <linux/mm_inline.h>
 
 /* void page_replace_hint_active(struct page *); */
 /* void page_replace_hint_use_once(struct page *); */
 extern void fastcall page_replace_add(struct page *);
+/* void __page_replace_add(struct zone *, struct page *); */
 /* void page_replace_add_drain(void); */
 extern void __page_replace_add_drain(unsigned int);
 extern int page_replace_add_drain_all(void);
Index: linux-2.6-git/mm/useonce.c
===================================================================
--- linux-2.6-git.orig/mm/useonce.c
+++ linux-2.6-git/mm/useonce.c
@@ -11,64 +11,6 @@
 static DEFINE_PER_CPU(struct pagevec, lru_add_pvecs) = { 0, };
 static DEFINE_PER_CPU(struct pagevec, lru_add_active_pvecs) = { 0, };
 
-/*
- * Add the passed pages to the LRU, then drop the caller's refcount
- * on them.  Reinitialises the caller's pagevec.
- */
-void __pagevec_page_replace_add(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)
-				spin_unlock_irq(&zone->lru_lock);
-			zone = pagezone;
-			spin_lock_irq(&zone->lru_lock);
-		}
-		if (TestSetPageLRU(page))
-			BUG();
-		add_page_to_inactive_list(zone, page);
-	}
-	if (zone)
-		spin_unlock_irq(&zone->lru_lock);
-	release_pages(pvec->pages, pvec->nr, pvec->cold);
-	pagevec_reinit(pvec);
-}
-
-EXPORT_SYMBOL(__pagevec_page_replace_add);
-
-static void __pagevec_lru_add_active(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)
-				spin_unlock_irq(&zone->lru_lock);
-			zone = pagezone;
-			spin_lock_irq(&zone->lru_lock);
-		}
-		if (TestSetPageLRU(page))
-			BUG();
-		if (TestSetPageActive(page))
-			BUG();
-		add_page_to_active_list(zone, page);
-	}
-	if (zone)
-		spin_unlock_irq(&zone->lru_lock);
-	release_pages(pvec->pages, pvec->nr, pvec->cold);
-	pagevec_reinit(pvec);
-}
-
 static inline void lru_cache_add(struct page *page)
 {
 	struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
@@ -85,18 +27,16 @@ static inline void lru_cache_add_active(
 
 	page_cache_get(page);
 	if (!pagevec_add(pvec, page))
-		__pagevec_lru_add_active(pvec);
+		__pagevec_page_replace_add(pvec);
 	put_cpu_var(lru_add_active_pvecs);
 }
 
 void fastcall page_replace_add(struct page *page)
 {
-	if (PageActive(page)) {
-		ClearPageActive(page);
+	if (PageActive(page))
 		lru_cache_add_active(page);
-	} else {
+	else
 		lru_cache_add(page);
-	}
 }
 
 void __page_replace_add_drain(unsigned int cpu)
@@ -107,7 +47,7 @@ void __page_replace_add_drain(unsigned i
 		__pagevec_page_replace_add(pvec);
 	pvec = &per_cpu(lru_add_active_pvecs, cpu);
 	if (pagevec_count(pvec))
-		__pagevec_lru_add_active(pvec);
+		__pagevec_page_replace_add(pvec);
 }
 
 #ifdef CONFIG_NUMA
Index: linux-2.6-git/mm/swap.c
===================================================================
--- linux-2.6-git.orig/mm/swap.c
+++ linux-2.6-git/mm/swap.c
@@ -306,6 +306,37 @@ unsigned pagevec_lookup_tag(struct pagev
 
 EXPORT_SYMBOL(pagevec_lookup_tag);
 
+/*
+ * Add the passed pages to the LRU, then drop the caller's refcount
+ * on them.  Reinitialises the caller's pagevec.
+ */
+void __pagevec_page_replace_add(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)
+				spin_unlock_irq(&zone->lru_lock);
+			zone = pagezone;
+			spin_lock_irq(&zone->lru_lock);
+		}
+		if (TestSetPageLRU(page))
+			BUG();
+		__page_replace_add(zone, page);
+	}
+	if (zone)
+		spin_unlock_irq(&zone->lru_lock);
+	release_pages(pvec->pages, pvec->nr, pvec->cold);
+	pagevec_reinit(pvec);
+}
+
+EXPORT_SYMBOL(__pagevec_page_replace_add);
+
 #ifdef CONFIG_SMP
 /*
  * We tolerate a little inaccuracy to avoid ping-ponging the counter between

--
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>

  parent reply	other threads:[~2006-03-22 22:32 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-22 22:31 [PATCH 00/34] mm: Page Replacement Policy Framework Peter Zijlstra
2006-03-22 22:31 ` [PATCH 01/34] mm: kill-page-activate.patch Peter Zijlstra
2006-03-22 22:32 ` [PATCH 02/34] mm: page-replace-kconfig-makefile.patch Peter Zijlstra
2006-03-22 23:03   ` Jeff Garzik
2006-03-22 22:32 ` [PATCH 03/34] mm: page-replace-insert.patch Peter Zijlstra
2006-03-22 22:32 ` [PATCH 04/34] mm: page-replace-use_once.patch Peter Zijlstra
2006-03-22 22:32 ` Peter Zijlstra [this message]
2006-03-22 22:32 ` [PATCH 06/34] mm: page-replace-activate.patch Peter Zijlstra
2006-03-22 22:32 ` [PATCH 07/34] mm: page-replace-move-macros.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 08/34] mm: page-replace-move-scan_control.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 09/34] mm: page-replace-move-isolate_lru_pages.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 10/34] mm: page-replace-reinsert.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 11/34] mm: page-replace-should_reclaim_mapped.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 12/34] mm: page-replace-shrink.patch Peter Zijlstra
2006-03-22 22:33 ` [PATCH 13/34] mm: page-replace-mark-accessed.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 14/34] mm: page-replace-remove-mm_inline.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 15/34] mm: page-replace-rotate.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 16/34] mm: page-replace-init.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 17/34] mm: page-replace-info.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 18/34] mm: page-replace-counts.patch Peter Zijlstra
2006-03-22 22:34 ` [PATCH 19/34] mm: page-replace-data.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 20/34] mm: page-replace-pg_flags.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 21/34] mm: page-replace-nonresident.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 22/34] mm: page-replace-shrink-new.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 23/34] mm: page-replace-documentation.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 24/34] mm: sum_cpu_var.patch Peter Zijlstra
2006-03-22 22:35 ` [PATCH 25/34] mm: kswapd-writeout-wait.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 26/34] mm: clockpro-nonresident.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 27/34] mm: clockpro-ignore_token.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 28/34] mm: clockpro-PG_reclaim2.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 29/34] mm: clockpro-clockpro.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 30/34] mm: cart-nonresident.patch Peter Zijlstra
2006-03-22 22:36 ` [PATCH 31/34] mm: cart-PG_reclaim3.patch Peter Zijlstra
2006-03-22 22:37 ` [PATCH 32/34] mm: cart-cart.patch Peter Zijlstra
2006-03-22 22:37 ` [PATCH 33/34] mm: cart-r.patch Peter Zijlstra
2006-03-22 22:37 ` [PATCH 34/34] mm: random.patch Peter Zijlstra
2006-03-22 22:51 ` [PATCH 00/34] mm: Page Replacement Policy Framework Andrew Morton
2006-03-23  2:21   ` Nick Piggin
2006-03-23 21:13     ` Marcelo Tosatti
2006-03-23  4:01   ` Rik van Riel
2006-03-23 20:53   ` Marcelo Tosatti
2006-03-23 18:15     ` Linus Torvalds
2006-03-23 18:26       ` Rik van Riel
2006-03-23 18:48       ` Diego Calleja
2006-03-23 19:03       ` Peter Zijlstra
2006-03-23 22:30       ` Marcelo Tosatti
2006-03-23 20:49         ` Linus Torvalds
2006-03-23 20:59           ` Rik van Riel
2006-03-24 15:06       ` Helge Hafting
2006-03-28 23:05       ` Elladan

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=20060322223158.12658.73621.sendpatchset@twins.localnet \
    --to=a.p.zijlstra@chello.nl \
    --cc=akpm@osdl.org \
    --cc=bob.picco@hp.com \
    --cc=christoph@lameter.com \
    --cc=iwamoto@valinux.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=npiggin@suse.de \
    --cc=riel@redhat.com \
    --cc=torvalds@osdl.org \
    --cc=wfg@mail.ustc.edu.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox