public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Nick Piggin <npiggin@suse.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Edward Shishkin <edward.shishkin@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ryan Hope <rmh3093@gmail.com>,
	Randy Dunlap <randy.dunlap@oracle.com>,
	linux-kernel@vger.kernel.org,
	ReiserFS Mailing List <reiserfs-devel@vger.kernel.org>
Subject: Re: set_page_dirty races (was: Re: [patch 2/4] vfs: add set_page_dirty_notag)
Date: Tue, 17 Feb 2009 12:55:32 +0100	[thread overview]
Message-ID: <20090217115532.GF26402@wotan.suse.de> (raw)
In-Reply-To: <1234870772.4744.79.camel@laptop>

On Tue, Feb 17, 2009 at 12:39:32PM +0100, Peter Zijlstra wrote:
> On Tue, 2009-02-17 at 12:25 +0100, Nick Piggin wrote:
> 
> > Introduce put_user_pages function.
> > 
> > In order to have more flexibility to deal with issues surrounding
> > get_user_pages difficulties[*], introduce put_user_pages function
> > intended to release pages acquired by get_user_pages. For now, just
> > do the regular put_page thing. If all callers are converted, it could
> > be used to help with such races. In the meantime, it will actually
> > serve as a small extra piece of documentation for the code.
> > 
> > [*] eg. get_user_pages caller can bypass page_mkwrite calls into the
> >     filesystem to notify of page dirty activity if the page gets cleaned
> >     before the caller calls its final set_page_dirty).
> 
> Hmm, if we want to distinguish between .write=1 and .write=0, we would
> have to pass .write to pup too, right?

Doh, yeah. I hand edited the patch to put that parameter in, but quilt
refresh must have outsmarted me!

If nobody thinks it is insane, I'll resend to Andrew in a new thread.

> > ---
> >  include/linux/mm.h |    1 +
> >  mm/memory.c        |   13 ++++++++++++-
> >  2 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > Index: linux-2.6/include/linux/mm.h
> > ===================================================================
> > --- linux-2.6.orig/include/linux/mm.h
> > +++ linux-2.6/include/linux/mm.h
> > @@ -826,6 +826,7 @@ extern int access_process_vm(struct task
> >  int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, unsigned long start,
> >  		int len, int write, int force, struct page **pages, struct vm_area_struct **vmas);
> >  
> > +void put_user_pages(struct page **pages, int nr);
> >  extern int try_to_release_page(struct page * page, gfp_t gfp_mask);
> >  extern void do_invalidatepage(struct page *page, unsigned long offset);
> >  
> > Index: linux-2.6/mm/memory.c
> > ===================================================================
> > --- linux-2.6.orig/mm/memory.c
> > +++ linux-2.6/mm/memory.c
> > @@ -1370,9 +1370,20 @@ int get_user_pages(struct task_struct *t
> >  				start, len, flags,
> >  				pages, vmas);
> >  }
> > -
> >  EXPORT_SYMBOL(get_user_pages);
> >  
> > +/*
> > + * put_user_pages should be used to release pages acquired with get_user_pages.
> > + */
> > +void put_user_pages(struct page **pages, int nr)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < nr; i++)
> > +		put_page(pages[i]);
> > +}
> > +EXPORT_SYMBOL(put_user_pages);
> > +
> >  pte_t *get_locked_pte(struct mm_struct *mm, unsigned long addr,
> >  			spinlock_t **ptl)
> >  {
> > 

  reply	other threads:[~2009-02-17 11:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-13 11:56 [patch 2/4] vfs: add set_page_dirty_notag Edward Shishkin
2009-02-13 13:08 ` Peter Zijlstra
2009-02-13 13:57   ` Edward Shishkin
2009-02-13 14:09     ` Peter Zijlstra
2009-02-14 13:11       ` Edward Shishkin
2009-02-14 21:11         ` Peter Zijlstra
2009-02-16 22:43           ` Edward Shishkin
2009-02-17  9:09             ` Peter Zijlstra
2009-02-17  9:38               ` Nick Piggin
2009-02-17 10:05                 ` Peter Zijlstra
2009-02-17 10:24                   ` Nick Piggin
2009-02-17 10:40                     ` set_page_dirty races (was: Re: [patch 2/4] vfs: add set_page_dirty_notag) Peter Zijlstra
2009-02-17 11:25                       ` Nick Piggin
2009-02-17 11:39                         ` Peter Zijlstra
2009-02-17 11:55                           ` Nick Piggin [this message]
2009-02-17 12:05                             ` Peter Zijlstra
2009-02-17 12:30                               ` Nick Piggin
2009-02-17 22:35             ` [patch 2/4] vfs: add set_page_dirty_notag Andrew Morton
2009-02-18  0:26               ` Edward Shishkin
2009-02-18  0:38                 ` Andrew Morton
2009-02-18 13:27                   ` [patch 1/2] vfs: add/use update_page_accounting Edward Shishkin
2009-02-18 14:06                     ` Nick Piggin
2009-02-18 18:23                       ` Andrew Morton
2009-02-18 13:27                   ` [patch 2/2] vfs: (take 2)add set_page_dirty_notag Edward Shishkin

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=20090217115532.GF26402@wotan.suse.de \
    --to=npiggin@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=edward.shishkin@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=randy.dunlap@oracle.com \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=rmh3093@gmail.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