lkml.org 
[lkml]   [2005]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/14] page-replace-candidates.patch
Date

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

page-replace interface function:
page_replace_candidates()

Abstract the taking of candidate reclaim pages and place the new function
in page_replace.c; the place where all list manupulation happens.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

include/linux/mm_page_replace.h | 2 ++
mm/page_replace.c | 20 ++++++++++++++++++++
mm/vmscan.c | 17 ++---------------
3 files changed, 24 insertions(+), 15 deletions(-)

Index: linux-2.6-git-2/include/linux/mm_page_replace.h
===================================================================
--- linux-2.6-git-2.orig/include/linux/mm_page_replace.h
+++ linux-2.6-git-2/include/linux/mm_page_replace.h
@@ -5,6 +5,7 @@

#include <linux/mmzone.h>
#include <linux/mm.h>
+#include <linux/list.h>

#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))

@@ -37,6 +38,7 @@
#endif

void __page_replace_insert(struct zone *, struct page *);
+void page_replace_candidates(struct zone *, int, struct list_head *);
static inline void page_replace_activate(struct page *page)
{
SetPageActive(page);
Index: linux-2.6-git-2/mm/page_replace.c
===================================================================
--- linux-2.6-git-2.orig/mm/page_replace.c
+++ linux-2.6-git-2/mm/page_replace.c
@@ -1,5 +1,6 @@
#include <linux/mm_page_replace.h>
#include <linux/mm_inline.h>
+#include <linux/swap.h>


void __page_replace_insert(struct zone *zone, struct page *page)
@@ -58,3 +59,22 @@ int isolate_lru_pages(int nr_to_scan, st
*scanned = scan;
return nr_taken;
}
+
+void page_replace_candidates(struct zone *zone, int nr_to_scan, struct list_head *page_list)
+{
+ int nr_taken;
+ int nr_scan;
+
+ spin_lock_irq(&zone->lru_lock);
+ nr_taken = isolate_lru_pages(nr_to_scan, &zone->inactive_list,
+ page_list, &nr_scan);
+ zone->nr_inactive -= nr_taken;
+ zone->pages_scanned += nr_scan;
+ spin_unlock_irq(&zone->lru_lock);
+
+ if (current_is_kswapd())
+ mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
+ else
+ mod_page_state_zone(zone, pgscan_direct, nr_scan);
+}
+
Index: linux-2.6-git-2/mm/vmscan.c
===================================================================
--- linux-2.6-git-2.orig/mm/vmscan.c
+++ linux-2.6-git-2/mm/vmscan.c
@@ -575,27 +575,14 @@ static void shrink_cache(struct zone *zo
LIST_HEAD(page_list);
struct pagevec pvec;
struct page *page;
- int nr_taken;
- int nr_scan;
int nr_freed;

lru_add_drain();

- spin_lock_irq(&zone->lru_lock);
- nr_taken = isolate_lru_pages(sc->nr_to_scan,
- &zone->inactive_list,
- &page_list, &nr_scan);
- zone->nr_inactive -= nr_taken;
- zone->pages_scanned += nr_scan;
- spin_unlock_irq(&zone->lru_lock);
-
- if (nr_taken == 0)
+ page_replace_candidates(zone, sc->nr_to_scan, &page_list);
+ if (list_empty(&page_list))
return;

- if (current_is_kswapd())
- mod_page_state_zone(zone, pgscan_kswapd, nr_scan);
- else
- mod_page_state_zone(zone, pgscan_direct, nr_scan);
nr_freed = shrink_list(&page_list, sc);
if (current_is_kswapd())
mod_page_state(kswapd_steal, nr_freed);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-12-30 23:45    [W:0.709 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site