From mboxrd@z Thu Jan 1 00:00:00 1970 From: Artem Bityutskiy Subject: Re: [RFC][PATCH 14/16] writeback: move bdi threads exiting logic to the forker thread Date: Tue, 20 Jul 2010 15:54:26 +0300 Message-ID: <1279630466.16462.132.camel@localhost> References: <1279284312-2411-1-git-send-email-dedekind1@gmail.com> <1279284312-2411-15-git-send-email-dedekind1@gmail.com> <20100718070231.GK23811@infradead.org> Reply-To: dedekind1@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Jens Axboe , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from smtp.nokia.com ([192.100.122.233]:63104 "EHLO mgw-mx06.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757019Ab0GTNBI (ORCPT ); Tue, 20 Jul 2010 09:01:08 -0400 In-Reply-To: <20100718070231.GK23811@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sun, 2010-07-18 at 03:02 -0400, Christoph Hellwig wrote: > Yes, only killing threads from the caller is much better, that's how > the kthread API is supposed to be used anyway. >=20 > > static void bdi_queue_work(struct backing_dev_info *bdi, > > struct wb_writeback_work *work) > > { > > + bool wakeup_default =3D false; > > + > > trace_writeback_queue(bdi, work); > > =20 > > spin_lock(&bdi->wb_lock); > > list_add_tail(&work->list, &bdi->work_list); > > - spin_unlock(&bdi->wb_lock); > > - > > /* > > * 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(!bdi->wb.task)) > > + wakeup_default =3D true; > > + else > > + wake_up_process(bdi->wb.task); > > + spin_unlock(&bdi->wb_lock); > > + > > + if (wakeup_default) { > > trace_writeback_nothread(bdi, work); > > wake_up_process(default_backing_dev_info.wb.task); >=20 > Why not simply do the defaul thread wakeup under wb_lock, too? > It keeps the code a lot simpler, and this is not a typical path anywa= y. Hmm, actually, I want to take this lock in __mark_inode_dirty() as well= , so it makes sense to micro-optimize this. Also, can 'trace_writeback_nothread()' be called under a spinlock? If no, then a variable is needed anyway. --=20 Best Regards, Artem Bityutskiy (=D0=90=D1=80=D1=82=D1=91=D0=BC =D0=91=D0=B8=D1=82=D1=8E= =D1=86=D0=BA=D0=B8=D0=B9) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html