Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1490093ybl; Fri, 31 Jan 2020 23:29:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwoF45IQDAz0UpQK1wCoHhzRjc6oFaJHkPtJXh1bhrWPf/uyRuKmQT7fMYyrPpo5+PP1UTX X-Received: by 2002:aca:514e:: with SMTP id f75mr9156401oib.103.1580542159431; Fri, 31 Jan 2020 23:29:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580542159; cv=none; d=google.com; s=arc-20160816; b=1DZF2hdpJpIq2bh18NVB2vz8ewYzJbG1iMQS8rF+uxq+GaQlY5ZrYMLEgek120Kxi9 4OxnsPKpUn0ej4oqaD94qQgOqaD78SwiYh6BdA+4Jmjw0SqqiXYfOEbnF0Efe9i3Bowy 4/2XUzacsorU6tv9bV4fsaXxLzXjeecSmf/6Gl4iZUIwWS6tZm68pt3KXIBJ+SWhcibx Odl1MdZSbnJByhp4tmAYz//pn+2kiggp/7213IaSm7NsLUSRW+DK3izEE0yBZAPbfjOB KxIBllChHDl4Uf9S8iTLYKCUJKYjyAA8tQgKoYCgnUyDRdLYmZiTIYHrfLBh0kEyUT9b JIcw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=2tdGWkxDgfXpnJAdtjaUc34vzgvsJbHdiM8yHvDQB98=; b=NnJ4VPGQam/2MLOu26JPotzaiP+i5ZN7iKfYFIWfL8LQOYkhHci1OtfZPlOkH0isAf obRN3KSRzjfG1c5jjJVPN16Jb7WAwjqGhYMXC4y+cq37F+SsmH9imUln6PzTfJe9lG7X Pad9a9bO2cWM1KE4L0IrKRfleorZdjlD4nS2zyruZAz8R2Sc43NWrP9aMeEpWRbDw5Xi Nf0HZKA+1DmvBToD6deyjDFHZhyoySJpM0tRLFtK13C9hAMf4pUq2WcIMNSNz+BjwTrq A0z13qj+ERaUClhWeUMy/8Q0cpSRuXqSpVozZvRNoHH0wRDRe7p3N+/kvjJrq7j25cUi CPqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=An9h9hQf; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v26si6381583otj.0.2020.01.31.23.29.06; Fri, 31 Jan 2020 23:29:19 -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=@gmail.com header.s=20161025 header.b=An9h9hQf; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbgBAH2C (ORCPT + 99 others); Sat, 1 Feb 2020 02:28:02 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44668 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726115AbgBAH2C (ORCPT ); Sat, 1 Feb 2020 02:28:02 -0500 Received: by mail-pl1-f195.google.com with SMTP id d9so3714310plo.11 for ; Fri, 31 Jan 2020 23:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2tdGWkxDgfXpnJAdtjaUc34vzgvsJbHdiM8yHvDQB98=; b=An9h9hQfzeqnBoTwBSP5knDHWbGL/U1hHk77g4T1UX3kn2zFWcnPMO/w3oPqJx1OSC 3MTc+fotYOu4KzvnZsmbBhg0OIb5bD/i5sOMK7CZrNwwbtHLjDM1N9ash0OPM2fVQGjY y3BoNY72E6Y8r7zUvP7fJupd3th8pb48FR7gsfMnUksabJlOldo+RT+m3xqr3S01Of/y cB4ZzdziuTbhmwdhGoKfPLwNdIwGkL/2xUfn+eGn3hzK0irwV9cHNRhvwu3mTPofKujQ pdfnKcFA9WWbnqKg+LfxDmblvHrme7l1Fpeb96LY1SKoAYhmLZ8odC+sW91PfTxEoWl4 3ApA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2tdGWkxDgfXpnJAdtjaUc34vzgvsJbHdiM8yHvDQB98=; b=GNxbSJ1FhZ+7EY+TAudsLpIkmct+rT5R5LcS9sDGIwjqTVftrKiRzWQbgxbgoXFIWV 0OLmj4FM3CgG4TgH5/SatcZdZIcKjauootw78lQs9CE5XwO+3XjNyTN4mvMqRXyXE22/ pXIA44yhS//mKfrWCJ2Vy8V+D7f2htnYk4LIDVmK66ibVbtRzoARdNV3BppgWX35rhr1 ZKRH2KQ+70ZVF7ZTpklhrPSfjDaRgWLKpRx/MzPnY/aBPIQAEL2YEp2757ghYWQZt3xU taXAkhtEF25tX8Xd0glb16swau5Eo7xx6PLvGf9gJfIH9n/Iuq3qh2b+z5JPuYvhK5sa BD3w== X-Gm-Message-State: APjAAAX2rV83Zc8AoQfrHq2uxXPkso2QgS527d1Y26UisSa2Khonzeuf ASctwgb8lsWmf0uVSkHkZHM= X-Received: by 2002:a17:90a:5d85:: with SMTP id t5mr17043821pji.126.1580542082014; Fri, 31 Jan 2020 23:28:02 -0800 (PST) Received: from localhost.localdomain ([103.211.17.237]) by smtp.googlemail.com with ESMTPSA id h7sm13240735pfq.36.2020.01.31.23.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2020 23:28:01 -0800 (PST) From: Amol Grover To: Steven Rostedt , Ingo Molnar Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" , Amol Grover Subject: [PATCH] tracing: Annotate ftrace_graph_hash pointer with __rcu Date: Sat, 1 Feb 2020 12:57:04 +0530 Message-Id: <20200201072703.17330-1-frextrite@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix following instances of sparse error kernel/trace/ftrace.c:5664:29: error: incompatible types in comparison kernel/trace/ftrace.c:5785:21: error: incompatible types in comparison kernel/trace/ftrace.c:5864:36: error: incompatible types in comparison kernel/trace/ftrace.c:5866:25: error: incompatible types in comparison Use rcu_dereference_protected to access the __rcu annotated pointer. Signed-off-by: Amol Grover --- kernel/trace/ftrace.c | 2 +- kernel/trace/trace.h | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 9bf1f2cd515e..959ded08dc13 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -5596,7 +5596,7 @@ static const struct file_operations ftrace_notrace_fops = { static DEFINE_MUTEX(graph_lock); -struct ftrace_hash *ftrace_graph_hash = EMPTY_HASH; +struct ftrace_hash __rcu *ftrace_graph_hash = EMPTY_HASH; struct ftrace_hash *ftrace_graph_notrace_hash = EMPTY_HASH; enum graph_filter_type { diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 63bf60f79398..97dad3326020 100644 --- 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()); + + if (ftrace_hash_empty(hash)) { ret = 1; goto out; } - if (ftrace_lookup_ip(ftrace_graph_hash, addr)) { + if (ftrace_lookup_ip(hash, addr)) { /* * This needs to be cleared on the return functions -- 2.24.1