Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3697235ybi; Sun, 2 Jun 2019 21:19:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7scuB0VTXSOvGBpR4W1nyGzmZgy+t6+Pbrnjn3vvAUyord0x++dif+Z+9hzXaImaFcJZZ X-Received: by 2002:aa7:8f22:: with SMTP id y2mr28211403pfr.22.1559535592494; Sun, 02 Jun 2019 21:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559535592; cv=none; d=google.com; s=arc-20160816; b=GSsAwNyb6WWa5Vz7cjxVaf8phXf6zVOdQnuneHLz5qveGifbrP5SbMAHrcReA387p9 5pLGISAQnIKGxdVYQ86jHYDtKjMGAgzmfvRUycom7ectySM5VdGsuAl1xAGrC69foYFs 5mfNNSbRA3GsM1i99UtISfNJnR5pVa/8GNTmPrVEBnbvWT2qt/KUt/L7yW3R0JhRRmX0 3y/I/6g1MKrWmUTEolhP+ER4+QS9NvVvrRF8AvRJ4f0rBe8GZ/3V8QB9B9cNf6IOmGwd F435Ca2pj5rzjYzTO3lgL+Z3mZRQrnO1f4p793cVp9iy2PbFff+7qZwWCClXxpAsXy9E P9aA== 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; bh=Pgkn9fXQOOKoE3Ah0L57zY7Y0qhPbJkzxRZvsh6LxGo=; b=GNSmN+1QJvXXaxek368ca9B4sTu3/JtQhGIPH33PVA43mGarPryhEyjf1fmaMTVlAd WtS2koCpOb6P42WTqlGws/ichS967v5/clwPcCkV/6JqbllqBZlZmCesq7m+JYCsGE+T iFb9BbG6us8+9W6QFoPMBpfrdlhkUUm8iTbPoQO+5Lxjoq/zUT8esoJCKh1ZLzVXWLhO s7CN5B4ow616PX0gZacMs/nuWU6bKQAr5hAcr7jt2kzv6V4A/6981NNBnc2pMbwflQoA NFDf5i4xXA9/BAnBelfEkchZeDjW6dcI05KMdgdQd+m7UVSyFhBclitO7ZQmw6Qt0Qio 5ZDQ== 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 e13si16717360pgi.176.2019.06.02.21.19.36; Sun, 02 Jun 2019 21:19:52 -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 S1726660AbfFCERp (ORCPT + 99 others); Mon, 3 Jun 2019 00:17:45 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:48338 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbfFCERp (ORCPT ); Mon, 3 Jun 2019 00:17:45 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1hXePg-0000Ph-O8; Mon, 03 Jun 2019 12:17:36 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1hXePb-00028Y-Ix; Mon, 03 Jun 2019 12:17:31 +0800 Date: Mon, 3 Jun 2019 12:17:31 +0800 From: Herbert Xu To: "Paul E. McKenney" Cc: Linus Torvalds , Frederic Weisbecker , Boqun Feng , Fengguang Wu , LKP , LKML , Netdev , "David S. Miller" Subject: Re: rcu_read_lock lost its compiler barrier Message-ID: <20190603041731.m6rvcaivgeh4iw4g@gondor.apana.org.au> References: <20150910102513.GA1677@fixme-laptop.cn.ibm.com> <20150910171649.GE4029@linux.vnet.ibm.com> <20150911021933.GA1521@fixme-laptop.cn.ibm.com> <20150921193045.GA13674@lerouge> <20150921204327.GH4029@linux.vnet.ibm.com> <20190602055607.bk5vgmwjvvt4wejd@gondor.apana.org.au> <20190603024640.2soysu4rpkwjuash@gondor.apana.org.au> <20190603034707.GG28207@linux.ibm.com> <20190603040114.st646bujtgyu7adn@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603040114.st646bujtgyu7adn@gondor.apana.org.au> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 03, 2019 at 12:01:14PM +0800, Herbert Xu wrote: > On Sun, Jun 02, 2019 at 08:47:07PM -0700, Paul E. McKenney wrote: > > > > CPU2: if (b != 1) > > CPU2: b = 1; > > Stop right there. The kernel is full of code that assumes that > assignment to an int/long is atomic. If your compiler breaks this > assumption that we can kiss the kernel good-bye. The slippery slope apparently started here: : commit ea435467500612636f8f4fb639ff6e76b2496e4b : Author: Matthew Wilcox : Date: Tue Jan 6 14:40:39 2009 -0800 : : atomic_t: unify all arch definitions : : diff --git a/arch/x86/include/asm/atomic_32.h b/arch/x86/include/asm/atomic_32.h : index ad5b9f6ecddf..85b46fba4229 100644 : --- a/arch/x86/include/asm/atomic_32.h : +++ b/arch/x86/include/asm/atomic_32.h : ... : @@ -10,15 +11,6 @@ : * resource counting etc.. : */ : : -/* : - * Make sure gcc doesn't try to be clever and move things around : - * on us. We need to use _exactly_ the address the user gave us, : - * not some alias that contains the same information. : - */ : -typedef struct { : - int counter; : -} atomic_t; : : diff --git a/include/linux/types.h b/include/linux/types.h : index 121f349cb7ec..3b864f2d9560 100644 : --- a/include/linux/types.h : +++ b/include/linux/types.h : @@ -195,6 +195,16 @@ typedef u32 phys_addr_t; : : typedef phys_addr_t resource_size_t; : : +typedef struct { : + volatile int counter; : +} atomic_t; : + Before evolving into the READ_ONCE/WRITE_ONCE that we have now. Linus, are we now really supporting a compiler where an assignment (or a read) from an int/long/pointer can be non-atomic without the volatile marker? Because if that's the case then we have a lot of code to audit. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt