Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp418882ybv; Wed, 5 Feb 2020 07:50:54 -0800 (PST) X-Google-Smtp-Source: APXvYqz4Ux7H4upS3PJz3raRgstQw6tvTi5jazUJXUQoy3hEVq2FeeRD5jg3rUawQwVNLi/vJlyT X-Received: by 2002:aca:ea43:: with SMTP id i64mr3444589oih.30.1580917854118; Wed, 05 Feb 2020 07:50:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580917854; cv=none; d=google.com; s=arc-20160816; b=To8xsyFSkWIPycrPSZNv7UwAhvl1ybL29y37nPJw/L8TqzkveisWZTGBh/MlXv72vE u4P0FUFcmm3VKkAZojd6QsJJxkGfTGCzCWGw6puTa/oQ94XvrHfkZ7406hOrn1Mgcz+w sCdhYpNZsX7+1mOarKuSHPeeEj0qMWGzatX81v64m5PbjGFf8n0PnbqAnwODSQK0b+nM +S7Izg7Kwoo+cTGtetc088N5guLbeRfu0Dj28CFu0hmFvI7N6jvVca8di2eMxMFWskeE 7IJeiCFvJqkmC6DsC/RAOKq1U9sJLZCtZGM8/d/nE4d6NgdIrU7hy4/AoFM3UiGJAEmc eOHA== 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=k7UIK6nG2IT9GPWWRoUQt1yZOhO+Ck/wEGhG0NBn1U0=; b=soIOXANoGelRYGorbmkFvqgXP/Nheb24R5NznImFjPd3XHiJkJCZLsrBlZtBpI0P09 lHfWAAowIzCWQZcXdWgPXiaJnyXDh1b8wjCwDpY15tnSuIYKnXjKXwNYLBGrKoT7IL9V y/mKfVSfqBYE+HXFAyLZTon1Zy+gtzTA6ar8FjR5NaivO/Uibj+nQCkR9WmGqxFhrFOv KzMV2I230gTdglJY4NHqb0cXD6lec0+lxsDEMVRDem3F8teEQ4QNmU1V+FungSsAvATc tclSt0mWBDqx+PCerivtzWa360JDt3BoC3uMzpI4nnJOkwrUiS4fDMuRNWtT71ThFkrd KIOQ== 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 e25si14472002otk.62.2020.02.05.07.50.41; Wed, 05 Feb 2020 07:50:54 -0800 (PST) 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 S1727484AbgBEPtw (ORCPT + 99 others); Wed, 5 Feb 2020 10:49:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:60712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726334AbgBEPtv (ORCPT ); Wed, 5 Feb 2020 10:49:51 -0500 Received: from oasis.local.home (unknown [212.187.182.165]) (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 054F920730; Wed, 5 Feb 2020 15:49:49 +0000 (UTC) Date: Wed, 5 Feb 2020 10:49:45 -0500 From: Steven Rostedt To: Joel Fernandes Cc: "Paul E. McKenney" , linux-kernel@vger.kernel.org, Ingo Molnar , Andrew Morton , Amol Grover Subject: Re: [for-next][PATCH 4/4] ftrace: Add comment to why rcu_dereference_sched() is open coded Message-ID: <20200205104945.4a6f85de@oasis.local.home> In-Reply-To: <20200205154212.GC142103@google.com> References: <20200205104929.313040579@goodmis.org> <20200205105113.283672584@goodmis.org> <20200205063349.4c3df2c0@oasis.local.home> <20200205141915.GA194021@google.com> <20200205092847.0b650972@oasis.local.home> <20200205154212.GC142103@google.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 Wed, 5 Feb 2020 10:42:12 -0500 Joel Fernandes wrote: > On Wed, Feb 05, 2020 at 09:28:47AM -0500, Steven Rostedt wrote: > > On Wed, 5 Feb 2020 09:19:15 -0500 > > Joel Fernandes wrote: > > > > > Could you paste the stack here when RCU is not watching? In trace event code > > > IIRC we call rcu_enter_irqs_on() to have RCU temporarily watch, since that > > > code can be called from idle loop. Should we doing the same here as well? > > > > Unfortunately I lost the stack trace. And the last time we tried to use > > rcu_enter_irqs_on() for ftrace, we couldn't find a way to do this > > properly. Ftrace is much more invasive then going into idle. The > > problem is that ftrace traces RCU itself, and calling > > "rcu_enter_irqs_on()" in pretty much any place in the RCU code caused > > lots of bugs ;-) > > > > This is why we have the schedule_on_each_cpu(ftrace_sync) hack. > > The "schedule a task on each CPU" trick works on !PREEMPT though right? It works on both, as I care more about the PREEMPT=y case then the !PREEMPT, and the PREEMPT_RT which is even more preemptive than PREEMPT! > > Because it is possible in PREEMPT=y to get preempted in the middle of a > read-side critical section, switch to the worker thread executing the > ftrace_sync() and then switch back. But RCU still has to watch that CPU since > the read-side critical section was not completed. > > Or is there a subtlety here with ftrace that I missed? > Hence Amol's patch: > + notrace_hash = rcu_dereference_protected(ftrace_graph_notrace_hash, > + !preemptible()); It checks to make sure preemption is off. There is no chance of being preempted in the read side critical section. -- Steve