From: Tejun Heo <tj@kernel.org>
To: jaxboe@fusionio.com, linux-kernel@vger.kernel.org, hch@lst.de
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 5/5] backing-dev: replace sync_supers_tsk/timer with a delayed_work
Date: Mon, 6 Sep 2010 14:46:22 +0200 [thread overview]
Message-ID: <1283777182-11426-6-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1283777182-11426-1-git-send-email-tj@kernel.org>
sync_supers_task/timer can trivially replaced with a delayed_work. As
it's not on the allocation path, run it on the system_wq.
NOTE: Both before and after this patch, sync_supers is not freezeable.
This might need to be changed.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
mm/backing-dev.c | 49 ++++++++++++++-----------------------------------
1 files changed, 14 insertions(+), 35 deletions(-)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 3b2a657..4fb8095 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -45,11 +45,8 @@ LIST_HEAD(bdi_list);
LIST_HEAD(bdi_pending_list);
struct workqueue_struct *bdi_wq;
-static struct task_struct *sync_supers_tsk;
-static struct timer_list sync_supers_timer;
-
-static int bdi_sync_supers(void *);
-static void sync_supers_timer_fn(unsigned long);
+static void bdi_sync_supers_work_fn(struct work_struct *work);
+static DECLARE_DELAYED_WORK(bdi_sync_supers_work, bdi_sync_supers_work_fn);
#ifdef CONFIG_DEBUG_FS
#include <linux/debugfs.h>
@@ -239,10 +236,6 @@ static int __init default_bdi_init(void)
WQ_UNBOUND | WQ_FREEZEABLE | WQ_RESCUER, 0);
BUG_ON(!bdi_wq);
- sync_supers_tsk = kthread_run(bdi_sync_supers, NULL, "sync_supers");
- BUG_ON(IS_ERR(sync_supers_tsk));
-
- setup_timer(&sync_supers_timer, sync_supers_timer_fn, 0);
bdi_arm_supers_timer();
err = bdi_init(&default_backing_dev_info);
@@ -271,43 +264,29 @@ static void bdi_flush_io(struct backing_dev_info *bdi)
}
/*
- * kupdated() used to do this. We cannot do it from the bdi_forker_thread()
- * or we risk deadlocking on ->s_umount. The longer term solution would be
- * to implement sync_supers_bdi() or similar and simply do it from the
- * bdi writeback thread individually.
+ * kupdated() used to do this. Don't do it from bdi_wq as we might
+ * deadlock on ->s_umount.
*/
-static int bdi_sync_supers(void *unused)
+static void bdi_sync_supers_work_fn(struct work_struct *work)
{
- set_user_nice(current, 0);
-
- while (!kthread_should_stop()) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule();
-
- /*
- * Do this periodically, like kupdated() did before.
- */
- sync_supers();
- }
+ /* Do this periodically, like kupdated() did before */
+ sync_supers();
- return 0;
+ if (dirty_writeback_interval)
+ schedule_delayed_work(&bdi_sync_supers_work,
+ msecs_to_jiffies(dirty_writeback_interval * 10));
}
void bdi_arm_supers_timer(void)
{
- unsigned long next;
+ /* Interval might have decreased, cancel delayed work first */
+ cancel_delayed_work(&bdi_sync_supers_work);
if (!dirty_writeback_interval)
return;
- next = msecs_to_jiffies(dirty_writeback_interval * 10) + jiffies;
- mod_timer(&sync_supers_timer, round_jiffies_up(next));
-}
-
-static void sync_supers_timer_fn(unsigned long unused)
-{
- wake_up_process(sync_supers_tsk);
- bdi_arm_supers_timer();
+ schedule_delayed_work(&bdi_sync_supers_work,
+ msecs_to_jiffies(dirty_writeback_interval * 10));
}
static void bdi_timer_fn(unsigned long data)
--
1.7.1
next prev parent reply other threads:[~2010-09-06 12:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-06 12:46 [PATCHSET] backing-dev: replace private thread pool with workqueue Tejun Heo
2010-09-06 12:46 ` [PATCH 1/5] workqueue: implement workqueue_on_rescuer() Tejun Heo
2010-09-06 12:46 ` [PATCH 2/5] backing-dev: kill unused bdi_writeback->nr Tejun Heo
2010-09-08 8:57 ` Artem Bityutskiy
2010-09-06 12:46 ` [PATCH 3/5] backing-dev: replace private thread pool with workqueue Tejun Heo
2010-09-06 12:46 ` [PATCH 4/5] backing-dev: update trace points Tejun Heo
2010-09-06 12:46 ` Tejun Heo [this message]
2010-09-08 9:00 ` [PATCH 5/5] backing-dev: replace sync_supers_tsk/timer with a delayed_work Artem Bityutskiy
2010-09-07 12:16 ` [PATCHSET] backing-dev: replace private thread pool with workqueue Christoph Hellwig
2010-09-07 12:19 ` Tejun Heo
2010-09-07 12:29 ` Jens Axboe
2010-09-07 12:36 ` Tejun Heo
2010-11-27 16:02 ` Tejun Heo
2010-11-27 18:50 ` Jens Axboe
2010-11-27 20:30 ` Tejun Heo
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=1283777182-11426-6-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=hch@lst.de \
--cc=jaxboe@fusionio.com \
--cc=linux-kernel@vger.kernel.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