From: Jan Kara <jack@suse.cz>
To: Derek Basehore <dbasehore@chromium.org>
Cc: Alexander Viro <viro@zento.linux.org.uk>, Jan Kara <jack@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Tejun Heo <tj@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Darrick J. Wong" <darrick.wong@oracle.com>,
Kees Cook <keescook@chromium.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, bleung@chromium.org, sonnyrao@chromium.org,
semenzato@chromium.org
Subject: Re: [PATCH] backing_dev: Fix hung task on sync
Date: Mon, 17 Feb 2014 10:20:54 +0100 [thread overview]
Message-ID: <20140217092054.GA3686@quack.suse.cz> (raw)
In-Reply-To: <1392437537-27392-1-git-send-email-dbasehore@chromium.org>
On Fri 14-02-14 20:12:17, Derek Basehore wrote:
> bdi_wakeup_thread_delayed used the mod_delayed_work function to schedule work
> to writeback dirty inodes. The problem with this is that it can delay work that
> is scheduled for immediate execution, such as the work from sync_inodes_sb.
> This can happen since mod_delayed_work can now steal work from a work_queue.
> This fixes the problem by using queue_delayed_work instead. This is a
> regression from the move to the bdi workqueue design.
>
> The reason that this causes a problem is that laptop-mode will change the
> delay, dirty_writeback_centisecs, to 60000 (10 minutes) by default. In the case
> that bdi_wakeup_thread_delayed races with sync_inodes_sb, sync will be stopped
> for 10 minutes and trigger a hung task. Even if dirty_writeback_centisecs is
> not long enough to cause a hung task, we still don't want to delay sync for
> that long.
>
> For the same reason, this also changes bdi_writeback_workfn to immediately
> queue the work again in the case that the work_list is not empty. The same
> problem can happen if the sync work is run on the rescue worker.
The patch looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>
I'd also suggest to push this to stable kernels.
Honza
>
> Signed-off-by: Derek Basehore <dbasehore@chromium.org>
> ---
> fs/fs-writeback.c | 5 +++--
> mm/backing-dev.c | 2 +-
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index e0259a1..95b7b8c 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -1047,8 +1047,9 @@ void bdi_writeback_workfn(struct work_struct *work)
> trace_writeback_pages_written(pages_written);
> }
>
> - if (!list_empty(&bdi->work_list) ||
> - (wb_has_dirty_io(wb) && dirty_writeback_interval))
> + if (!list_empty(&bdi->work_list))
> + mod_delayed_work(bdi_wq, &wb->dwork, 0);
> + else if (wb_has_dirty_io(wb) && dirty_writeback_interval)
> queue_delayed_work(bdi_wq, &wb->dwork,
> msecs_to_jiffies(dirty_writeback_interval * 10));
>
> diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> index ce682f7..3fde024 100644
> --- a/mm/backing-dev.c
> +++ b/mm/backing-dev.c
> @@ -294,7 +294,7 @@ void bdi_wakeup_thread_delayed(struct backing_dev_info *bdi)
> unsigned long timeout;
>
> timeout = msecs_to_jiffies(dirty_writeback_interval * 10);
> - mod_delayed_work(bdi_wq, &bdi->wb.dwork, timeout);
> + queue_delayed_work(bdi_wq, &bdi->wb.dwork, timeout);
> }
>
> /*
> --
> 1.9.0.rc1.175.g0b1dcb5
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
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>
next prev parent reply other threads:[~2014-02-17 9:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-15 4:12 [PATCH] backing_dev: Fix hung task on sync Derek Basehore
2014-02-17 9:20 ` Jan Kara [this message]
2014-02-18 22:55 ` Tejun Heo
2014-02-19 9:27 ` Jan Kara
2014-02-19 19:01 ` Tejun Heo
2014-03-11 18:23 ` Andrew Morton
2014-03-11 20:19 ` Jan Kara
2014-03-15 20:22 ` dbasehore .
2014-03-16 14:59 ` Tejun Heo
2014-03-16 19:13 ` dbasehore .
2014-03-16 20:20 ` dbasehore .
2014-03-17 14:40 ` Tejun Heo
2014-03-17 20:53 ` dbasehore .
2014-03-17 20:59 ` Tejun Heo
2014-03-17 9:53 ` Jan Kara
2014-02-19 15:31 ` dbasehore .
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=20140217092054.GA3686@quack.suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=bleung@chromium.org \
--cc=darrick.wong@oracle.com \
--cc=dbasehore@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=semenzato@chromium.org \
--cc=sonnyrao@chromium.org \
--cc=tj@kernel.org \
--cc=viro@zento.linux.org.uk \
/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).