From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-f67.google.com ([209.85.208.67]:44968 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727212AbeK0Duz (ORCPT ); Mon, 26 Nov 2018 22:50:55 -0500 Received: by mail-ed1-f67.google.com with SMTP id y56so16432636edd.11 for ; Mon, 26 Nov 2018 08:56:14 -0800 (PST) Date: Mon, 26 Nov 2018 17:56:06 +0100 From: Andrea Parri To: David Howells Cc: gregkh@linux-foundation.org, Kiran Kumar Modukuri , viro@zeniv.linux.org.uk, sandeen@redhat.com, linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] fscache: Fix race in fscache_op_complete() due to split atomic_sub & read Message-ID: <20181126165606.GA11282@andrea> References: <20181017164848.GA9795@andrea> <20181017151134.GA8966@andrea> <153978619457.8478.3813964117489247515.stgit@warthog.procyon.org.uk> <153978621809.8478.2198040871218302573.stgit@warthog.procyon.org.uk> <14408.1539790333@warthog.procyon.org.uk> <26942.1543249596@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <26942.1543249596@warthog.procyon.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Nov 26, 2018 at 04:26:36PM +0000, David Howells wrote: > Andrea Parri wrote: > > > > > > Fix this by using atomic_sub_return() instead of two calls. > > > > > > > > Seems a case for atomic_sub_return_relaxed()... why not? > > > > > > Ummm... In that case, should it be atomic_sub_return_release()? > > > > Hard to tell for me: your diff./changelog is all I know about fs-cache > > ... (and this suggests -no-, given that atomic_sub() and atomic_read() > > provide no ordering...); good question though. ;-) > > Yeah, that doesn't mean that it shouldn't be stricter than 'relaxed'. It's > kind of like an unlock/release operation, so I think 'release' is probably the > minimum requirement. Sure. My point was: those operations are currently not atomic _and_ they provide no ordering; I think that the above commit message does a good work in explaining *why* we need atomicity, but can't say the same for the memory-ordering requirement. Andrea > > David