linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Fengguang Wu <fengguang.wu@intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Greg Thelen <gthelen@google.com>, Ying Han <yinghan@google.com>,
	"hannes@cmpxchg.org" <hannes@cmpxchg.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Rik van Riel <riel@redhat.com>, Mel Gorman <mgorman@suse.de>,
	Minchan Kim <minchan.kim@gmail.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 5/9] writeback: introduce the pageout work
Date: Thu, 1 Mar 2012 19:41:51 +0800	[thread overview]
Message-ID: <20120301114151.GA19049@localhost> (raw)
In-Reply-To: <20120301110404.GC4385@quack.suse.cz>

On Thu, Mar 01, 2012 at 12:04:04PM +0100, Jan Kara wrote:
> On Tue 28-02-12 16:04:03, Andrew Morton wrote:
> ...
> > > --- linux.orig/mm/vmscan.c	2012-02-28 19:07:06.065064464 +0800
> > > +++ linux/mm/vmscan.c	2012-02-28 20:26:15.559731455 +0800
> > > @@ -874,12 +874,22 @@ static unsigned long shrink_page_list(st
> > >  			nr_dirty++;
> > >  
> > >  			/*
> > > -			 * Only kswapd can writeback filesystem pages to
> > > -			 * avoid risk of stack overflow but do not writeback
> > > -			 * unless under significant pressure.
> > > +			 * Pages may be dirtied anywhere inside the LRU. This
> > > +			 * ensures they undergo a full period of LRU iteration
> > > +			 * before considering pageout. The intention is to
> > > +			 * delay writeout to the flusher thread, unless when
> > > +			 * run into a long segment of dirty pages.
> > > +			 */
> > > +			if (references == PAGEREF_RECLAIM_CLEAN &&
> > > +			    priority == DEF_PRIORITY)
> > > +				goto keep_locked;
> > > +
> > > +			/*
> > > +			 * Try relaying the pageout I/O to the flusher threads
> > > +			 * for better I/O efficiency and avoid stack overflow.
> > >  			 */
> > > -			if (page_is_file_cache(page) &&
> > > -					(!current_is_kswapd() || priority >= DEF_PRIORITY - 2)) {
> > > +			if (page_is_file_cache(page) && mapping &&
> > > +			    queue_pageout_work(mapping, page) >= 0) {
> > >  				/*
> > >  				 * Immediately reclaim when written back.
> > >  				 * Similar in principal to deactivate_page()
> > > @@ -892,8 +902,13 @@ static unsigned long shrink_page_list(st
> > >  				goto keep_locked;
> > >  			}
> > >  
> > > -			if (references == PAGEREF_RECLAIM_CLEAN)
> > > +			/*
> > > +			 * Only kswapd can writeback filesystem pages to
> > > +			 * avoid risk of stack overflow.
> > > +			 */
> > > +			if (page_is_file_cache(page) && !current_is_kswapd())
> > 
> > And here we run into big problems.
> > 
> > When a page-allocator enters direct reclaim, that process is trying to
> > allocate a page from a particular zone (or set of zones).  For example,
> > he wants a ZONE_NORMAL or ZONE_DMA page.  Asking flusher threads to go
> > off and write back three gigabytes of ZONE_HIGHMEM is pointless,
> > inefficient and doesn't fix the caller's problem at all.
> > 
> > This has always been the biggest problem with the
> > avoid-writeback-from-direct-reclaim patches.  And your patchset (as far
> > as I've read) doesn't address the problem at all and appears to be
> > blissfully unaware of its existence.
> > 
> > 
> > I've attempted versions of this I think twice, and thrown the patches
> > away in disgust.  One approach I tried was, within direct reclaim, to
> > grab the page I wanted (ie: one which is in one of the caller's desired
> > zones) and to pass that page over to the kernel threads.  The kernel
> > threads would ensure that this particular page was included in the
> > writearound preparation.  So that we at least make *some* progress
> > toward what the caller is asking us to do.
> > 
> > iirc, the way I "grabbed" the page was to actually lock it, with
> > [try_]_lock_page().  And unlock it again way over within the writeback
> > thread.  I forget why I did it this way, rather than get_page() or
> > whatever.  Locking the page is a good way of preventing anyone else
> > from futzing with it.  It also pins the inode, which perhaps meant that
> > with careful management, I could avoid the igrab()/iput() horrors
> > discussed above.
>   I think using get_page() might be a good way to go. Naive implementation:
> If we need to write a page from kswapd, we do get_page(), attach page to
> wb_writeback_work and push it to flusher thread to deal with it.
> Flusher thread sees the work, takes a page lock, verifies the page is still
> attached to some inode & dirty (it could have been truncated / cleaned by
> someone else) and if yes, it submits page for IO (possibly with some
> writearound). This scheme won't have problems with iput() and won't have
> problems with umount. Also we guarantee some progress - either flusher
> thread does it, or some else must have done the work before flusher thread
> got to it.

I like this idea.

get_page() looks the perfect solution to verify if the struct inode
pointer (w/o igrab) is still live and valid.

[...upon rethinking...] Oh but still we need to lock some page to pin
the inode during the writeout. Then there is the dilemma: if the page
is locked, we effectively keep it from being written out...

Thanks,
Fengguang

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2012-03-01 11:47 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 14:00 [PATCH 0/9] [RFC] pageout work and dirty reclaim throttling Fengguang Wu
2012-02-28 14:00 ` [PATCH 1/9] memcg: add page_cgroup flags for dirty page tracking Fengguang Wu
2012-02-29  0:50   ` KAMEZAWA Hiroyuki
2012-03-04  1:29     ` Fengguang Wu
2012-02-28 14:00 ` [PATCH 2/9] memcg: add dirty page accounting infrastructure Fengguang Wu
2012-02-28 22:37   ` Andrew Morton
2012-02-29  0:27     ` Fengguang Wu
2012-02-28 14:00 ` [PATCH 3/9] memcg: add kernel calls for memcg dirty page stats Fengguang Wu
2012-02-29  1:10   ` KAMEZAWA Hiroyuki
2012-02-28 14:00 ` [PATCH 4/9] memcg: dirty page accounting support routines Fengguang Wu
2012-02-28 15:15   ` Fengguang Wu
2012-02-28 22:45   ` Andrew Morton
2012-02-29  1:15     ` KAMEZAWA Hiroyuki
2012-02-28 14:00 ` [PATCH 5/9] writeback: introduce the pageout work Fengguang Wu
2012-02-29  0:04   ` Andrew Morton
2012-02-29  2:31     ` Fengguang Wu
2012-02-29 13:28     ` Fengguang Wu
2012-03-01 11:04     ` Jan Kara
2012-03-01 11:41       ` Fengguang Wu [this message]
2012-03-01 16:50         ` Jan Kara
2012-03-01 19:46         ` Andrew Morton
2012-03-03 13:25           ` Fengguang Wu
2012-03-07  0:37             ` Andrew Morton
2012-03-07  5:40               ` Fengguang Wu
2012-03-01 19:42       ` Andrew Morton
2012-03-01 21:15         ` Jan Kara
2012-03-01 21:22           ` Andrew Morton
2012-03-01 12:36     ` Fengguang Wu
2012-03-01 16:38       ` Jan Kara
2012-03-02  4:48         ` Fengguang Wu
2012-03-02  9:59           ` Jan Kara
2012-03-02 10:39             ` Fengguang Wu
2012-03-02 19:57               ` Andrew Morton
2012-03-03 13:55                 ` Fengguang Wu
2012-03-03 14:27                   ` Fengguang Wu
2012-03-04 11:13                     ` Fengguang Wu
2012-03-07 15:48                   ` Artem Bityutskiy
2012-03-09  7:31                     ` Fengguang Wu
2012-03-09  9:51                       ` Jan Kara
2012-03-09 10:24                         ` Artem Bityutskiy
2012-03-09 16:10                         ` Artem Bityutskiy
2012-03-09 21:11                           ` Jan Kara
2012-03-12 12:36                             ` Artem Bityutskiy
2012-03-12 14:02                               ` Jan Kara
2012-03-12 14:21                                 ` Artem Bityutskiy
2012-03-09 10:15                   ` Jan Kara
2012-03-09 15:10                     ` Fengguang Wu
2012-02-29 13:51   ` [PATCH v2 " Fengguang Wu
2012-03-01 13:35     ` Fengguang Wu
2012-03-02  6:22       ` [PATCH v3 " Fengguang Wu
2012-02-28 14:00 ` [PATCH 6/9] vmscan: dirty reclaim throttling Fengguang Wu
2012-02-28 14:00 ` [PATCH 7/9] mm: pass __GFP_WRITE to memcg charge and reclaim routines Fengguang Wu
2012-02-28 14:00 ` [PATCH 8/9] mm: dont set __GFP_WRITE on ramfs/sysfs writes Fengguang Wu
2012-03-01 10:13   ` Johannes Weiner
2012-03-01 10:30     ` Fengguang Wu
2012-02-28 14:00 ` [PATCH 9/9] mm: debug vmscan waits Fengguang Wu
2012-03-02  6:59   ` [RFC PATCH] mm: don't treat anonymous pages as dirtyable pages Fengguang Wu
2012-03-02  7:18     ` Fengguang Wu

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=20120301114151.GA19049@localhost \
    --to=fengguang.wu@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=gthelen@google.com \
    --cc=hannes@cmpxchg.org \
    --cc=jack@suse.cz \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=minchan.kim@gmail.com \
    --cc=riel@redhat.com \
    --cc=yinghan@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;
as well as URLs for NNTP newsgroup(s).