linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Christoph Lameter <clameter@engr.sgi.com>
Cc: Nick Piggin <npiggin@suse.de>, Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: Race in new page migration code?
Date: Sat, 14 Jan 2006 19:19:49 +0100	[thread overview]
Message-ID: <20060114181949.GA27382@wotan.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.62.0601140955340.11378@schroedinger.engr.sgi.com>

On Sat, Jan 14, 2006 at 10:01:43AM -0800, Christoph Lameter wrote:
> On Sat, 14 Jan 2006, Nick Piggin wrote:
> 
> > I'm fairly sure there is a race in the page migration code
> > due to your not taking a reference on the page. Taking the
> > reference also can make things less convoluted.
> 
> We take that reference count on the page:
> 

Yes, after you have dropped all your claims to pin this page
(ie. pte lock). You really can't take a refcount on a page that
you haven't somehow pinned (only I can ;)). This get_page_testone
code used by reclaim is a tricky special case where the page is
pinned by lru_lock even if it is "free" (ie. zero refcount).

It is not something that you can use without being very careful.
And I don't understand why you would want to even if it did work,
after you take a look at the simplicity of my patch.

> /*
>  * Isolate one page from the LRU lists.
>  *
>  * - zone->lru_lock must be held
>  */
> static inline int __isolate_lru_page(struct page *page)
> {
>         if (unlikely(!TestClearPageLRU(page)))
>                 return 0;
> 
> >>>>        if (get_page_testone(page)) {
>                 /*
>                  * It is being freed elsewhere
>                  */
>                 __put_page(page);
>                 SetPageLRU(page);
>                 return -ENOENT;
>         }
> 
>         return 1;
> }
> 

By this stage the page may have been freed, and reused by an
unrelated pagecache on the LRU. I'm not sure if there are any
worse races than this (ie. random page being moved), but I
wouldn't like to risk it.

>  
> > Also, an unsuccessful isolation attempt does not mean something is
> > wrong. I removed the WARN_ON, but you should probably be retrying
> > on this level if you are really interested in migrating all pages.
> 
> It depends what you mean by unsuccessful isolate attempt. One reason for 
> not being successful is that the page has been freed. Thats okay.
> 
> The other is that the page is not on the LRU, and is not being moved
> back to the LRU by draining the lru caches. In that case we need to
> have a WARN_ON at least for now. There may be other reasons that a page
> is not on the LRU but I would like to be careful about that at first.
> 
> Its not an error but something that is of concern thus WARN_ON.

kswapd picks them off the lru as normal part of scanning. A
WARN_ON is simply spam.

Nick

--
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-01-14 18:19 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-14 15:55 Nick Piggin
2006-01-14 18:01 ` Christoph Lameter
2006-01-14 18:19   ` Nick Piggin [this message]
2006-01-14 18:58     ` Christoph Lameter
2006-01-15  5:28       ` Nick Piggin
2006-01-16  6:54         ` Christoph Lameter
2006-01-16  7:44           ` Nick Piggin
2006-01-17  8:29           ` Magnus Damm
2006-01-17  9:01             ` Nick Piggin
2006-01-17  9:22               ` Magnus Damm
2006-01-15  6:58       ` Nick Piggin
2006-01-15 10:58       ` Hugh Dickins
2006-01-16  6:51         ` Christoph Lameter
2006-01-16 12:32           ` Hugh Dickins
2006-01-16 15:47             ` Christoph Lameter
2006-01-16 16:06               ` Hugh Dickins
2006-01-16 16:10                 ` Christoph Lameter
2006-01-16 16:28                   ` Hugh Dickins
2006-01-16 16:51                     ` Andi Kleen
2006-01-16 16:56                       ` Nick Piggin
2006-01-17  5:06                         ` Christoph Lameter
2006-01-17 11:16                           ` Nick Piggin
2006-01-17 17:29             ` Christoph Lameter
2006-01-17 18:46               ` Lee Schermerhorn
2006-01-17 18:48                 ` Christoph Lameter
2006-01-17 19:01               ` Hugh Dickins
2006-01-17 20:15                 ` Christoph Lameter
2006-01-17 20:49                   ` Hugh Dickins

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=20060114181949.GA27382@wotan.suse.de \
    --to=npiggin@suse.de \
    --cc=akpm@osdl.org \
    --cc=clameter@engr.sgi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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