Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1948106ybb; Fri, 29 Mar 2019 14:54:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyeKVvqnoDLPUjCdTX86mzIPDUrmTkMMr817yJofEDK3Vqfavqid7EHBVq8gRahSMqqu7Vc X-Received: by 2002:a17:902:7590:: with SMTP id j16mr16095268pll.98.1553896444450; Fri, 29 Mar 2019 14:54:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553896444; cv=none; d=google.com; s=arc-20160816; b=aLiqCm7ktCx6m91xl/22FsNkssOG3dEv8JUYb1qrYmhFDE8LVR3591Lagxv6vSQk1S wRwEXfwv8JaRQmaRCKHoIQDonuq3cPpjissUeV3bT5DtI24r8mgLue3qa09gh8dypYZK qKRFA3WR6mpPQJPWzIwTNEKXj9BOpDtJBap0m1ADqwe9KGLQ1ncKxHin5jdLTVLR2MGz I+N6rhrU9bLxliU1/fUAOE3XjzBFO7iOw1Eyrx7dze9HaPx7Q25hxH49qZ9P0ofl4tPK yHF286LNEcMqEZuz0Vw8je1huoQdqKdgmLLgnexKDSVtGRLyqDFCs8xPr3MzfQYp2VhN 4dPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/AroANKFk+OqiRnE8XTOlngqffSbY1uCpEuZKu1hL1k=; b=03jQM2g9scJT1wafo70QSHExK7QKuLFzbsZsRQjgpgc6bRpxncbgaggLSCfsC8V4UT lQ2TuXo2f7AuAR057h5E0KwK7/fP3BnTm9VRlS5zyWJDmzqfxGUabOvEdd0jEkONmYH6 a9efVVI+uGbPXYR7uE36xm5uJ6ab7jT0mMKpvgx0oXtswacS+Y3LGIYJ3If+uy0Hee+W gAMZxItQUJpYpsKdRto4Du5WoiQJXACCr3Hkt8UTHJrvADH97C/cd3KRa43/uFkyROZU WkjQ/bNe7L8fBvPXeCUdlcO21ZdQuni7tlvw0YIikBy2A8LXAhimyEX5gWIDNv+Zqm7i x67w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si2764091pgo.80.2019.03.29.14.53.49; Fri, 29 Mar 2019 14:54:04 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730367AbfC2Vvr (ORCPT + 99 others); Fri, 29 Mar 2019 17:51:47 -0400 Received: from terminus.zytor.com ([198.137.202.136]:60207 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730108AbfC2Vvr (ORCPT ); Fri, 29 Mar 2019 17:51:47 -0400 Received: from tazenda.hos.anvin.org ([IPv6:2601:646:8680:2bb0:e269:95ff:fe35:9f3c]) (authenticated bits=0) by mail.zytor.com (8.15.2/8.15.2) with ESMTPSA id x2TLpVp73962284 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 29 Mar 2019 14:51:31 -0700 Subject: Re: Potentially missing "memory" clobbers in bitops.h for x86 To: paulmck@linux.ibm.com Cc: Alexander Potapenko , Peter Zijlstra , Ingo Molnar , LKML , Dmitriy Vyukov , James Y Knight References: <20190328162222.GO4102@linux.ibm.com> <8e32ab34-c14c-1ccb-76f9-0dcd729a0ef6@zytor.com> <20190329210918.GZ4102@linux.ibm.com> From: "H. Peter Anvin" Message-ID: <8092b8aa-bb1c-0266-b308-5cebfb25e2ef@zytor.com> Date: Fri, 29 Mar 2019 14:51:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190329210918.GZ4102@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/29/19 2:09 PM, Paul E. McKenney wrote: >> >> Note: the atomic versions of these functions obviously need to have >> "volatile" and the clobber anyway, as they are by definition barriers >> and moving memory operations around them would be a very serious error. > > The atomic functions that return void don't need to order anything except > the input and output arguments. The oddness with clear_bit() is that the > memory changed isn't necessarily the quantity referenced by the argument, > if the number of bits specified is large. > > So (for example) atomic_inc() does not need a "memory" clobber, right? > I don't believe that is true: the code calling it has a reasonable expectation that previous memory operations have finished and later memory operations have not started from the point of view of another processor. You are more of an expert on memory ordering than I am, but I'm 89% sure that there is plenty of code in the kernel which makes that assumption. -hpa