Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1376905ybl; Fri, 16 Aug 2019 13:59:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqywCe9+Gnvv9Hgri+dpzYvuczZiNu2Gq/d6gzZx0UZ6BfuiR0mSgG6tfsjN0otzk66TrMTY X-Received: by 2002:a62:642:: with SMTP id 63mr12686829pfg.257.1565989149017; Fri, 16 Aug 2019 13:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565989149; cv=none; d=google.com; s=arc-20160816; b=pd5xHM0UxYwqQCJzfcx9ol9jFxm7ihndTbC6xkuteOKORcv5s3h2I4JJerpRWsLw98 opY/b08+sijj/t1EU8OA7qePPrGd/JGx2gxI+dhpY+gcFyVqLQ4ZJ3IPoNn8rd+COOQ8 NjbS5Mx91pK88zM98Q89iCPgdjJXZea/yGTj644Yg8qSVeS1pxYHm6uEMybZKGpd+S5s omh04EulGYpoZKevcMrycm1dfR+9DHAT+0m00nriOBFfX/rszdk0lftwCX/ibR0/B383 MCEiky99jzVlf+iPWmnLJfBfQhjualAz0tpoubjmgTMZAL8ej6Ed9ExElf0nrDHryYSn uFDQ== 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=BrykIQptEr5uG2ppILJEV/PA8/ETiDoByQ19l2TgJ8w=; b=DCOrdw0M1AnCHAn1iYFEPRdzGySegmVuDhODUgv8smHCqmXdO6xHg1rCFmPiSx9LTk cbkhG9UJIHqVuOqCQfEOo2OLVMHEZvSDN58+DItDRVFTfy3r5dxI3Qpt3wKFCUNiSMsO bu0Wh1VkknluiBagTg8EJhKz+yFL1iQhQLlGhemvQeC/VoSP608fdI2daWGMPVnfXmIR 6KOzgXTEL9MmXssxBrvoIN7SLqND3jVN77y73v+tXDkbJxD67dY8Y0h08q/IhSkrpSe/ y6fFvLwXFmJCOl0iYu2Skyn5VAhhP2oOnqpmYJxT5MVb+7cBeKpXhz+uX22DDOAZYbkc NTTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=w2hQUmQ2; 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 x24si4627617plm.358.2019.08.16.13.58.52; Fri, 16 Aug 2019 13:59:09 -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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=w2hQUmQ2; 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 S1727708AbfHPU57 (ORCPT + 99 others); Fri, 16 Aug 2019 16:57:59 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42815 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727548AbfHPU56 (ORCPT ); Fri, 16 Aug 2019 16:57:58 -0400 Received: by mail-pf1-f193.google.com with SMTP id i30so3700994pfk.9 for ; Fri, 16 Aug 2019 13:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BrykIQptEr5uG2ppILJEV/PA8/ETiDoByQ19l2TgJ8w=; b=w2hQUmQ2uCA4bsTeqtI4e/zAXtzZY+2GTQpvsj4kSYdNqKLA1cJCjyu3WSGdflzw8X zgs71DMZYr0B/6uDfrewd68czoxM+No49TBIG6SHn9jgHnRsZjoqwiYUVjwj6R99lV1+ HecLABQVbF/pxL3j1+W4n2jB+0Dh3stE/rTcQ= 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=BrykIQptEr5uG2ppILJEV/PA8/ETiDoByQ19l2TgJ8w=; b=RqvUdGo0SzDidHQ0RKkJeX4+jpwWcOLKSaEh2xp67fKPN6rh/w0kmsTlCYI5Gl78WS RiT/IvWg+IiTiYBzxqdcu2LQxEmrNDa5o1N36b2RjomdgMmjT/aVWpa113jbTyPGZwbE 33fOMEo1V6IcBlN71/dRi2cFCWQ27kB//UjZs0rPUSUY/gO+t2LwYHa3mh1ulcUDjvsu BxTZA2bohkU7HPWKxmq7vJQFEOOfC66nfc0OytFZaYXyr4wfT7lsUzaEhonRxlxuiQio 3VGa8+lhWcVpwqy1D9qz3o1bhitKKFfdTIX8x2YdzxXydS1v9n51OS3Q1FyKeBUHhPRE ld3g== X-Gm-Message-State: APjAAAV1vaCVB9P0Z+YBWNXkgZq5fdhNIQfNxw8omXBrdMYERdb4CbIY d0e1UxeXQu480cUpt1twHqdsHA== X-Received: by 2002:a65:4489:: with SMTP id l9mr9620185pgq.207.1565989077931; Fri, 16 Aug 2019 13:57:57 -0700 (PDT) Received: from localhost ([172.19.216.18]) by smtp.gmail.com with ESMTPSA id c13sm8110467pfi.17.2019.08.16.13.57.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2019 13:57:57 -0700 (PDT) Date: Fri, 16 Aug 2019 16:57:40 -0400 From: Joel Fernandes To: Thomas Gleixner 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 Message-ID: <20190816205740.GF10481@google.com> References: <241506096.21688.1565977319832.JavaMail.zimbra@efficios.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 16, 2019 at 10:49:04PM +0200, Thomas Gleixner wrote: > 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. Really? That is quite scary that you are saying half of the kernel has issues with concurrent access or compiler optimizations. It scares me that a concurrent access can tear down a store/load and existing code can just fail, if that is the case. > Can we finally put a foot down and tell compiler and standard committee > people to stop this insanity? Sure, or could the compilers provide flags which prevent such optimization similar to -O* flags? thanks, - Joel