lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090528125308.GA11363@kernel.dk>
Date:	Thu, 28 May 2009 14:53:08 +0200
From:	Jens Axboe <jens.axboe@...cle.com>
To:	Jan Kara <jack@...e.cz>
Cc:	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	chris.mason@...cle.com, david@...morbit.com, hch@...radead.org,
	akpm@...ux-foundation.org, yanmin_zhang@...ux.intel.com,
	richard@....demon.co.uk, damien.wyart@...e.fr
Subject: Re: [PATCH 07/11] writeback: support > 1 flusher thread per bdi

On Thu, May 28 2009, Jan Kara wrote:
> > >   Looking into this, it seems a bit complex with all that on_stack, sync /
> > > nosync thing. Wouldn't a simple refcounting scheme be more clear? Alloc /
> > > init_work_on_stack gets a reference from bdi_work, queue_work gets another
> > > reference passed later to flusher thread. We drop the reference when we
> > > leave bdi_start_writeback() and when flusher thread is done with the work.
> > > When refcount hits zero, work struct is freed (when work is on stack, we
> > > just never drop the last reference)...
> > 
> > It wouldn't change the complexity of the stack vs non-stack at all,
> > since you have to do the same checks for when it's safe to proceed. And
> > having the single bit there with the hash bit wait queues makes that bit
> > easier.
>   I think it would be simpler. Look:
> static void bdi_work_free(struct rcu_head *head)
> {
> 	struct bdi_work *work = container_of(head, struct bdi_work, rcu_head);
> 
> 	kfree(work);
> }
> 
> static void bdi_put_work(struct bdi_work *work)
> {
> 	if (!atomic_dec_and_test(&work->count, 1))
> 		call_rcu(&work->rcu_head, bdi_work_free);
> }
> 
> static void wb_work_complete(struct bdi_work *work)
> {
> 	bdi_work_clear(work);
> 	bdi_put_work(work);
> }
> 
> void bdi_start_writeback(...)
> {
> 	...
> 	if (must_wait || work == &work_stack)
> 		bdi_wait_on_work_clear(work);
> 	if (work != &work_stack)
> 		bdi_put_work(work);
> }
> 
>   IMO much easier to read...

And doesn't work, since you cannot exit after clearing the on-stack work
before before rcu is quisced. The bdi_work could be browseable by other
threads under rcu_read_lock(), just like you defer the kfree(), you have
to defer the bdi_work_clear() for on-stack work.

-- 
Jens Axboe

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ