Re: [PATCH 04/11] writeback: switch to per-bdi threads forflushing data

From: Jens Axboe
Date: Wed May 27 2009 - 07:24:25 EST


On Wed, May 27 2009, Peter Zijlstra wrote:
> On Wed, 2009-05-27 at 11:41 +0200, Jens Axboe wrote:
>
> > + if (writeback_acquire(bdi)) {
> > + bdi->wb_arg.nr_pages = nr_pages;
> > + bdi->wb_arg.sb = sb;
> > + bdi->wb_arg.sync_mode = sync_mode;
> > + /*
> > + * make above store seen before the task is woken
> > + */
> > + smp_mb();
> > + wake_up(&bdi->wait);
> > + }
>
> wake_up() implies a wmb() when we indeed to a wakeup, is that
> sufficient?

That is sufficient. I'll kill it in the next revision, seeing as this is
just an intermediate step, no harm done.

> > +int bdi_writeback_task(struct backing_dev_info *bdi)
> > +{
> > + while (!kthread_should_stop()) {
> > + unsigned long wait_jiffies;
> > + DEFINE_WAIT(wait);
> > +
> > + prepare_to_wait(&bdi->wait, &wait, TASK_INTERRUPTIBLE);
> > + wait_jiffies = msecs_to_jiffies(dirty_writeback_interval * 10);
> > + schedule_timeout(wait_jiffies);
> > + try_to_freeze();
> > +
> > + /*
> > + * We get here in two cases:
> > + *
> > + * schedule_timeout() returned because the dirty writeback
> > + * interval has elapsed. If that happens, we will be able
> > + * to acquire the writeback lock and will proceed to do
> > + * kupdated style writeout.
> > + *
> > + * Someone called bdi_start_writeback(), which will acquire
> > + * the writeback lock. This means our writeback_acquire()
> > + * below will fail and we call into bdi_pdflush() for
> > + * pdflush style writeout.
> > + *
> > + */
> > + if (writeback_acquire(bdi))
> > + bdi_kupdated(bdi);
> > + else
> > + bdi_pdflush(bdi);
> > +
> > + writeback_release(bdi);
> > + finish_wait(&bdi->wait, &wait);
> > + }
> > +
> > + return 0;
> > +}
>
> the unpaired writeback_release() wrt writeback_acquire() looks odd.

Did you read the comment? :-)

> Also the prepare/finish wait bits seem oddly out of place. Are there
> really multiple waiters on bdi->wait? The above wake_up() seems to
> suggest not, since it directly modifies bdi state instead of queueing
> work.

Intermediate step, further along it should be more clear.

--
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/