Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1239931imu; Wed, 28 Nov 2018 06:44:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/UCGABSU7wqjwSsmmy+lbhXuFgJB9Ht6DOS7EDbSzuOsASwTRpRXBzFmZSCnKMHNLoR+3ll X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr27508244plz.110.1543416294745; Wed, 28 Nov 2018 06:44:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543416294; cv=none; d=google.com; s=arc-20160816; b=LQr5LcDiI5CsF/ScadAmYLEDXYnrGUqssn8iQ3nvASmPZboS8HhVDJaRuvQydSKW2c ORn4oqYGA3ICgHQ1S2U405X/DbyrF+wwE+1QfsokjiQ/1Qyz914PFBmFLUeROqFtgv+a malk3ZNXmoqFcpRAE3rvw4IrZhGiu8gz7qSCSEj23p6xh2KESc4fQ2/glzr+0BN4Y7RC l3m+HDf/WrqE4KU/0j7n0aoKjfrzxuGPzw2PFUTtT8bNyFUeVgzqcjw44RUYqBWWnIc2 9xg+eEHhYG+Odrm2naodgnl2RZQU0LlnIUSFAlro1fRmnm83t003gkLmWgZ2m4aqSDy3 dWSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-id:mime-version :subject:cc:to:references:in-reply-to:from:organization; bh=HaGUD6QSVYr1X8XUZ7dOhzj7jYt+DQYeKe+p/M2blGs=; b=KB5f302EI0JadWQrUOen5BVzLsq4mpLACJwqPXS6zSuI/fyuzz+micen2cYeMiR5Zx gV5aXK6X1zawMzJmMPHmv6++B7b3YfsGhGvlYGjA6nz9Xvm3AgKvegK/qAVA1gLsomb8 TieIPUDfg+NePRWsEcGK+sEH4HE2U8omQyuBt3TD4UFsHq1gaJfrZfP4/mdzQa+5qFWH JasdeXcHFg3S6jl+m+6pRbtH7Vwq+ZYPMQuhGpkcFy8qY7vsOpxyNEcBShdH4bU0aIXY 7OIpx3hEGIA7Leb1rjvqpuweKTEZtRe8Wu2cyaP8eVYko4H4YcOlIzoOF5guVU5bk9i9 4aZQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si1225316plo.203.2018.11.28.06.44.38; Wed, 28 Nov 2018 06:44:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729044AbeK2Bpa (ORCPT + 99 others); Wed, 28 Nov 2018 20:45:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47247 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728619AbeK2Bp3 (ORCPT ); Wed, 28 Nov 2018 20:45:29 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 036753983; Wed, 28 Nov 2018 14:43:36 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-113.rdu2.redhat.com [10.10.120.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4291413B; Wed, 28 Nov 2018 14:43:25 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20181126165606.GA11282@andrea> References: <20181126165606.GA11282@andrea> <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> To: Andrea Parri Cc: dhowells@redhat.com, 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4282.1543416204.1@warthog.procyon.org.uk> Date: Wed, 28 Nov 2018 14:43:24 +0000 Message-ID: <4283.1543416204@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 28 Nov 2018 14:43:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Having discussed it with Paul McKenney and thought about it some more, I think relaxed is probably okay since there isn't a pair of variables that need ordering. David