Hi, On Mon 13-09-10 20:31:12, Wu Fengguang wrote: > From: Jan Kara <jack@xxxxxxx> > > Background writeback and kupdate-style writeback are easily livelockable > (from a definition of their target). This is inconvenient because it can > make sync(1) stall forever waiting on its queued work to be finished. > Fix the problem by interrupting background and kupdate writeback if there > is some other work to do. We can return to them after completing all the > queued work. I actually have a slightly updated version with a better changelog: Background writeback are easily livelockable (from a definition of their target). This is inconvenient because it can make sync(1) stall forever waiting on its queued work to be finished. Generally, when a flusher thread has some work queued, someone submitted the work to achieve a goal more specific than what background writeback does. So it makes sense to give it a priority over a generic page cleaning. Thus we interrupt background writeback if there is some other work to do. We return to the background writeback after completing all the queued work. Could you please update it? Thanks. Honza PS: I've also attached the full patch if that's more convenient for you. > Signed-off-by: Jan Kara <jack@xxxxxxx> > Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx> > --- > fs/fs-writeback.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > --- linux-next.orig/fs/fs-writeback.c 2010-09-13 13:58:47.000000000 +0800 > +++ linux-next/fs/fs-writeback.c 2010-09-13 14:03:54.000000000 +0800 > @@ -643,6 +643,14 @@ static long wb_writeback(struct bdi_writ > break; > > /* > + * Background writeout and kupdate-style writeback are > + * easily livelockable. Stop them if there is other work > + * to do so that e.g. sync can proceed. > + */ > + if ((work->for_background || work->for_kupdate) && > + !list_empty(&wb->bdi->work_list)) > + break; > + /* > * For background writeout, stop when we are below the > * background dirty threshold > */ > > -- Jan Kara <jack@xxxxxxx> SUSE Labs, CR
>From ad6e0b4f46fdbc41fc256bb792414371ac54d051 Mon Sep 17 00:00:00 2001 From: Jan Kara <jack@xxxxxxx> Date: Mon, 2 Aug 2010 22:30:25 +0200 Subject: [PATCH 2/2] mm: Stop background writeback if there is other work queued for the thread Background writeback are easily livelockable (from a definition of their target). This is inconvenient because it can make sync(1) stall forever waiting on its queued work to be finished. Generally, when a flusher thread has some work queued, someone submitted the work to achieve a goal more specific than what background writeback does. So it makes sense to give it a priority over a generic page cleaning. Thus we interrupt background writeback if there is some other work to do. We return to the background writeback after completing all the queued work. Signed-off-by: Jan Kara <jack@xxxxxxx> --- fs/fs-writeback.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index e2eb42f..49fd41a 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -638,6 +638,14 @@ static long wb_writeback(struct bdi_writeback *wb, break; /* + * Background writeout and kupdate-style writeback are + * easily livelockable. Stop them if there is other work + * to do so that e.g. sync can proceed. + */ + if ((work->for_background || work->for_kupdate) && + !list_empty(&wb->bdi->work_list)) + break; + /* * For background writeout, stop when we are below the * background dirty threshold */ -- 1.6.4.2