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: <20090706154345.GT23611@kernel.dk>
Date:	Mon, 6 Jul 2009 17:43:45 +0200
From:	Jens Axboe <jens.axboe@...cle.com>
To:	Artem Bityutskiy <dedekind1@...il.com>
Cc:	Jamie Lokier <jamie@...reable.org>, linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org, chris.mason@...cle.com,
	david@...morbit.com, hch@...radead.org, akpm@...ux-foundation.org,
	jack@...e.cz, yanmin_zhang@...ux.intel.com,
	richard@....demon.co.uk, damien.wyart@...e.fr, fweisbec@...il.com,
	Alan.Brunelle@...com
Subject: Re: [PATCH 05/10] writeback: support > 1 flusher thread per bdi

On Mon, Jul 06 2009, Artem Bityutskiy wrote:
> Jamie Lokier wrote:
>> Artem Bityutskiy wrote:
>>> Jens Axboe 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);
>>>> +		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);
>>>> +	}
>>> Doesn't spin_lock() include an implicit memory barrier?
>>> After &bdi->wb_lock is acquired, it is guaranteed that all
>>> memory operations are finished.
>>
>> I'm pretty sure spin_lock() is an "acquire" barrier, which just guarantees
>> loads/stores after the spin_lock() are done after taking the lock.
>>
>> It doesn't guarantee anything about loads/stores before the spin_lock().
>
> Right, but comment says memops should be flushed before the
> list is changed.

The comment says that the _above_ stores should be seen before it
appears on the list, it doesn't say anything about the list itself. What
matters is that the ->seen/pending must be fully visible before it
appears on the list. A spin_lock() doesn't guarentee that, and the bdi
thread could even see the work before the spin_unlock() is started.

-- 
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