Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp146425imu; Mon, 26 Nov 2018 09:03:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wo1AVRrHXFhVPRAxrxjZ9QKOY2HE3tDeTzChDXn3Kk6lRGPsi+DO2U9pPFWKJ5UT3TlmsF X-Received: by 2002:a63:314c:: with SMTP id x73mr26000971pgx.323.1543251785820; Mon, 26 Nov 2018 09:03:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543251785; cv=none; d=google.com; s=arc-20160816; b=E36kWx2kYU+CpzJUCsLb/X74/1rpxpMTUEHY6ijRZXqb3vFCX/bcEQ4UXIhc4XOXww oy+0h+F9N0jnhof33ID47CUaaKrxOsKZMzl+GIn0meadgK+abfxO5tIvX7ta6yyiS5KD 6IxeBWgjNEUBC+y15ckbR32YeRzsPxIbnid1T2ZteebKi5vCjaTJLR9MKmyjVYioKMee pf/6CRTyr8x6KO9RSB7k65jpjeHPYYW8I+xRQHSBZ3n0POAvRBNs3UJoXRVrWYJ9Zc5z cGuFLR/74AVS9txoURVkVQNpoBjBkMkQGb2XlihKmrbiDM8OBSzacUHAdVwST3qvnx3L PuKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4TU5EWPLOJUD/AgePTOjqipP72/q085XlRhrOSgBK8s=; b=070XYcLDLsJtIIqpC/1Epg8HEFS3G43Ie6UG8JLaQSAwAv2uTZjadaTb/EB0d1h9wk 0laGAz2Qt88yNfCXG8w4vH6wFX2C9aIe63Y7zWXJHKQAWk9TFuV4ith6nj6Gsr7RhgVe YMDdv4CnKi3Z5/4cDmaMpBbrAfpRHzXt3BIVSGTbNqmArKnkJDsXBz6ETmk5ucnigOa0 rR6nmWH1w6kXCdOzSXaBOGXSaJlgPibkPhMphBYh5E57jLYuSfX2sve2VX4qe9g56PbE xU1w9gvaWvt5OKTjvke0R2eFOvObEX9CeT3P+4OZ1Aq48v389UDT2ZLcB9o433muKUOp fotQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kK5e3xKN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r197si933135pfc.116.2018.11.26.09.02.07; Mon, 26 Nov 2018 09:03:05 -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; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kK5e3xKN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727230AbeK0Du4 (ORCPT + 99 others); Mon, 26 Nov 2018 22:50:56 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:35949 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726266AbeK0Duz (ORCPT ); Mon, 26 Nov 2018 22:50:55 -0500 Received: by mail-ed1-f65.google.com with SMTP id f23so16478601edb.3 for ; Mon, 26 Nov 2018 08:56:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4TU5EWPLOJUD/AgePTOjqipP72/q085XlRhrOSgBK8s=; b=kK5e3xKNjI2JbVfgXMIsWGyfvbH8ewTUKTBN955C3hZPlUTNRSQvhLBf6XljfFTOzw rPnxHc4Quqcx5hfFC22JefFAElMTcpU0fg5OurIEsYouyD1zHoITbUY21XM71DZWQSRJ UE5HTjTpu21G9KmRfpsI/Wh2QWZ6btP47xzTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4TU5EWPLOJUD/AgePTOjqipP72/q085XlRhrOSgBK8s=; b=LnBu+y2PNFnGaPoyb3zILla2H/rGQQxdXzoYcMtVjFYMQiEAUTGSNgN5YQ5DB8vRbv bFcX5pj/+bIk6L+AHKZFu0O43BrxY8Lc/Tj7mnX3Q4610OSADIZgWkeWtQnN8acxEA6c rJi3FT5E0NKxlyWOSBPtOdSExei4anXU2QTM+vWUfv/RzpcricTj6bdl4WhGC9urVE5H xRNTodveOgDcttYeOfjdDkd/KP6V7ZytW9XOww2M6zRUxB8yv08oAYuhYJaydJ46pLw9 o8FROClWNV/ao5ljhHeZUhO918VQOMKbYMekC5PN9XsU4iM0qet767IZz3joVssEHK3+ K91Q== X-Gm-Message-State: AA+aEWbwSIr0z1s6Q/64hRTi1BxU/fzo5NgMMa9GOAXHKM0rm0wPTSj6 rWDDfp3e8wKaH/zXTuNug/ZFEEfQ06zgOw== X-Received: by 2002:a50:ae8f:: with SMTP id e15mr24319787edd.250.1543251373294; Mon, 26 Nov 2018 08:56:13 -0800 (PST) Received: from andrea (85.100.broadband17.iol.cz. [109.80.100.85]) by smtp.gmail.com with ESMTPSA id n11sm315974edn.14.2018.11.26.08.56.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Nov 2018 08:56:12 -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> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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