linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Christoph Lameter <clameter@sgi.com>
Cc: hugh@veritas.com, linux-kernel@vger.kernel.org,
	lee.schermerhorn@hp.com, linux-mm@kvack.org, taka@valinux.co.jp,
	marcelo.tosatti@cyclades.com, kamezawa.hiroyu@jp.fujitsu.com
Subject: Re: [PATCH 2/5] Swapless V2: Add migration swap entries
Date: Thu, 13 Apr 2006 22:29:21 -0700	[thread overview]
Message-ID: <20060413222921.2834d897.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0604131827210.16220@schroedinger.engr.sgi.com>

Christoph Lameter <clameter@sgi.com> wrote:
>
> On Thu, 13 Apr 2006, Andrew Morton wrote:
> 
> > So we falsely return VM_FAULT_MINOR and let userspace retake the pagefault,
> > thus implementing a form of polling, yes?  If so, there is no "something
> > else" which this process can do.
> 
> Right.
> 
> > Pages are locked during migration.  The faulting process will sleep in
> > lock_page() until migration is complete.  Except we've gone and diddled
> > with the swap pte so do_swap_page() can no longer locate the page which
> > needs to be locked.
> 
> Oh. The page is enconded in the migration pte.
>  
> > Doing a busy-wait seems a bit lame.  Perhaps it would be better to go to
> > sleep on some global queue, poke that queue each time a page migration
> > completes?
> 
> If we rely on the migrating thread to hold the page count while the 
> page is locked then we could do what the patch below does. But then we 
> may race with the freeing of the old page after migration is finished.

Yeah, that's unpleasant.

> If we would add the 
> increment of the page count back then we are on the safe side but have 
> the problem that we may increment the page count before the migrating
> thread gets to the final check. Then the migration check would fail
> and we would retry.
> 
> 
> Index: linux-2.6.17-rc1-mm2/mm/memory.c
> ===================================================================
> --- linux-2.6.17-rc1-mm2.orig/mm/memory.c	2006-04-13 17:32:36.000000000 -0700
> +++ linux-2.6.17-rc1-mm2/mm/memory.c	2006-04-13 18:26:49.000000000 -0700
> @@ -1881,11 +1881,11 @@ static int do_swap_page(struct mm_struct
>  	entry = pte_to_swp_entry(orig_pte);
>  
>  	if (is_migration_entry(entry)) {
> -		/*
> -		 * We cannot access the page because of ongoing page
> -		 * migration. See if we can do something else.
> -		 */
> -		yield();
> +		page = migration_entry_to_page(entry);
> +		lock_page(page);
> +		entry = pte_to_swp_entry(*page_table);
> +		BUG_ON(is_migration_entry(entry));
> +		unlock_page(page);
>  		goto out;
>  	}

Is this page still lookable-uppable in swapcache?  If so, that's the way to
get the refcount on it.

We don't _have_ to use the page lock of course.   A simple

	wait_event(some_wq, !is_migration_entry(entry));

would suffice.

But what prevents this swp_entry_t from becoming an is_migration_entry
swp_pte_t two nanoseconds after we've passed this check?

--
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:[~2006-04-14  5:29 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 ` [PATCH 2/5] Swapless V2: Add migration swap entries Christoph Lameter
2006-04-14  0:13   ` 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 [this message]
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=20060413222921.2834d897.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=clameter@sgi.com \
    --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).