Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp854019ybi; Tue, 16 Jul 2019 06:14:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7NMBJZGE8nl2JH8ljN8J1bM2c202UAHeSdNX7YDidZ5Ha4ke5OOXMKJxlKguNN46tE64x X-Received: by 2002:a17:902:2ec5:: with SMTP id r63mr34934857plb.21.1563282865901; Tue, 16 Jul 2019 06:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563282865; cv=none; d=google.com; s=arc-20160816; b=KB5RV0JI6xZ/hJSsAd5RNUwVDHNsjjQMBNdd5cxSbyDpSbncCX+j5cL/7+L8LnQBSi PcBalbMO6xmLfg7y0sLQGhE2KMEMipCmm7HiAxA7vuWQ28QsBzI0EGIxiaDoPbPvmEHj 0Y1EY3upUzsIK21HRGjJh3XQkgGmPnSrsgCybwBqiA1gifcVAWhQuDtZw82buiu9YGYk gxZz4B3IfX8H+1Mvw9Xas2gI6xIyBPUs1qRI+SP2xb2RjmsRUcFHF/KPGYd487eBLBnU zypijev6cqpBSC7ekFiVQ2KdMEUQz52mNbflGzCHvAT3nn7L7g77OwaVULsLDZ3EFS0s dX8Q== 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=AAH1VreojgrW1PY+zRgZSaa6MnAiqzOsBuEFTG16Aqk=; b=ao8fmV5oZHWiYpbVjURpDZ9iRPk85lQqZnBMbHiqz4yCzPS8fETl2rlBtPscNLXyfR /O7WsWt6iGC3OtYxzrTickgQKCiIXrFkQMWs7tE5MeXwY+xYfURMv3x+nqdQShdDMS1B MU6ZS+KHeNx0hPXh8Iceb4icrU8GQ8x590/7YFYbUHRAaHYO65X267uW5kUAnexjP3Q3 CW5MTKHHJ0wfrp78YolxS7JUdAHsfijU85gVkOezaoy0US6f02WSqlRTrGy8qDDg9iwG Zj/EUQRvyRt3SwI4U2sdX8WyP2QCipj1Q3xxDk0TG9esNVSlmRKr4ZdcYa226sygBYpP kYbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="S6QnGj/t"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 t14si14008310pgh.128.2019.07.16.06.14.10; Tue, 16 Jul 2019 06:14:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b="S6QnGj/t"; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728004AbfGPNOE (ORCPT + 99 others); Tue, 16 Jul 2019 09:14:04 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:58972 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726997AbfGPNOE (ORCPT ); Tue, 16 Jul 2019 09:14:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=AAH1VreojgrW1PY+zRgZSaa6MnAiqzOsBuEFTG16Aqk=; b=S6QnGj/tm4B+qxyyQT+qAWW40 aZQp4WvSFQCjPOC7AoBFhMQYe9OsWCa7RmEaQDuTmOi+QDhTHKYuxnrOlBfAM4onqLGyA79Ge3KcE hwKh8kc+Mal+LHfcHGxZSsh+wjpxf57Bbfjt+q+Qy1b/CG1J8oEBFOirJJ0X7i1KPH6uBdQGpzcqj 2ocfKQtRsVrKR97Ov8LEslFlYYzQqFT5KVCTTnQ4I2t1Qg6wicsokuDXsDZN/Ob4bjYtEvNW5ZUWZ TcVWtfIP6hClILfhVLwRcCVV+PFUYp6IcX4TWDUkt8zzlQIxQxcRrKF+5kNkCmEvRKqr0PS+jdYRz gBTP4StUw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hnNHE-0001pN-0O; Tue, 16 Jul 2019 13:13:52 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4BCDA20B172CB; Tue, 16 Jul 2019 15:13:50 +0200 (CEST) Date: Tue, 16 Jul 2019 15:13:50 +0200 From: Peter Zijlstra To: Andrea Parri Cc: Daniel Jordan , Steffen Klassert , Herbert Xu , boqun.feng@gmail.com, paulmck@linux.ibm.com, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, will@kernel.org Subject: Re: [PATCH] padata: use smp_mb in padata_reorder to avoid orphaned padata jobs Message-ID: <20190716131350.GA3402@hirez.programming.kicks-ass.net> References: <20190711221205.29889-1-daniel.m.jordan@oracle.com> <20190712100636.mqdr567p7ozanlyl@gondor.apana.org.au> <20190712101012.GW14601@gauss3.secunet.de> <20190712160737.iniaaxlsnhs6azg5@ca-dmjordan1.us.oracle.com> <20190716125309.GA10672@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190716125309.GA10672@andrea> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Tue, Jul 16, 2019 at 02:53:09PM +0200, Andrea Parri wrote: > C daniel-padata > > { } > > P0(atomic_t *reorder_objects, spinlock_t *pd_lock) > { > int r0; > > spin_lock(pd_lock); > spin_unlock(pd_lock); > smp_mb(); > r0 = atomic_read(reorder_objects); > } > > P1(atomic_t *reorder_objects, spinlock_t *pd_lock, spinlock_t *reorder_lock) > { > int r1; > > spin_lock(reorder_lock); > atomic_inc(reorder_objects); > spin_unlock(reorder_lock); > //smp_mb(); > r1 = spin_trylock(pd_lock); > } > > exists (0:r0=0 /\ 1:r1=0) > > It seems worth noticing that this test's "exists" clause is satisfiable > according to the (current) memory consistency model. (Informally, this > can be explained by noticing that the RELEASE from the spin_unlock() in > P1 does not provide any order between the atomic increment and the read > part of the spin_trylock() operation.) FWIW, uncommenting the smp_mb() > in P1 would suffice to prevent this clause from being satisfiable; I am > not sure, however, whether this approach is feasible or ideal... (sorry, > I'm definitely not too familiar with this code... ;/) Urgh, that one again. Yes, you need the smp_mb(); although a whole bunch of architectures can live without it. IIRC it is part of the eternal RCsc/RCpc debate. Paul/RCU have their smp_mb__after_unlock_lock() that is about something similar, although we've so far confinsed that to the RCU code, because of how confusing that all is.