Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1370551ybl; Fri, 16 Aug 2019 13:50:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxB+VnhAmWRyBgsKO1f7sG7vWmmkM5wkdWE2j/B3aMsKzoLA6LTh+V8V51cfU2Ikv5pL4gt X-Received: by 2002:a63:eb51:: with SMTP id b17mr9068777pgk.384.1565988638280; Fri, 16 Aug 2019 13:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565988638; cv=none; d=google.com; s=arc-20160816; b=ts4mpL3YHwwo6nmQVEhew72NiC0mXZP3WUf+RGy5kfmuDHzop6uEeaSTDlz54ezFRx IrYTsftZePdd1tpvvZUo+rUiPhrBB/zzPkADsFuZcTGxj3tYtA0M7Zyns/ex6Fvgwr/c Y4wWE9uNJtfXtrDZiH7kaMU3aYe4+77/z/EDQje3NBzcvDgf+3GqPTo/ssN8GtoSxYEn l8Q+CzwWwI9stmwm39Yf4iS2gV2+xLFV+JeAn/CDeNHi2kf1yKjw+Zt7ODXFme0/+4yq bwGKL84ui0PpLG3E1FJgpyl34i4bHmyjUjGHcxOaFZELXi3mRxa/xRNcGoQUr0/mpcKh c39w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Ggyn8U7YpkDXuHIi6fiqRGM555hI6lM5gYDSM7ZCr6g=; b=SJ1eC7DsPI5vaHd8oMNCPeRw5xJvXIMKzpIbJKweW+qD7gIxRQqdDsobTbkq9PZMTc vP4sUAKfrH2T6tTxV8sfWXzz1pZ+3bP2De6D24Jeai7ch2ZeZb2xQhgamiMKw00QNoJ9 2tZuvltLYQde6hpGx4r7QCoPfBM54/UX8la0muAWLsxUbENN0K1gbnlcdwB8Fe8IkHuD qerU/XNoz1QESHoT6/PzcWjpQgESsr0AslJ/xvCaftOTJjWe5Fo5kQN73GNfZiX+i2xs joO7MCRlG8Rzy2ydAbI5PB5NfpIAxnyi+WDALEPdljR/yAVlMOIkMiJ9m0Yj0tEh+s9Z kl7w== 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 h3si3634077pjq.21.2019.08.16.13.50.22; Fri, 16 Aug 2019 13:50:38 -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 S1727686AbfHPUtU (ORCPT + 99 others); Fri, 16 Aug 2019 16:49:20 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43178 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727655AbfHPUtT (ORCPT ); Fri, 16 Aug 2019 16:49:19 -0400 Received: from pd9ef1cb8.dip0.t-ipconnect.de ([217.239.28.184] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hyj9l-0000JK-Q7; Fri, 16 Aug 2019 22:49:05 +0200 Date: Fri, 16 Aug 2019 22:49:04 +0200 (CEST) From: Thomas Gleixner To: Joel Fernandes cc: Alan Stern , Mathieu Desnoyers , rostedt , Valentin Schneider , linux-kernel , Peter Zijlstra , paulmck , Boqun Feng , Will Deacon , David Howells , Linus Torvalds Subject: Re: [PATCH 1/1] Fix: trace sched switch start/stop racy updates In-Reply-To: Message-ID: References: <241506096.21688.1565977319832.JavaMail.zimbra@efficios.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 16 Aug 2019, Joel Fernandes wrote: > On Fri, Aug 16, 2019 at 3:19 PM Alan Stern wrote: > > On Fri, 16 Aug 2019, Mathieu Desnoyers wrote: > > > > > If you choose not to use READ_ONCE(), then the "load tearing" issue can > > > cause similar spurious 1 -> 0 -> 1 transitions near 16-bit counter > > > overflow as described above. The "Invented load" also becomes an issue, > > > because the compiler could use the loaded value for a branch, and re-load > > > that value between two branches which are expected to use the same value, > > > effectively generating a corrupted state. > > > > > > I think we need a statement about whether READ_ONCE/WRITE_ONCE should > > > be used in this kind of situation, or if we are fine dealing with the > > > awkward compiler side-effects when they will occur. > > > > The only real downside (apart from readability) of READ_ONCE and > > WRITE_ONCE is that they prevent the compiler from optimizing accesses > > to the location being read or written. But if you're just doing a > > single access in each place, not multiple accesses, then there's > > nothing to optimize anyway. So there's no real reason not to use > > READ_ONCE or WRITE_ONCE. > > I am also more on the side of using *_ONCE. To me, by principal, I > would be willing to convert any concurrent plain access using _ONCE, > just so we don't have to worry about it now or in the future and also > documents the access. By that argumentation we need to plaster half of the kernel with _ONCE() and I'm so not looking forward to the insane amount of script kiddies patches to do that. Can we finally put a foot down and tell compiler and standard committee people to stop this insanity? Thanks, tglx