From: Jens Axboe <jens.axboe@oracle.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
chris.mason@oracle.com, david@fromorbit.com, hch@infradead.org,
akpm@linux-foundation.org, yanmin_zhang@linux.intel.com,
richard@rsk.demon.co.uk, damien.wyart@free.fr,
fweisbec@gmail.com, Alan.Brunelle@hp.com
Subject: Re: [PATCH 5/9] writeback: support > 1 flusher thread per bdi
Date: Thu, 6 Aug 2009 09:05:46 +0200 [thread overview]
Message-ID: <20090806070546.GH12579@kernel.dk> (raw)
In-Reply-To: <20090805195504.GD27505@duck.suse.cz>
On Wed, Aug 05 2009, Jan Kara wrote:
> > +static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work)
> > +{
> > + if (work) {
> > + work->seen = bdi->wb_mask;
> > + BUG_ON(!work->seen);
> > + atomic_set(&work->pending, bdi->wb_cnt);
> I guess the idea here is that every writeback thread has to acknowledge
> the work. But what if some thread decides to die after the work is queued
> but before it manages to acknowledge it? We would end up waiting
> indefinitely...
The writeback thread checks for race added work on exit, so it should be
fine. Additionally, only the default thread will exit and that one will
always have it's count and mask be valid (since we auto-fork it again,
if needed).
>
> > + BUG_ON(!bdi->wb_cnt);
> > +
> > + /*
> > + * Make sure stores are seen before it appears on the list
> > + */
> > + smp_mb();
> > +
> > + spin_lock(&bdi->wb_lock);
> > + list_add_tail_rcu(&work->list, &bdi->work_list);
> > + spin_unlock(&bdi->wb_lock);
> > + }
> > +
> > /*
> > - * This only happens the first time someone kicks this bdi, so put
> > - * it out-of-line.
> > + * If the default thread isn't there, make sure we add it. When
> > + * it gets created and wakes up, we'll run this work.
> > */
> > - if (unlikely(!bdi->wb.task))
> > + if (unlikely(list_empty_careful(&bdi->wb_list)))
> > wake_up_process(default_backing_dev_info.wb.task);
> > + else
> > + bdi_sched_work(bdi, work);
> > +}
> > +
> > +/*
> > + * Used for on-stack allocated work items. The caller needs to wait until
> > + * the wb threads have acked the work before it's safe to continue.
> > + */
> > +static void bdi_wait_on_work_clear(struct bdi_work *work)
> > +{
> > + wait_on_bit(&work->state, 0, bdi_sched_wait, TASK_UNINTERRUPTIBLE);
> > +}
> I still feel the rules for releasing / cleaning up work are too
> complicated.
> 1) I believe we can bear one more "int" for flags in the struct bdi_work
> so that you don't have to hide them in sb_data.
Sure, but there's little reason to do that I think, since it's only used
internally. Let me put it another way, why add an extra int if we can
avoid it?
> 2) I'd introduce a flag with the meaning: free the work when you are
> done. Obviusly this flag makes sence only with dynamically allocated work
> structure. There would be no "on stack" flag.
> 3) I'd create a function:
> bdi_wait_work_submitted()
> which you'd have to call whenever you didn't set the flag and want to
> free the work (either explicitely, or via returning from a function which
> has the structure on stack).
> It would do:
> bdi_wait_on_work_clear(work);
> call_rcu(&work->rcu_head, bdi_work_free);
>
> wb_work_complete() would just depending on the flag setting either
> completely do away with the work struct or just do bdi_work_clear().
>
> IMO that would make the code easier to check and also less prone to
> errors (currently you have to think twice when you have to wait for the rcu
> period, call bdi_work_free, etc.).
Didn't we go over all that last time, too?
--
Jens Axboe
next prev parent reply other threads:[~2009-08-06 7:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-30 21:23 [PATCH 0/9] Per-bdi writeback flusher threads v13 Jens Axboe
2009-07-30 21:23 ` [PATCH 1/9] writeback: move dirty inodes from super_block to backing_dev_info Jens Axboe
2009-08-06 21:35 ` Christoph Hellwig
2009-08-12 16:12 ` Jens Axboe
2009-08-12 16:18 ` Jens Axboe
2009-08-28 20:29 ` Christoph Hellwig
2009-07-30 21:23 ` [PATCH 2/9] writeback: switch to per-bdi threads for flushing data Jens Axboe
2009-08-05 16:35 ` Jan Kara
2009-08-06 21:44 ` Christoph Hellwig
2009-07-30 21:23 ` [PATCH 3/9] writeback: get rid of pdflush completely Jens Axboe
2009-07-30 21:23 ` [PATCH 4/9] writeback: separate the flushing state/task from the bdi Jens Axboe
2009-07-30 21:24 ` [PATCH 5/9] writeback: support > 1 flusher thread per bdi Jens Axboe
2009-08-05 19:55 ` Jan Kara
2009-08-06 7:05 ` Jens Axboe [this message]
2009-08-06 20:56 ` Jan Kara
2009-08-24 11:43 ` Jens Axboe
2009-08-24 12:36 ` Jan Kara
2009-08-24 14:09 ` Jens Axboe
2009-08-06 21:33 ` Christoph Hellwig
2009-07-30 21:24 ` [PATCH 6/9] writeback: allow sleepy exit of default writeback task Jens Axboe
2009-08-05 19:57 ` Jan Kara
2009-08-06 7:03 ` Jens Axboe
2009-08-06 18:55 ` Jan Kara
2009-07-30 21:24 ` [PATCH 7/9] writeback: add some debug inode list counters to bdi stats Jens Axboe
2009-07-30 21:24 ` [PATCH 8/9] writeback: add name to backing_dev_info Jens Axboe
2009-07-30 21:24 ` [PATCH 9/9] writeback: check for registered bdi in flusher add and inode dirty Jens Axboe
2009-07-31 6:30 ` [PATCH 0/9] Per-bdi writeback flusher threads v13 Damien Wyart
2009-07-31 7:15 ` Jens Axboe
2009-08-03 19:29 ` Damien Wyart
2009-08-03 20:28 ` Jens Axboe
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=20090806070546.GH12579@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=Alan.Brunelle@hp.com \
--cc=akpm@linux-foundation.org \
--cc=chris.mason@oracle.com \
--cc=damien.wyart@free.fr \
--cc=david@fromorbit.com \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=richard@rsk.demon.co.uk \
--cc=yanmin_zhang@linux.intel.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).