linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hugh@veritas.com>
To: Neil Brown <neilb@suse.de>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	Erez Zadok <ezk@cs.sunysb.edu>, Ryan Finnie <ryan@finnie.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	cjwatson@ubuntu.com, linux-mm@kvack.org
Subject: Re: msync(2) bug(?), returns AOP_WRITEPAGE_ACTIVATE to userland
Date: Fri, 26 Oct 2007 12:26:08 +0100 (BST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0710261124000.19611@blonde.wat.veritas.com> (raw)
In-Reply-To: <18209.19021.383347.160126@notabene.brown>

On Fri, 26 Oct 2007, Neil Brown wrote:
> On Thursday October 25, hugh@veritas.com wrote:
> 
> The patch looks like it makes perfect sense to me.

Great, thanks a lot for looking at it, Neil and Pekka.

> Before the change, ->writepage could return AOP_WRITEPAGE_ACTIVATE
> without unlocking the page, and this has precisely the effect of:
>    ClearPageReclaim();  (if the call path was through pageout)
>    SetPageActive();  (if the call was through shrink_page_list)
>    unlock_page();
> 
> With the patch, the ->writepage method does the SetPageActive and the
> unlock_page, which on the whole seems cleaner.
> 
> We seem to have lost a call to ClearPageReclaim - I don't know if that
> is significant.

It doesn't show up in the diff at all, but pageout() already has
		if (!PageWriteback(page)) {
			/* synchronous write or broken a_ops? */
			ClearPageReclaim(page);
		}
which will clear it since we've never set PageWriteback.

I think no harm would come from leaving it set there, since it only
takes effect in end_page_writeback (its effect being to let the just
written page be moved to the end of the LRU, so that it will then
be soon reclaimed), and clear_page_dirty_for_io clears it before
coming down this way.  But I'd never argue for that: I hate having
leftover flags hanging around outside the scope of their relevance.

> > Special, hidden, undocumented, secret hack!  Then in 2.6.7 Andrew
> > stole his own secret and used it when concocting ramdisk_writepage.
> > Oh, and NFS made some kind of use of it in 2.6.6 only.  Then Neil
> > revealed the secret to the uninitiated in 2.6.17: now, what's the
> > appropriate punishment for that?
> 
> Surely the punishment should be for writing hidden undocumented hacks
> in the first place!  I vote we just make him maintainer for the whole
> kernel - that will keep him so busy that he will never have a chance
> to do it again :-)

That is a splendid retort, which has won you absolution.
But it makes me a little sad: that smiley should be a weepy.

> > --- 2.6.24-rc1/Documentation/filesystems/vfs.txt	2007-10-24 07:15:11.000000000 +0100
> > +++ linux/Documentation/filesystems/vfs.txt	2007-10-24 08:42:07.000000000 +0100
> > @@ -567,9 +567,7 @@ struct address_space_operations {
> >        If wbc->sync_mode is WB_SYNC_NONE, ->writepage doesn't have to
> >        try too hard if there are problems, and may choose to write out
> >        other pages from the mapping if that is easier (e.g. due to
> > -      internal dependencies).  If it chooses not to start writeout, it
> > -      should return AOP_WRITEPAGE_ACTIVATE so that the VM will not keep
> > -      calling ->writepage on that page.
> > +      internal dependencies).
> >  
> 
> It seems that the new requirement is that if the address_space
> chooses not to write out the page, it should now call SetPageActive().
> If that is the case, I think it should be explicit in the
> documentation - please?

No, it's not the case; but you're right that I should add something
there, to put an end to the idea.  It'll be something along the lines
of "You may notice shmem setting PageActive there, but please don't do
that; or if you insist, be sure never to do so in the !wbc->for_reclaim
case".

The PageActive thing is for when a filesystem regrets that it even
had a ->writepage (it replicates the behaviour of the writepage == NULL
case or the VM_LOCKED SWAP_FAIL case or the !add_to_swap case, delaying
the return of this page to writepage for as long as it can).  It's done
in shmem_writepage because shm_lock (equivalent to VM_LOCKED) is only
discovered within that writepage, and no-swap is discovered there too.

ramdisk does it too: I've not tried to understand ramdisk as Nick and
Eric have, but it used to have no writepage, and would prefer to have
no writepage, but appears to need one for some PageUptodate reasons.

It's fairly normal for a filesystem to find that for some reason it
cannot carry out a writepage on this page right now (in the reclaim
case: the sync case demands action, IIRC); so it then simply does
set_page_dirty and unlock_page and returns "success".

I'll try to condense this down for the Doc when finalizing the patch;
which I've still not yet tested properly - thanks for the eyes, but
I can't submit it until I've checked in detail that it really gets
to do what we think it does.

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>

  parent reply	other threads:[~2007-10-26 11:26 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200710071920.l97JKJX5018871@agora.fsl.cs.sunysb.edu>
2007-10-11 21:47 ` Andrew Morton
2007-10-11 22:12   ` Ryan Finnie
2007-10-12  0:38     ` Hugh Dickins
2007-10-12 21:45       ` Pekka Enberg
2007-10-14  8:44         ` Hugh Dickins
2007-10-14 17:09           ` Pekka Enberg
2007-10-14 17:23             ` Erez Zadok
2007-10-14 17:50               ` Pekka J Enberg
2007-10-14 22:32                 ` Erez Zadok
2007-10-15 11:47                   ` Pekka Enberg
2007-10-16 18:02                     ` Erez Zadok
2007-10-22 20:16                     ` Hugh Dickins
2007-10-22 20:48                       ` Pekka Enberg
2007-10-25 15:36                         ` Hugh Dickins
2007-10-25 16:44                           ` Erez Zadok
2007-10-25 18:23                             ` Hugh Dickins
2007-10-26  2:00                           ` Neil Brown
2007-10-26  8:09                             ` Pekka Enberg
2007-10-26 11:26                             ` Hugh Dickins [this message]
2007-10-26  8:05                           ` Pekka Enberg
2007-10-22 21:04                       ` Erez Zadok
2007-10-25 16:40                         ` Hugh Dickins
2007-10-24 21:02                       ` [PATCH] fix tmpfs BUG and AOP_WRITEPAGE_ACTIVATE Hugh Dickins
2007-10-24 21:08                         ` Andrew Morton
2007-10-24 21:37                           ` [PATCH+comment] " Hugh Dickins
2007-10-25  5:37                             ` Pekka Enberg
2007-10-25  6:30                               ` Hugh Dickins
2007-10-25  7:24                                 ` Pekka Enberg
2007-10-25 16:01                                 ` Erez Zadok
2007-10-25 20:51                                   ` H. Peter Anvin
2007-10-22 20:01                   ` msync(2) bug(?), returns AOP_WRITEPAGE_ACTIVATE to userland Hugh Dickins
2007-10-22 20:40                     ` Pekka Enberg
2007-10-22 19:42               ` Hugh Dickins
2007-10-22 21:38                 ` Erez Zadok
2007-10-25 18:03                   ` Hugh Dickins
2007-10-27 20:47                     ` Erez Zadok
2007-10-28 20:23                     ` Erez Zadok
2007-10-29 20:33                       ` Hugh Dickins
2007-10-31 23:53                         ` Erez Zadok
2007-11-05 15:40                           ` Hugh Dickins
2007-11-05 16:38                             ` Dave Hansen
2007-11-05 18:57                               ` Hugh Dickins
2007-11-09  2:47                               ` Erez Zadok
2007-11-09  6:05                             ` Erez Zadok
2007-11-12  5:41                               ` Hugh Dickins
2007-11-12 17:01                               ` Hugh Dickins
2007-11-13 10:18                                 ` Erez Zadok
2007-11-17 21:24                                   ` Hugh Dickins
2007-11-20  1:30                                     ` Erez Zadok

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=Pine.LNX.4.64.0710261124000.19611@blonde.wat.veritas.com \
    --to=hugh@veritas.com \
    --cc=akpm@linux-foundation.org \
    --cc=cjwatson@ubuntu.com \
    --cc=ezk@cs.sunysb.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=neilb@suse.de \
    --cc=penberg@cs.helsinki.fi \
    --cc=ryan@finnie.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