linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Lameter <clameter@sgi.com>
To: akpm@osdl.org
Cc: Hugh Dickins <hugh@veritas.com>,
	linux-kernel@vger.kernel.org,
	Lee Schermerhorn <lee.schermerhorn@hp.com>,
	linux-mm@kvack.org, Christoph Lameter <clameter@sgi.com>,
	Hirokazu Takahashi <taka@valinux.co.jp>,
	Marcelo Tosatti <marcelo.tosatti@cyclades.com>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Subject: [PATCH 2/5] Swapless V2: Add migration swap entries
Date: Thu, 13 Apr 2006 16:54:16 -0700 (PDT)	[thread overview]
Message-ID: <20060413235416.15398.49978.sendpatchset@schroedinger.engr.sgi.com> (raw)
In-Reply-To: <20060413235406.15398.42233.sendpatchset@schroedinger.engr.sgi.com>

Add migration swap type and functions to handle migration entries

SWP_TYPE_MIGRATION is a special swap type that encodes the pfn of the
page in the swp_offset. SWP_TYPE_MIGRATION swap entries are only set
for a pte while the corresponding page is locked. Migration entries
are removed while the page is still locked. Therefore the processing
for this special type of swap page can be simple.

Only freeing and duplication operations are supported for copy_page_range
and zap_range. The freeing of this type of entry is ignored and we also
simply do nothing on duplication relying on the reverse maps to track
replications of the pte.

If do_swap_page encounters a migration entry then it simply redoes
the fault until the migration entry has gone away. We used to take
a page count on the old page which frequently caused the page migration
code to retry again. Redoing the fault immediately avoids
migration retries.

Migration entry related operations work even if CONFIG_SWAP has not been
switched on.

Signed-off-by: Christoph Lameter <clameter@sgi.com>

Index: linux-2.6.17-rc1-mm2/mm/swapfile.c
===================================================================
--- linux-2.6.17-rc1-mm2.orig/mm/swapfile.c	2006-04-02 20:22:10.000000000 -0700
+++ linux-2.6.17-rc1-mm2/mm/swapfile.c	2006-04-13 16:43:10.000000000 -0700
@@ -395,6 +395,9 @@ void free_swap_and_cache(swp_entry_t ent
 	struct swap_info_struct * p;
 	struct page *page = NULL;
 
+	if (is_migration_entry(entry))
+		return;
+
 	p = swap_info_get(entry);
 	if (p) {
 		if (swap_entry_free(p, swp_offset(entry)) == 1) {
@@ -1709,6 +1712,9 @@ int swap_duplicate(swp_entry_t entry)
 	unsigned long offset, type;
 	int result = 0;
 
+	if (is_migration_entry(entry))
+		return 1;
+
 	type = swp_type(entry);
 	if (type >= nr_swapfiles)
 		goto bad_file;
Index: linux-2.6.17-rc1-mm2/include/linux/swap.h
===================================================================
--- linux-2.6.17-rc1-mm2.orig/include/linux/swap.h	2006-04-11 12:14:34.000000000 -0700
+++ linux-2.6.17-rc1-mm2/include/linux/swap.h	2006-04-13 16:43:21.000000000 -0700
@@ -29,7 +29,13 @@ static inline int current_is_kswapd(void
  * the type/offset into the pte as 5/27 as well.
  */
 #define MAX_SWAPFILES_SHIFT	5
+#ifndef CONFIG_MIGRATION
 #define MAX_SWAPFILES		(1 << MAX_SWAPFILES_SHIFT)
+#else
+/* Use last entry for page migration swap entries */
+#define MAX_SWAPFILES		((1 << MAX_SWAPFILES_SHIFT)-1)
+#define SWP_TYPE_MIGRATION	MAX_SWAPFILES
+#endif
 
 /*
  * Magic header for a swap area. The first part of the union is
Index: linux-2.6.17-rc1-mm2/include/linux/swapops.h
===================================================================
--- linux-2.6.17-rc1-mm2.orig/include/linux/swapops.h	2006-04-02 20:22:10.000000000 -0700
+++ linux-2.6.17-rc1-mm2/include/linux/swapops.h	2006-04-13 16:43:10.000000000 -0700
@@ -67,3 +67,35 @@ static inline pte_t swp_entry_to_pte(swp
 	BUG_ON(pte_file(__swp_entry_to_pte(arch_entry)));
 	return __swp_entry_to_pte(arch_entry);
 }
+
+#ifdef CONFIG_MIGRATION
+static inline swp_entry_t make_migration_entry(struct page *page)
+{
+	BUG_ON(!PageLocked(page));
+	return swp_entry(SWP_TYPE_MIGRATION, page_to_pfn(page));
+}
+
+static inline int is_migration_entry(swp_entry_t entry)
+{
+	return swp_type(entry) == SWP_TYPE_MIGRATION;
+}
+
+static inline struct page *migration_entry_to_page(swp_entry_t entry)
+{
+	struct page *p = pfn_to_page(swp_offset(entry));
+	/*
+	 * Any use of migration entries may only occur while the
+	 * corresponding page is locked
+	 */
+	BUG_ON(!PageLocked(p));
+	BUG_ON(!is_migration_entry(entry));
+	return p;
+}
+#else
+
+#define make_migration_entry(page) swp_entry(0, 0)
+#define is_migration_entry(swp) 0
+#define migration_entry_to_page(swp) NULL
+
+#endif
+
Index: linux-2.6.17-rc1-mm2/mm/memory.c
===================================================================
--- linux-2.6.17-rc1-mm2.orig/mm/memory.c	2006-04-11 12:14:34.000000000 -0700
+++ linux-2.6.17-rc1-mm2/mm/memory.c	2006-04-13 16:43:10.000000000 -0700
@@ -1879,6 +1879,12 @@ static int do_swap_page(struct mm_struct
 		goto out;
 
 	entry = pte_to_swp_entry(orig_pte);
+
+	if (unlikely(is_migration_entry(entry))) {
+		yield();
+		goto out;
+	}
+
 	page = lookup_swap_cache(entry);
 	if (!page) {
  		swapin_readahead(entry, address, vma);

--
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-04-13 23:54 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-13 23:54 [PATCH 0/5] Swapless page migration V2: Overview Christoph Lameter
2006-04-13 23:54 ` [PATCH 1/5] Swapless V2: try_to_unmap() - Rename ignrefs to "migration" Christoph Lameter
2006-04-13 23:54 ` Christoph Lameter [this message]
2006-04-14  0:13   ` [PATCH 2/5] Swapless V2: Add migration swap entries Andrew Morton
2006-04-14  0:29     ` Christoph Lameter
2006-04-14  0:42       ` Andrew Morton
2006-04-14  0:46         ` Christoph Lameter
2006-04-14  1:01           ` Andrew Morton
2006-04-14  1:17             ` Andrew Morton
2006-04-14  1:31               ` Christoph Lameter
2006-04-14  5:25                 ` Andrew Morton
2006-04-14 14:27                   ` Lee Schermerhorn
2006-04-14 16:01                   ` Christoph Lameter
2006-04-14  1:31             ` Christoph Lameter
2006-04-14  5:29               ` Andrew Morton
2006-04-14 17:28                 ` Implement lookup_swap_cache for migration entries Christoph Lameter
2006-04-14 18:31                   ` Andrew Morton
2006-04-14 18:48                     ` Christoph Lameter
2006-04-14 19:15                       ` Andrew Morton
2006-04-14 19:22                         ` Christoph Lameter
2006-04-14 19:53                           ` Andrew Morton
2006-04-14 20:12                             ` Christoph Lameter
2006-04-14 21:51                             ` Wait for migrating page after incr of page count under anon_vma lock Christoph Lameter
2006-04-17 23:52                               ` migration_entry_wait: Use the pte lock instead of the " Christoph Lameter
2006-04-14  0:36     ` [PATCH 2/5] Swapless V2: Add migration swap entries Christoph Lameter
2006-04-13 23:54 ` [PATCH 3/5] Swapless V2: Make try_to_unmap() create migration entries Christoph Lameter
2006-04-13 23:54 ` [PATCH 4/5] Swapless V2: Rip out swap portion of old migration code Christoph Lameter
2006-04-13 23:54 ` [PATCH 5/5] Swapless V2: Revise main migration logic Christoph Lameter
2006-04-14  1:19   ` KAMEZAWA Hiroyuki
2006-04-14  1:33     ` Christoph Lameter
2006-04-14  1:40       ` KAMEZAWA Hiroyuki
2006-04-14  2:34       ` KAMEZAWA Hiroyuki
2006-04-14  2:44         ` KAMEZAWA Hiroyuki
2006-04-14 17:29           ` Preserve write permissions in migration entries Christoph Lameter
2006-04-14 16:48         ` [PATCH 5/5] Swapless V2: Revise main migration logic Christoph Lameter
2006-04-15  0:06           ` KAMEZAWA Hiroyuki
2006-04-15 17:41             ` Christoph Lameter
2006-04-17  0:18               ` KAMEZAWA Hiroyuki
2006-04-17 17:00                 ` Christoph Lameter
2006-04-18  0:04                   ` KAMEZAWA Hiroyuki
2006-04-18  0:27                     ` Christoph Lameter
2006-04-18  0:42                       ` KAMEZAWA Hiroyuki
2006-04-18  1:57                         ` Christoph Lameter
2006-04-18  3:00                           ` KAMEZAWA Hiroyuki
2006-04-18  3:16                             ` Christoph Lameter
2006-04-18  3:32                               ` KAMEZAWA Hiroyuki
2006-04-18  6:58                                 ` Christoph Lameter
2006-04-18  8:05                                   ` KAMEZAWA Hiroyuki
2006-04-18  8:27                                     ` Christoph Lameter
2006-04-18  9:08                                       ` KAMEZAWA Hiroyuki
2006-04-18 16:49                                         ` Christoph Lameter
2006-04-14  0:08 ` [PATCH 0/5] Swapless page migration V2: Overview Andrew Morton
2006-04-14  0:27   ` Christoph Lameter
2006-04-14 14:14     ` Lee Schermerhorn

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=20060413235416.15398.49978.sendpatchset@schroedinger.engr.sgi.com \
    --to=clameter@sgi.com \
    --cc=akpm@osdl.org \
    --cc=hugh@veritas.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=lee.schermerhorn@hp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=marcelo.tosatti@cyclades.com \
    --cc=taka@valinux.co.jp \
    /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).