linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mel@csn.ul.ie>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: Alex Villac??s Lasso <avillaci@fiec.espol.edu.ec>,
	Andrew Morton <akpm@linux-foundation.org>,
	avillaci@ceibo.fiec.espol.edu.ec,
	bugzilla-daemon@bugzilla.kernel.org,
	bugme-daemon@bugzilla.kernel.org, linux-mm@kvack.org
Subject: Re: [Bugme-new] [Bug 31142] New: Large write to USB stick freezes unrelated tasks for a long time
Date: Mon, 21 Mar 2011 16:37:42 +0000	[thread overview]
Message-ID: <20110321163742.GA24244@csn.ul.ie> (raw)
In-Reply-To: <20110321134832.GC5719@random.random>

On Mon, Mar 21, 2011 at 02:48:32PM +0100, Andrea Arcangeli wrote:
> On Mon, Mar 21, 2011 at 09:41:49AM +0000, Mel Gorman wrote:
> > The check is at the wrong level I believe because it misses NFS pages which
> > will still get queued for IO which can block waiting on a request to complete.
> 
> But for example ->migratepage won't block at all for swapcache... it's
> just a pointer for migrate_page... so I didnt' want to skip what could
> be nonblocking, it just makes migrate less reliable for no good in
> some case. The fallback case is very likely blocking instead so I only
> returned -EBUSY there.
> 

Fair point.

> Best would be to pass a sync/nonblock param to migratepage(nonblock)
> so that nfs_migrate_page can pass "nonblock" instead of "false" to
> nfs_find_and_lock_request.
> 

I had considered this but thought passing in sync to things like
migrate_page() that ignored it looked a little ugly.

> > sync should be bool.
> 
> That's better thanks.
> 
> > It's overkill to return EBUSY just because we failed to get a lock which could
> > be released very quickly. If we left rc as -EAGAIN it would retry again.
> > The worst case scenario is that the current process is the holder of the
> > lock and the loop is pointless but this is a relatively rare situation
> > (other than Hugh's loopback test aside which seems to be particularly good
> > at triggering that situation).
> 
> This change was only meant to possibly avoid some cpu waste in the
> tight loop, not really "blocking" related so I'm sure ok to drop it
> for now. The page lock holder better to be quick because with sync=0
> the tight loop will retry real fast. If the holder blocks we're not so
> smart at retrying in a tight loop but for now it's ok.
> 

Ok.

> > >  			goto move_newpage;
> > >  
> > > @@ -686,7 +695,11 @@ static int unmap_and_move(new_page_t get
> > >  	BUG_ON(charge);
> > >  
> > >  	if (PageWriteback(page)) {
> > > -		if (!force || !sync)
> > > +		if (!sync) {
> > > +			rc = -EBUSY;
> > > +			goto uncharge;
> > > +		}
> > > +		if (!force)
> > >  			goto uncharge;
> > 
> > Where as this is ok because if the page is being written back, it's fairly
> > unlikely it'll get cleared quickly enough for the retry loop to make sense.
> 
> Agreed.
> 
> > Because of the NFS pages and being a bit aggressive about using -EBUSY,
> > how about the following instead? (build tested only unfortunately)
> 
> I tested my version below but I think one needs udf with lots of dirty
> pages plus the usb to trigger this which I don't have setup
> immediately.
> 
> > @@ -586,18 +586,23 @@ static int move_to_new_page(struct page *newpage, struct page *page,
> >  	mapping = page_mapping(page);
> >  	if (!mapping)
> >  		rc = migrate_page(mapping, newpage, page);
> > -	else if (mapping->a_ops->migratepage)
> > -		/*
> > -		 * Most pages have a mapping and most filesystems
> > -		 * should provide a migration function. Anonymous
> > -		 * pages are part of swap space which also has its
> > -		 * own migration function. This is the most common
> > -		 * path for page migration.
> > -		 */
> > -		rc = mapping->a_ops->migratepage(mapping,
> > -						newpage, page);
> > -	else
> > -		rc = fallback_migrate_page(mapping, newpage, page);
> > +	else {
> > +		/* Do not writeback pages if !sync */
> > +		if (PageDirty(page) && !sync)
> > +			rc = -EBUSY;
> 
> I think it's better to at least change it to:
> 
> if (PageDirty(page) && !sync && mapping->a_ops->migratepage != migrate_page))
> 
> I wasn't sure how to handle noblocking ->migratepage for swapcache and
> tmpfs but probably the above check is a good enough approximation.
> 

It's a good enough approximation. It's a little ugly but I don't think
it's much uglier than passing in unused parameters to migrate_page().

> Before sending my patch I thought of adding a "sync" parameter to
> ->migratepage(..., sync/nonblock) but then the patch become
> bigger... and I just wanted to know if this was the problem or not so
> I deferred it.
> 

I deferred it for similar reasons. It was becoming a much larger change
than should be necessary for the fix.

> If we're sure that all migratepage blocks except for things like
> swapcache/tmpfs or other not-filebacked things that defines it to
> migrate_page, we're pretty well covered by adding a check like above
> migratepage == migrate_page and maybe we don't need to add a
> "sync/nonblock" parameter to ->migratepage(). For example the
> buffer_migrate_page can block too in lock_buffer.
> 

Agreed.

> This is the patch I'm trying with the addition of the above check and
> some comment space/tab issue cleanup.
> 

Nothing bad jumped out at me. Lets see how it gets on with testing.

Thanks

-- 
Mel Gorman
SUSE Labs

--
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>

  parent reply	other threads:[~2011-03-21 16:37 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-31142-10286@https.bugzilla.kernel.org/>
2011-03-15 20:53 ` [Bugme-new] [Bug 31142] New: Large write to USB stick freezes unrelated tasks for a long time Andrew Morton
2011-03-15 22:53   ` Alex Villací­s Lasso
2011-03-15 23:19     ` Andrew Morton
2011-03-16 15:25       ` Alex Villací­s Lasso
2011-03-16 22:02         ` Andrew Morton
2011-03-17 21:27           ` Alex Villací­s Lasso
2011-03-17 21:47             ` Andrew Morton
2011-03-17 22:11               ` Alex Villací­s Lasso
2011-03-17 22:25                 ` Andrew Morton
2011-03-18 11:13               ` Mel Gorman
2011-03-18 12:26                 ` Andrea Arcangeli
2011-03-18 18:05                 ` Alex Villací­s Lasso
2011-03-19 13:46                   ` Mel Gorman
2011-03-19 16:04                     ` Alex Villací­s Lasso
2011-03-19 23:51                       ` Andrea Arcangeli
2011-03-21  9:41                         ` Mel Gorman
2011-03-21 13:48                           ` Andrea Arcangeli
2011-03-21 15:22                             ` Alex Villací­s Lasso
2011-03-21 15:36                               ` Alex Villací­s Lasso
2011-03-21 15:40                               ` Andrea Arcangeli
2011-03-21 16:37                             ` Mel Gorman [this message]
2011-03-21 17:05                               ` Alex Villací­s Lasso
2011-03-21 20:16                                 ` Andrea Arcangeli
2011-03-21 23:35                                   ` Alex Villací­s Lasso
2011-03-22 11:20                                   ` Mel Gorman
2011-03-22 15:03                                     ` Andrea Arcangeli
2011-03-22 20:34                                       ` Alex Villací­s Lasso
2011-03-22 21:40                                         ` Andrea Arcangeli
2011-03-23  0:37                                           ` Andrea Arcangeli
2011-03-23 16:51                                             ` Alex Villací­s Lasso
2011-04-04 15:37                                               ` Alex Villací­s Lasso
2011-04-08 19:09                                                 ` Andrea Arcangeli
2011-04-08 20:06                                                   ` Alex Villací­s Lasso
2011-04-12 16:27                                                     ` Alex Villací­s Lasso
2011-04-14 17:25                                                       ` Alex Villací­s Lasso
2011-04-14 17:37                                                         ` 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=20110321163742.GA24244@csn.ul.ie \
    --to=mel@csn.ul.ie \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=avillaci@ceibo.fiec.espol.edu.ec \
    --cc=avillaci@fiec.espol.edu.ec \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).