Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp262302ybv; Wed, 5 Feb 2020 05:12:39 -0800 (PST) X-Google-Smtp-Source: APXvYqzc9jil4zRWP/NXc0eTKlI/fpJMoJVZ+Jw5G0ZQHvDFJ5fqPXzhJp5n834IvqRyNJlGUcQm X-Received: by 2002:aca:1b11:: with SMTP id b17mr2814733oib.45.1580908359533; Wed, 05 Feb 2020 05:12:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580908359; cv=none; d=google.com; s=arc-20160816; b=oId+ZSN5hlCDhkLHhS1C/Mt3yUsFZ/+yQJu7njubLA3qahC+pjnii2hePZjT43pxzP sPCxSRCgpTQ4GWk6MdvhJbTT8VZnkPCOgz6WGSIF1pThzN5TKOa5c2gMEGcu0jymHcwr 44t6dY+rxiVk+9Qr4MBxrtSfyIQBe2lmzHdFSy1esinxhG+CdZjQNUx6s6nD0ds+S26s keI2jC1rW/qET5GbOFDXyFOj9B3sl3oNJTaPHwkpW4yLHVft4Re+/sUv2ADxeiCL5pEV N5ioNonxtBx7dlXSqF1PqB6eY0YSsZc26pDcC8T7mqDTvrHSmtJsfOSG/CgxC7dzEX58 AtSg== 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:reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=yU0FiumYZlZLYVwa2noZI54cm9+XadHETk0EROtmzTQ=; b=kdBWfOx7Hwt1M271XEvBQWL/WevADDCz3wTv0k8DQjuINSMce5wopdGX2eezmb6+P4 arDFiUDZrXpf0FKEXCI25IEeHdkcD+Ejj8aeB3/17lZmc/lCWgX32qPAxcLNkQ6UVV4H uiFvCKwhR+rhBXG1neAzZLL7bFfTR3qPh7zb7ZHyZnCxvd94R9K0mrYgrHJHsXvtEv6D BwhanLCzxC6Dq8eg6SGljs6VMb4Uch92HL0vAGWFw3RqWigKNMXUaz2bzBfLLEpREY1I ArMlPbl+yOMYHi7I1qFECsQYgkfczITID8TOEO16zTFt/JpN9v5VapZwBYAxcEkxbRUy j0PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lFln09Vk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 22si5897806oin.34.2020.02.05.05.12.25; Wed, 05 Feb 2020 05:12:39 -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; dkim=pass header.i=@kernel.org header.s=default header.b=lFln09Vk; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbgBENLL (ORCPT + 99 others); Wed, 5 Feb 2020 08:11:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:59118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbgBENLL (ORCPT ); Wed, 5 Feb 2020 08:11:11 -0500 Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (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 6D3B62082E; Wed, 5 Feb 2020 13:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580908270; bh=wSPjyDZaJd4iYDsHDvfTkbCVhxFTYWZXqFiynFRgSqQ=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=lFln09VkBtkKNCzjna0O6RjF4HXeY041b+M9cjd6Gg+nM1BDA5etdYv1mR98VGfJD 19dJOGyubTzNLTYO1TgPFs91g8c6SzX04APp359/ins/jR3jaif5VhBt3i8xwTGY3g EUEm4yg8Z6LWtBrnQ8/8skmEGJgZSklG5+b1A6AU= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 3EDCC352270F; Wed, 5 Feb 2020 05:11:10 -0800 (PST) Date: Wed, 5 Feb 2020 05:11:10 -0800 From: "Paul E. McKenney" To: Steven Rostedt Cc: Joel Fernandes , Amol Grover , Ingo Molnar , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Madhuparna Bhowmik Subject: Re: [PATCH] tracing: Annotate ftrace_graph_hash pointer with __rcu Message-ID: <20200205131110.GT2935@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200201072703.17330-1-frextrite@gmail.com> <20200203163301.GB85781@google.com> <20200204200116.479f0c60@oasis.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200204200116.479f0c60@oasis.local.home> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 04, 2020 at 08:01:16PM -0500, Steven Rostedt wrote: > On Mon, 3 Feb 2020 11:33:01 -0500 > Joel Fernandes wrote: > > > > > --- a/kernel/trace/trace.h > > > +++ b/kernel/trace/trace.h > > > @@ -950,22 +950,25 @@ extern void __trace_graph_return(struct trace_array *tr, > > > unsigned long flags, int pc); > > > > > > #ifdef CONFIG_DYNAMIC_FTRACE > > > -extern struct ftrace_hash *ftrace_graph_hash; > > > +extern struct ftrace_hash __rcu *ftrace_graph_hash; > > > extern struct ftrace_hash *ftrace_graph_notrace_hash; > > > > > > static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace) > > > { > > > unsigned long addr = trace->func; > > > int ret = 0; > > > + struct ftrace_hash *hash; > > > > > > preempt_disable_notrace(); > > > > > > - if (ftrace_hash_empty(ftrace_graph_hash)) { > > > + hash = rcu_dereference_protected(ftrace_graph_hash, !preemptible()); > > > > I think you can use rcu_dereference_sched() here? That way no need to pass > > !preemptible. > > > > A preempt-disabled section is an RCU "sched flavor" section. Flavors are > > consolidated in the backend, but in the front end the dereference API still > > do have flavors. > > Unfortunately, doing it with rcu_dereference_sched() causes a lockdep > splat :-P. This is because ftrace can execute when rcu is not > "watching" and that will trigger a lockdep error. That means, this > origin patch *is* correct. I'm re-applying this one. I strongly recommend a comment stating why disabling preemption prevents ftrace_graph_hash from going away. I see the synchronize_rcu() after the rcu_assign_pointer() in ftrace_graph_release(), but I don't see anything that waits on CPUs that RCU is not watching. Of course, event tracing -makes- RCU watch when needed, but if that was set up, then lockdep would not have complained. So what am I missing? Thanx, Paul