From: Rik van Riel <riel@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, Nick Piggin <npiggin@suse.de>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Subject: [patch 01/19] move isolate_lru_page() to vmscan.c
Date: Tue, 08 Jan 2008 15:59:40 -0500 [thread overview]
Message-ID: <20080108205957.384385487@redhat.com> (raw)
In-Reply-To: 20080108205939.323955454@redhat.com
[-- Attachment #1: np-01-move-and-rework-isolate_lru_page-v2.patch --]
[-- Type: text/plain, Size: 7359 bytes --]
V1 -> V2 [lts]:
+ fix botched merge -- add back "get_page_unless_zero()"
From: Nick Piggin <npiggin@suse.de>
To: Linux Memory Management <linux-mm@kvack.org>
Subject: [patch 1/4] mm: move and rework isolate_lru_page
Date: Mon, 12 Mar 2007 07:38:44 +0100 (CET)
isolate_lru_page logically belongs to be in vmscan.c than migrate.c.
It is tough, because we don't need that function without memory migration
so there is a valid argument to have it in migrate.c. However a subsequent
patch needs to make use of it in the core mm, so we can happily move it
to vmscan.c.
Also, make the function a little more generic by not requiring that it
adds an isolated page to a given list. Callers can do that.
Note that we now have '__isolate_lru_page()', that does
something quite different, visible outside of vmscan.c
for use with memory controller. Methinks we need to
rationalize these names/purposes. --lts
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
Index: linux-2.6.24-rc6-mm1/include/linux/migrate.h
===================================================================
--- linux-2.6.24-rc6-mm1.orig/include/linux/migrate.h 2008-01-02 12:37:12.000000000 -0500
+++ linux-2.6.24-rc6-mm1/include/linux/migrate.h 2008-01-02 12:37:14.000000000 -0500
@@ -25,7 +25,6 @@ static inline int vma_migratable(struct
return 1;
}
-extern int isolate_lru_page(struct page *p, struct list_head *pagelist);
extern int putback_lru_pages(struct list_head *l);
extern int migrate_page(struct address_space *,
struct page *, struct page *);
@@ -42,8 +41,6 @@ extern int migrate_vmas(struct mm_struct
static inline int vma_migratable(struct vm_area_struct *vma)
{ return 0; }
-static inline int isolate_lru_page(struct page *p, struct list_head *list)
- { return -ENOSYS; }
static inline int putback_lru_pages(struct list_head *l) { return 0; }
static inline int migrate_pages(struct list_head *l, new_page_t x,
unsigned long private) { return -ENOSYS; }
Index: linux-2.6.24-rc6-mm1/mm/internal.h
===================================================================
--- linux-2.6.24-rc6-mm1.orig/mm/internal.h 2008-01-02 12:37:12.000000000 -0500
+++ linux-2.6.24-rc6-mm1/mm/internal.h 2008-01-02 12:37:14.000000000 -0500
@@ -34,6 +34,8 @@ static inline void __put_page(struct pag
atomic_dec(&page->_count);
}
+extern int isolate_lru_page(struct page *page);
+
extern void __init __free_pages_bootmem(struct page *page,
unsigned int order);
Index: linux-2.6.24-rc6-mm1/mm/migrate.c
===================================================================
--- linux-2.6.24-rc6-mm1.orig/mm/migrate.c 2008-01-02 12:37:12.000000000 -0500
+++ linux-2.6.24-rc6-mm1/mm/migrate.c 2008-01-02 12:37:14.000000000 -0500
@@ -36,36 +36,6 @@
#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
/*
- * Isolate one page from the LRU lists. If successful put it onto
- * the indicated list with elevated page count.
- *
- * Result:
- * -EBUSY: page not on LRU list
- * 0: page removed from LRU list and added to the specified list.
- */
-int isolate_lru_page(struct page *page, struct list_head *pagelist)
-{
- int ret = -EBUSY;
-
- if (PageLRU(page)) {
- struct zone *zone = page_zone(page);
-
- spin_lock_irq(&zone->lru_lock);
- if (PageLRU(page) && get_page_unless_zero(page)) {
- ret = 0;
- ClearPageLRU(page);
- if (PageActive(page))
- del_page_from_active_list(zone, page);
- else
- del_page_from_inactive_list(zone, page);
- list_add_tail(&page->lru, pagelist);
- }
- spin_unlock_irq(&zone->lru_lock);
- }
- return ret;
-}
-
-/*
* migrate_prep() needs to be called before we start compiling a list of pages
* to be migrated using isolate_lru_page().
*/
@@ -853,14 +823,17 @@ static int do_move_pages(struct mm_struc
!migrate_all)
goto put_and_set;
- err = isolate_lru_page(page, &pagelist);
+ err = isolate_lru_page(page);
+ if (err) {
put_and_set:
- /*
- * Either remove the duplicate refcount from
- * isolate_lru_page() or drop the page ref if it was
- * not isolated.
- */
- put_page(page);
+ /*
+ * Either remove the duplicate refcount from
+ * isolate_lru_page() or drop the page ref if it was
+ * not isolated.
+ */
+ put_page(page);
+ } else
+ list_add_tail(&page->lru, &pagelist);
set_status:
pp->status = err;
}
Index: linux-2.6.24-rc6-mm1/mm/vmscan.c
===================================================================
--- linux-2.6.24-rc6-mm1.orig/mm/vmscan.c 2008-01-02 12:37:12.000000000 -0500
+++ linux-2.6.24-rc6-mm1/mm/vmscan.c 2008-01-02 12:37:14.000000000 -0500
@@ -829,6 +829,47 @@ static unsigned long clear_active_flags(
return nr_active;
}
+/**
+ * isolate_lru_page(@page)
+ *
+ * Isolate one @page from the LRU lists. Must be called with an elevated
+ * refcount on the page, which is a fundamentnal difference from
+ * isolate_lru_pages (which is called without a stable reference).
+ *
+ * The returned page will have PageLru() cleared, and PageActive set,
+ * if it was found on the active list. This flag generally will need to be
+ * cleared by the caller before letting the page go.
+ *
+ * The vmstat page counts corresponding to the list on which the page was
+ * found will be decremented.
+ *
+ * lru_lock must not be held, interrupts must be enabled.
+ *
+ * Returns:
+ * -EBUSY: page not on LRU list
+ * 0: page removed from LRU list.
+ */
+int isolate_lru_page(struct page *page)
+{
+ int ret = -EBUSY;
+
+ if (PageLRU(page)) {
+ struct zone *zone = page_zone(page);
+
+ spin_lock_irq(&zone->lru_lock);
+ if (PageLRU(page) && get_page_unless_zero(page)) {
+ ret = 0;
+ ClearPageLRU(page);
+ if (PageActive(page))
+ del_page_from_active_list(zone, page);
+ else
+ del_page_from_inactive_list(zone, page);
+ }
+ spin_unlock_irq(&zone->lru_lock);
+ }
+ return ret;
+}
+
/*
* shrink_inactive_list() is a helper for shrink_zone(). It returns the number
* of reclaimed pages
Index: linux-2.6.24-rc6-mm1/mm/mempolicy.c
===================================================================
--- linux-2.6.24-rc6-mm1.orig/mm/mempolicy.c 2008-01-02 12:37:12.000000000 -0500
+++ linux-2.6.24-rc6-mm1/mm/mempolicy.c 2008-01-02 12:37:14.000000000 -0500
@@ -93,6 +93,8 @@
#include <asm/tlbflush.h>
#include <asm/uaccess.h>
+#include "internal.h"
+
/* Internal flags */
#define MPOL_MF_DISCONTIG_OK (MPOL_MF_INTERNAL << 0) /* Skip checks for continuous vmas */
#define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1) /* Invert check for nodemask */
@@ -603,8 +605,12 @@ static void migrate_page_add(struct page
/*
* Avoid migrating a page that is shared with others.
*/
- if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1)
- isolate_lru_page(page, pagelist);
+ if ((flags & MPOL_MF_MOVE_ALL) || page_mapcount(page) == 1) {
+ if (!isolate_lru_page(page)) {
+ get_page(page);
+ list_add_tail(&page->lru, pagelist);
+ }
+ }
}
static struct page *new_node_page(struct page *page, unsigned long node, int **x)
--
All Rights Reversed
--
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>
next prev parent reply other threads:[~2008-01-08 20:59 UTC|newest]
Thread overview: 75+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-08 20:59 [patch 00/19] VM pageout scalability improvements Rik van Riel
2008-01-08 20:59 ` Rik van Riel [this message]
2008-01-08 22:03 ` [patch 01/19] move isolate_lru_page() to vmscan.c Christoph Lameter
2008-01-08 20:59 ` [patch 02/19] free swap space on swap-in/activation Rik van Riel
2008-01-08 22:10 ` Christoph Lameter
2008-01-08 20:59 ` [patch 03/19] define page_file_cache() function Rik van Riel
2008-01-08 22:18 ` Christoph Lameter
2008-01-08 22:28 ` Rik van Riel
2008-01-09 4:26 ` KAMEZAWA Hiroyuki
2008-01-08 20:59 ` [patch 04/19] Use an indexed array for LRU variables Rik van Riel
2008-01-08 20:59 ` [patch 05/19] split LRU lists into anon & file sets Rik van Riel
2008-01-08 22:22 ` Christoph Lameter
2008-01-08 22:36 ` Rik van Riel
2008-01-08 22:42 ` Christoph Lameter
2008-01-09 2:45 ` Rik van Riel
2008-01-09 4:41 ` KAMEZAWA Hiroyuki
2008-01-10 2:21 ` Balbir Singh
2008-01-10 2:36 ` KAMEZAWA Hiroyuki
2008-01-10 3:26 ` Balbir Singh
2008-01-10 4:23 ` KAMEZAWA Hiroyuki
2008-01-10 2:28 ` KAMEZAWA Hiroyuki
2008-01-10 2:37 ` Rik van Riel
2008-01-11 3:59 ` KOSAKI Motohiro
2008-01-11 15:37 ` Rik van Riel
2008-01-11 6:24 ` KOSAKI Motohiro
2008-01-11 15:42 ` Rik van Riel
2008-01-11 15:59 ` Lee Schermerhorn
2008-01-11 16:15 ` Rik van Riel
2008-01-11 19:51 ` Lee Schermerhorn
2008-01-11 15:50 ` Lee Schermerhorn
2008-01-11 16:06 ` Rik van Riel
2008-01-11 7:35 ` KOSAKI Motohiro
2008-01-11 15:46 ` Rik van Riel
2008-01-14 23:57 ` KOSAKI Motohiro
2008-01-30 3:25 ` KOSAKI Motohiro
2008-01-30 8:57 ` KOSAKI Motohiro
2008-01-30 14:29 ` Lee Schermerhorn
2008-01-31 1:17 ` KOSAKI Motohiro
2008-01-31 10:48 ` Rik van Riel
2008-01-31 10:59 ` KOSAKI Motohiro
2008-02-07 0:35 ` Rik van Riel
2008-02-07 1:20 ` KOSAKI Motohiro
2008-02-07 1:36 ` Rik van Riel
2008-01-08 20:59 ` [patch 06/19] SEQ replacement for anonymous pages Rik van Riel
2008-01-08 20:59 ` [patch 07/19] (NEW) add some sanity checks to get_scan_ratio Rik van Riel
2008-01-09 4:16 ` KAMEZAWA Hiroyuki
2008-01-09 12:53 ` Rik van Riel
2008-01-08 20:59 ` [patch 08/19] add newly swapped in pages to the inactive list Rik van Riel
2008-01-08 22:28 ` Christoph Lameter
2008-01-08 20:59 ` [patch 09/19] (NEW) more aggressively use lumpy reclaim Rik van Riel
2008-01-08 22:30 ` Christoph Lameter
2008-01-14 15:28 ` Mel Gorman
2008-01-08 20:59 ` [patch 10/19] No Reclaim LRU Infrastructure Rik van Riel
2008-01-11 4:36 ` KOSAKI Motohiro
2008-01-11 15:43 ` Lee Schermerhorn
2008-01-15 0:06 ` KOSAKI Motohiro
2008-01-08 20:59 ` [patch 11/19] Non-reclaimable page statistics Rik van Riel
2008-01-08 20:59 ` [patch 12/19] scan noreclaim list for reclaimable pages Rik van Riel
2008-01-08 20:59 ` [patch 13/19] ramfs pages are non-reclaimable Rik van Riel
2008-01-08 20:59 ` [patch 14/19] SHM_LOCKED pages are nonreclaimable Rik van Riel
2008-01-08 20:59 ` [patch 15/19] non-reclaimable mlocked pages Rik van Riel
2008-01-08 20:59 ` [patch 16/19] mlock vma pages under mmap_sem held for read Rik van Riel
2008-01-08 20:59 ` [patch 17/19] handle mlocked pages during map/unmap and truncate Rik van Riel
2008-01-08 20:59 ` [patch 18/19] account mlocked pages Rik van Riel
2008-01-11 12:51 ` Balbir Singh
2008-01-13 5:18 ` Rik van Riel
2008-01-08 20:59 ` [patch 19/19] cull non-reclaimable anon pages from the LRU at fault time Rik van Riel
2008-01-10 4:39 ` [patch 00/19] VM pageout scalability improvements Mike Snitzer
2008-01-10 15:41 ` Rik van Riel
2008-01-10 16:08 ` Mike Snitzer
2008-01-11 10:41 ` Balbir Singh
2008-01-11 15:38 ` Rik van Riel
2008-01-11 11:47 ` Balbir Singh
2008-01-16 6:17 ` rvr split LRU minor regression ? KOSAKI Motohiro
-- strict thread matches above, loose matches on Subject: below --
2008-01-02 22:41 [patch 00/19] VM pageout scalability improvements linux-kernel
2008-01-02 22:41 ` [patch 01/19] move isolate_lru_page() to vmscan.c linux-kernel
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=20080108205957.384385487@redhat.com \
--to=riel@redhat.com \
--cc=Lee.Schermerhorn@hp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=npiggin@suse.de \
/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;
as well as URLs for NNTP newsgroup(s).