Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp697340ybl; Sat, 17 Aug 2019 08:45:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOdMTnz5jQudc/dQ1uoWT2tAvyaI23XxYq3iGxr4iGYh4/oiBPeNMzaia4FW2YNhDF5SEL X-Received: by 2002:a17:90a:c20e:: with SMTP id e14mr13119095pjt.0.1566056715776; Sat, 17 Aug 2019 08:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566056715; cv=none; d=google.com; s=arc-20160816; b=uozotP2VfNgBgQrBBy2ZormIPa+KFriuU4+BdVkXSPXRG/krlc+q0by6S26cXgdr+b rlyZDBHOFJDEtlSuyoRLh1gHVVKVqtl8r+Q2Fmfw2oimoGoFJJkOHv7YiRu9woFIfOhV BdY6gWnqdla0Fx7E4NsrvGtlp6XWShh3+yh1y5RdClK10JorKB/VaitdxB2E2rNrIhAd /NQDJiJ2Ymawz6CjYjgAKCyVgFDZAxePmHJWf1gfYOB5N9Bx95fI3Idm+6VPfUPf3jK0 f0mWtzb5xzPwBnZwEBfdHmcJF0WQmT+AuwMGq56cFid4ma0lkgaB1igRXgW9pdGHx2Qs 97hQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=aSk5IjjFtYHWu+X5wTmuqq0Cw6LDjmOIym2C0LBGB3M=; b=KLCnhx0f/tceQbE//vdpDYi1I9BIX0bxhafGecWLQVfOGrGwtUBJVpzuxfP1Zq9l8x EaU/VkKZAYeQ5HzGRDehveAM9arrS4yGH4tApxGR3R/ya69jkmqsyzQ+2ADQFbNq482J XIQsmy5b4RbziON7jmo9EnJgdjXgGwjzSiVoYCgzptOOgqU7MmxZnzh1l8qE8M2UKj+f jyDdOmgzxD4Jv4evhJ6qBU8hxGTyWYcDDSKqoCEkENVdNFgImsioP4B8oUXYIKM16zh9 Uuq7XHVEGHA6gp5b0yEbkU7xYHHYMGdeJBi8YtvRgKdjBaJApakaP2cBMg4bhkOXoRxn wMdA== 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 y5si5254267pjv.25.2019.08.17.08.45.01; Sat, 17 Aug 2019 08:45:15 -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 S1726194AbfHQPmc (ORCPT + 99 others); Sat, 17 Aug 2019 11:42:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:48938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725832AbfHQPmc (ORCPT ); Sat, 17 Aug 2019 11:42:32 -0400 Received: from oasis.local.home (rrcs-76-79-140-27.west.biz.rr.com [76.79.140.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0B9FF2189D; Sat, 17 Aug 2019 15:42:31 +0000 (UTC) Date: Sat, 17 Aug 2019 11:42:18 -0400 From: Steven Rostedt To: Mathieu Desnoyers Cc: linux-kernel , "Joel Fernandes, Google" , Peter Zijlstra , Thomas Gleixner , paulmck , Boqun Feng , Will Deacon , David Howells , Alan Stern , Linus Torvalds Subject: Re: [PATCH 1/1] Fix: trace sched switch start/stop racy updates Message-ID: <20190817114218.5cb3912b@oasis.local.home> In-Reply-To: <621310481.23873.1566052059389.JavaMail.zimbra@efficios.com> References: <00000000000076ecf3059030d3f1@google.com> <20190816142643.13758-1-mathieu.desnoyers@efficios.com> <20190816122539.34fada7b@oasis.local.home> <623129606.21592.1565975960497.JavaMail.zimbra@efficios.com> <20190816151541.6864ff30@oasis.local.home> <621310481.23873.1566052059389.JavaMail.zimbra@efficios.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 17 Aug 2019 10:27:39 -0400 (EDT) Mathieu Desnoyers wrote: > I get your point wrt WRITE_ONCE(): since it's a cache it should not have > user-visible effects if a temporary incorrect value is observed. Well in > reality, it's not a cache: if the lookup fails, it returns "<...>" instead, > so cache lookup failure ends up not providing any useful data in the trace. > Let's assume this is a known and documented tracer limitation. Note, this is done at every sched switch, for both next and prev tasks. And the update is only done at the enabling of a tracepoint (very rare occurrence) If it missed it scheduling in, it has a really good chance of getting it while scheduling out. And 99.999% of my tracing that I do, the tasks scheduling in when enabling a tracepoint is not what I even care about, as I enable tracing then start what I want to trace. > > However, wrt READ_ONCE(), things are different. The variable read ends up > being used to control various branches in the code, and the compiler could > decide to re-fetch the variable (with a different state), and therefore > cause _some_ of the branches to be inconsistent. See > tracing_record_taskinfo_sched_switch() and tracing_record_taskinfo() @flags > parameter. I'm more OK with using a READ_ONCE() on the flags so it is consistent. But the WRITE_ONCE() is going a bit overboard. > > AFAIU the current code should not generate any out-of-bound writes in case of > re-fetch, but no comment in there documents how fragile this is. Which part of the code are you talking about here? -- Steve