linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh.dickins@tiscali.co.uk>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Izik Eidus <ieidus@redhat.com>, Robin Holt <holt@sgi.com>,
	Chris Wright <chrisw@redhat.com>,
	linux-mm@kvack.org
Subject: Re: mm/ksm.c seems to be doing an unneeded _notify.
Date: Thu, 11 Mar 2010 06:23:33 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LSU.2.00.1003110617540.29040@sister.anvils> (raw)
In-Reply-To: <20100310221903.GC5967@random.random>

On Wed, 10 Mar 2010, Andrea Arcangeli wrote:
> On Wed, Mar 10, 2010 at 10:19:33PM +0200, Izik Eidus wrote:
> > On 03/10/2010 09:18 PM, Robin Holt wrote:
> > > While reviewing ksm.c, I noticed that ksm.c does:
> > >
> > >          if (pte_write(*ptep)) {
> > >                  pte_t entry;
> > >
> > >                  swapped = PageSwapCache(page);
> > >                  flush_cache_page(vma, addr, page_to_pfn(page));
> > >                  /*
> > >                   * Ok this is tricky, when get_user_pages_fast() run it doesnt
> > >                   * take any lock, therefore the check that we are going to make
> > >                   * with the pagecount against the mapcount is racey and
> > >                   * O_DIRECT can happen right after the check.
> > >                   * So we clear the pte and flush the tlb before the check
> > >                   * this assure us that no O_DIRECT can happen after the check
> > >                   * or in the middle of the check.
> > >                   */
> > >                  entry = ptep_clear_flush(vma, addr, ptep);
> > >                  /*
> > >                   * Check that no O_DIRECT or similar I/O is in progress on the
> > >                   * page
> > >                   */
> > >                  if (page_mapcount(page) + 1 + swapped != page_count(page)) {
> > >                          set_pte_at_notify(mm, addr, ptep, entry);
> > >                          goto out_unlock;
> > >                  }
> > >                  entry = pte_wrprotect(entry);
> > >                  set_pte_at_notify(mm, addr, ptep, entry);
> > >
> > >
> > > I would think the error case (where the page has an elevated page_count)
> > > should not be using set_pte_at_notify.  In that event, you are simply
> > > restoring the previous value.  Have I missed something or is this an
> > > extraneous _notify?
> > >    
> > 
> > Yes, I think you are right set_pte_at(mm, addr, ptep, entry);  would be
> > enough here.
> > 
> > I can`t remember or think any reason why I have used the _notify...
> > 
> > Lets just get ACK from Andrea and Hugh that they agree it isn't needed
> 
> _notify it's needed, we're downgrading permissions here.

Robin is not questioning that it's needed in the success case;
but in the case where we back out because the counts don't match,
and just put back the original entry, he's suggesting that then
the _notify isn't needed.

(I'm guessing that Robin is not making a significant improvement to KSM,
but rather trying to clarify his understanding of set_pte_at_notify.)

Hugh

--
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:[~2010-03-11  6:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-10 19:18 Robin Holt
2010-03-10 20:19 ` Chris Wright
2010-03-10 20:19 ` Izik Eidus
2010-03-10 22:19   ` Andrea Arcangeli
2010-03-11  6:23     ` Hugh Dickins [this message]
2010-03-11 13:20       ` Izik Eidus
2010-03-11 15:54         ` [Patch] mm/ksm.c is doing an unneeded _notify in write_protect_page Robin Holt
2010-03-11 16:01           ` Izik Eidus
2010-03-11 16:06             ` Andrea Arcangeli

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=alpine.LSU.2.00.1003110617540.29040@sister.anvils \
    --to=hugh.dickins@tiscali.co.uk \
    --cc=aarcange@redhat.com \
    --cc=chrisw@redhat.com \
    --cc=holt@sgi.com \
    --cc=ieidus@redhat.com \
    --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