linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
To: Paul Menage <menage@google.com>
Cc: linux-mm@kvack.org, akpm@osdl.org
Subject: Re: [RFC][PATCH 0/1] Node-based reclaim/migration
Date: Thu, 30 Nov 2006 13:11:04 +0900	[thread overview]
Message-ID: <20061130131104.b3bd70dd.kamezawa.hiroyu@jp.fujitsu.com> (raw)
In-Reply-To: <6599ad830611291631hd6d3e52y971c35708004db00@mail.gmail.com>

On Wed, 29 Nov 2006 16:31:22 -0800
"Paul Menage" <menage@google.com> wrote:

> On 11/29/06, KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> wrote:
> >
> > 2. AFAIK, migrating pages without taking write lock of any mm->sem will
> >    cause problem. anon_vma can be freed while migration.
> 
> Hmm, isn't migration just analagous to swapping out and swapping back
> in again, but without the actual swapping?
> 
I'm sorry if there is no problem in *current* kernel
== See ==
http://lkml.org/lkml/2006/4/17/168
>mmap_sem must be held during page migration due to the way we retrieve the 
>anonymous vma.
========

Logic
Considering migrate oldpage to newpage..

1. We unmap a oldpage at migraiton. page->mapcount turns to be 0.
2. copy contents of the oldpage to a newpage. page->mapcount of both pages are 0.
3. map the newpage. this uses copied newpage->mapping. page->mapcount goes up.

And see rmap.c
==
 511 void page_remove_rmap(struct page *page)
 512 {
 513         if (atomic_add_negative(-1, &page->_mapcount)) {
 514 #ifdef CONFIG_DEBUG_VM
 515                 if (unlikely(page_mapcount(page) < 0)) {
 516                         printk (KERN_EMERG "Eeek! page_mapcount(page) went negative! (%d)\n", page_mapcount(page));
 517                         printk (KERN_EMERG "  page->flags = %lx\n", page->flags);
 518                         printk (KERN_EMERG "  page->count = %x\n", page_count(page));
 519                         printk (KERN_EMERG "  page->mapping = %p\n", page->mapping);
 520                 }
 521 #endif
 522                 BUG_ON(page_mapcount(page) < 0);
 523                 /*
 524                  * It would be tidy to reset the PageAnon mapping here,
 525                  * but that might overwrite a racing page_add_anon_rmap
 526                  * which increments mapcount after us but sets mapping
 527                  * before us: so leave the reset to free_hot_cold_page,
 528                  * and remember that it's only reliable while mapped.
 529                  * Leaving it set also helps swapoff to reinstate ptes
 530                  * faster for those pages still in swapcache.
 531                  */
 532                 if (page_test_and_clear_dirty(page))
 533                         set_page_dirty(page);
 534                 __dec_zone_page_state(page,
 535                                 PageAnon(page) ? NR_ANON_PAGES : NR_FILE_MAPPED);
 536         }
====
We cannot trust page->mapping if page->mapcount == 0.
File pages are guarded by address_space's lock.

if mm->sem is held, the oldpage's anon_vma/vm_area_struct will not change.
Then, the relationship between oldpage/anon_vma will not change.
So, page migration with mm->sem is safe.

-Kame


--
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-11-30  4:11 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-29  3:06 menage
2006-11-29  3:06 ` [RFC][PATCH 1/1] Expose per-node reclaim and migration to userspace menage
2006-11-29  6:07   ` Nick Piggin
2006-11-29 21:57     ` Paul Menage
2006-11-30  4:13       ` Christoph Lameter
2006-11-30  4:18         ` Paul Menage
2006-11-30  7:38       ` Nick Piggin
2006-11-30  7:57         ` Paul Menage
2006-11-30  8:26           ` Nick Piggin
2006-11-30  8:39             ` Paul Menage
2006-11-30  8:55               ` Nick Piggin
2006-11-30  9:06                 ` Paul Menage
2006-11-30  9:21                   ` Nick Piggin
2006-11-30  9:45                     ` Paul Menage
2006-11-30 10:15                       ` Nick Piggin
2006-11-30 10:40                         ` Paul Menage
2006-11-30 11:04                           ` Nick Piggin
2006-11-30 11:23                             ` Paul Menage
2006-11-30 11:35                               ` Nick Piggin
2006-11-30  0:18   ` KAMEZAWA Hiroyuki
2006-11-30  0:25     ` Paul Menage
2006-11-30  0:38       ` KAMEZAWA Hiroyuki
2006-11-30  4:15       ` Christoph Lameter
2006-11-30  4:10   ` Christoph Lameter
2006-11-30  0:31 ` [RFC][PATCH 0/1] Node-based reclaim/migration KAMEZAWA Hiroyuki
2006-11-30  0:31   ` Paul Menage
2006-11-30  4:11     ` KAMEZAWA Hiroyuki [this message]
2006-11-30  4:17     ` Christoph Lameter
2006-11-30 10:45       ` Paul Menage
2006-11-30 11:12         ` KAMEZAWA Hiroyuki
2006-11-30 11:25           ` Paul Menage
2006-11-30 12:18             ` KAMEZAWA Hiroyuki
2006-11-30 18:28             ` Christoph Lameter
2006-11-30 18:35               ` Paul Menage
2006-11-30 18:39                 ` Christoph Lameter
2006-11-30 19:09                   ` Paul Menage
2006-11-30 19:42                     ` Christoph Lameter
2006-11-30 19:53                       ` Paul Menage
2006-11-30 20:00                         ` Christoph Lameter
2006-11-30 20:07                           ` Paul Menage
2006-11-30 20:15                             ` Christoph Lameter
2006-11-30 21:33                               ` Paul Menage
2006-11-30 23:41                                 ` Christoph Lameter
2006-11-30 23:48                                   ` Paul Menage
2006-12-01  2:23                                     ` Christoph Lameter
2006-12-01 19:32                                       ` Paul Menage
2006-12-01 19:56                                         ` Christoph Lameter
2006-12-01  2:44                                     ` KAMEZAWA Hiroyuki
2006-12-01  2:43                                       ` Christoph Lameter
2006-12-01  2:59                                         ` KAMEZAWA Hiroyuki
2006-12-01  2:44                                       ` Christoph Lameter
2006-12-01  3:10                                         ` KAMEZAWA Hiroyuki
2006-12-01  5:28                                           ` Christoph Lameter
2006-11-30  4:04 ` Christoph Lameter

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=20061130131104.b3bd70dd.kamezawa.hiroyu@jp.fujitsu.com \
    --to=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=akpm@osdl.org \
    --cc=linux-mm@kvack.org \
    --cc=menage@google.com \
    /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