From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: [PATCH 04/11] writeback: switch to per-bdi threads for flushing data Date: Wed, 27 May 2009 13:24:12 +0200 Message-ID: <20090527112412.GZ11363@kernel.dk> References: <1243417312-7444-1-git-send-email-jens.axboe@oracle.com> <1243417312-7444-5-git-send-email-jens.axboe@oracle.com> <1243422713.23657.53.camel@twins> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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, jack@suse.cz, yanmin_zhang@linux.intel.com, richard@rsk.demon.co.uk, damien.wyart@free.fr To: Peter Zijlstra Return-path: Received: from brick.kernel.dk ([93.163.65.50]:33461 "EHLO kernel.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757960AbZE0LYL (ORCPT ); Wed, 27 May 2009 07:24:11 -0400 Content-Disposition: inline In-Reply-To: <1243422713.23657.53.camel@twins> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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