From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2547C352A3 for ; Mon, 10 Feb 2020 12:50:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE4E42051A for ; Mon, 10 Feb 2020 12:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581339031; bh=AvajLqGpUfAavsPcZmDIGys8maLrfStkNxpveatiF0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=TljlmfIWyzT8Asak0ZPCYTVZYoOERMBzG6LYI2quqmzwOl8JjzxSeqK/yfH4sLgLS P55aSQ+o19MzCF996FPm/FzjZO2+5cpyiFxXE4GSBP0SeNevY0u6+lREl9/6yGvKfV 5WW5t2DLNzoYCTj6Sl2c8su9CxPdGyrF28h4kVnw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730610AbgBJMoQ (ORCPT ); Mon, 10 Feb 2020 07:44:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:40600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729742AbgBJMk3 (ORCPT ); Mon, 10 Feb 2020 07:40:29 -0500 Received: from localhost (unknown [209.37.97.194]) (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 EE3882051A; Mon, 10 Feb 2020 12:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338428; bh=AvajLqGpUfAavsPcZmDIGys8maLrfStkNxpveatiF0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9eA1cSLol8oEMHqxz00/4MgP0L1SUmobFGBr93YFlnZ0Y436gridvbs1uzJVl6pV doD133L8NdypHtjN0nfZppdvGC8jVAzTWPoxQWPBEAIeOE+0YrUTHbS0wmb/r1bAtE DB+6nYX8ddnnqPLYx3zM7HtxCh8MJuzvW2o1J6jA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Joel Fernandes (Google)" , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 5.5 152/367] ftrace: Add comment to why rcu_dereference_sched() is open coded Date: Mon, 10 Feb 2020 04:31:05 -0800 Message-Id: <20200210122438.861741278@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) [ Upstream commit 16052dd5bdfa16dbe18d8c1d4cde2ddab9d23177 ] Because the function graph tracer can execute in sections where RCU is not "watching", the rcu_dereference_sched() for the has needs to be open coded. This is fine because the RCU "flavor" of the ftrace hash is protected by its own RCU handling (it does its own little synchronization on every CPU and does not rely on RCU sched). Acked-by: Joel Fernandes (Google) Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- kernel/trace/trace.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 497defe9ed264..b769638f005c7 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -961,6 +961,11 @@ static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace) preempt_disable_notrace(); + /* + * Have to open code "rcu_dereference_sched()" because the + * function graph tracer can be called when RCU is not + * "watching". + */ hash = rcu_dereference_protected(ftrace_graph_hash, !preemptible()); if (ftrace_hash_empty(hash)) { @@ -1008,6 +1013,11 @@ static inline int ftrace_graph_notrace_addr(unsigned long addr) preempt_disable_notrace(); + /* + * Have to open code "rcu_dereference_sched()" because the + * function graph tracer can be called when RCU is not + * "watching". + */ notrace_hash = rcu_dereference_protected(ftrace_graph_notrace_hash, !preemptible()); -- 2.20.1