Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1366685ybl; Fri, 16 Aug 2019 13:45:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSHgUlfE0BD8CSVVjKULAcYoa9y3jVoEy0GlyHuXyICzIMqOGHR0jOdOAptGb28FM59WVp X-Received: by 2002:a17:902:a606:: with SMTP id u6mr10980570plq.224.1565988314100; Fri, 16 Aug 2019 13:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565988314; cv=none; d=google.com; s=arc-20160816; b=xKK20aG1qqz2gtx39B6G/DgUMHUp7BKuidAf4lskUhQUM1uDPS+ZMNdZeWUtcD9mvZ uoy/4YzMPrxv7weBPL9JCBAEvMDlFYd4tDbWjNUUSj97ZoB77ib+bOeSzaCcYu4zh2g5 g5I4x6VSSWEal2ddeSbmDe+yIujE5lyla637vr5gyFiQAt34teYxRqem+46+l34fYrL6 DTABj7hoZTJM5kQw63f8JW3DucXhSXPKtUy4O4DWIjiUww9PfeLyF2bbSg3idX+5Wffu kavX0RNPJduE47Iczn5LqcqDLPawKpC6KrLBrqryHBXjSEZoSojT+qOD9PEGYlxr91sB S2Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2zJNFFtYFNXNppnrKTHuhLPDf9LLLnIdunHZPTN7U0E=; b=a9dIXyPB8Mmmm5upPbdYqUHbwD2N+GeoAxQdjv3V4EP6fs3GtF6j3IxSIQaMEf+GMm yDjj8B8s7hAoO5MM2hedzUcqYMyYAaylQfEGqsY7MFN80UUwGsCjueSFPpsXxNfEHiVE 6xFPWDWt2BgiKrwxKqCDDiznuXnGKAvhyrvz3m+mLgu/1XxuEJ3gfR8UC28t1lOg3qGQ Akyeci195C6MR8LdZjTEs8RqTMG0qJb+90ujPwjuTjWZ5Jf5kVYckTfcT28tSZpOmzx0 2M984IHV7xvY9AryIQkE+VY9lxgZ8B8VrU6bFRonqJP7r9m1TT3K7IKNGnSQosjIdimN BP1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=yGyN6OAQ; 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 x3si4707284plv.422.2019.08.16.13.44.58; Fri, 16 Aug 2019 13:45:14 -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=yGyN6OAQ; 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 S1727637AbfHPUoY (ORCPT + 99 others); Fri, 16 Aug 2019 16:44:24 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38396 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727548AbfHPUoY (ORCPT ); Fri, 16 Aug 2019 16:44:24 -0400 Received: by mail-lj1-f193.google.com with SMTP id x3so2360738lji.5 for ; Fri, 16 Aug 2019 13:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2zJNFFtYFNXNppnrKTHuhLPDf9LLLnIdunHZPTN7U0E=; b=yGyN6OAQ4+vDjcA3DW21wfSQ3vjKHsDR9f0UHXWRd5/JGrX2jSpx0zvTDP9qscz8In IbzHO6FioxQlc7vpXnWhwDBCqQSWQ5FUeQv+4GGWPOKonV9RqsMO/kXtuUdrWLZx9wfe gfY9DET1ZiJMEmOqH8OB/bkJi/PdOpXJ/p6Q0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2zJNFFtYFNXNppnrKTHuhLPDf9LLLnIdunHZPTN7U0E=; b=qeS73WuBN2rO4Zh98xjV5wVjnGV68VtKGhCeAO6f9qB85nP52n51/EjgTpJgu4OieJ WzvQ1pIe/09IxYjEh0ArZLPN1AovgNF5whK6GIfluA4KaF9LFJFH/2cFlf9tyh2tqyF/ nWxGsKoN2106X8Ei921eLgiPeGto/aieH8iTClmdI3D1j3682LuMpMDKhHnvemVzI6lQ vmXbn3ljSva1kYTQkNIx2myBKjyj1fpTyP1GQVg/P9v4XPNaZPCuSH4ledq3WFss3F/F MtsUEl3/ghp9M4FyluK/RE/GfZbRbB/uHnmxxivs8EhMN3spWixHDmiN7VOqOl4qQQZj y2jA== X-Gm-Message-State: APjAAAXL36clIowgCk5TIZczFQVpN0+naqp5CnVuXZcdhDDyxL+j23QK j/zcpo/SqvV7iObjHPueD/AaPvo/50p+FOpqy/9i4w== X-Received: by 2002:a2e:a415:: with SMTP id p21mr6572955ljn.111.1565988261752; Fri, 16 Aug 2019 13:44:21 -0700 (PDT) MIME-Version: 1.0 References: <241506096.21688.1565977319832.JavaMail.zimbra@efficios.com> In-Reply-To: From: Joel Fernandes Date: Fri, 16 Aug 2019 16:44:10 -0400 Message-ID: Subject: Re: [PATCH 1/1] Fix: trace sched switch start/stop racy updates To: Alan Stern Cc: Mathieu Desnoyers , rostedt , Valentin Schneider , linux-kernel , Peter Zijlstra , Thomas Gleixner , paulmck , Boqun Feng , Will Deacon , David Howells , Linus Torvalds Content-Type: text/plain; charset="UTF-8" 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 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. Perhaps the commit message can be reworded to mention that the _ONCE is an additional clean up for safe access. thanks, - Joel