Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1809632ybl; Thu, 30 Jan 2020 06:26:06 -0800 (PST) X-Google-Smtp-Source: APXvYqxdr167Z+tBOTEAjaA+xJU7/70g8R//wsgAwmBJRUxoHk2xNRMTyUp311rX3TV9DcxdeB/m X-Received: by 2002:a9d:6d10:: with SMTP id o16mr3906581otp.28.1580394366353; Thu, 30 Jan 2020 06:26:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580394366; cv=none; d=google.com; s=arc-20160816; b=DjwYWHWCbBcFwk2XwyPQGRKh0+uJ2PHYG7Q3ZSMBtA09EAkz1S4dpj3pA1Z6D++qbX ioJpYW+9DhYksiEx9OcqNALM4KcyGQfKQ+bYGSwVqZ8Vb4ZTLCJk7lAczv27BDUYl3/v tBNTU+CVoy7inDY3ooql4h4Aew03Ai8mJ8T/8uzi38xsiZ10LmAe0yl6Am2bgz6bdABz 7Si/w5iAcUk3iyYS+8eYWde/LPRrt4xcZbHHpBwnwCoaUyTMol9++WHd4EmXTmpSwRII 1hKY50yrzXEh1VFGaqhxnxU+pPCc7Hu0TlN2c3mZg42BjKGYuhxS+O3+CtZUSIqL4JmU 3gNg== 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=6T7BA/VeHSTmsgbu5fmQVa4i4NpuWX85GL9aH8ZEE74=; b=NQ3ScF9TAZMUqRJPewCao6/8jf7rt+vSuhmk4FgJjnjuQUYjBR19sxGxwXFVA7k54a q35T8USBcWtrQQS4+IvScuGTqdCPsh4Voqs5pBs7jF27s3lAXeBWU/yqxhY5UNabTrRG 7tCdXPvj8dLwao5NjJK02l3Q3G2P5KhsKW1GZOW1hEacbHBkJUXaBKToWlDSKaCsJYGc zbfJ5U9V6o2qWZ13QnY2ALDbsptaQuptcgYIdkgpJxeYnXBx6NrY7ooDBNV5CTUEH6so 9oP+jcxwMiqtb8Sb89KvTo5FZivsgLEvwL6bJU97tpT9cCtdIiFNN8tPr+5rU5x7g8Wc LxfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=R3LnSqcA; 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=fail (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 u132si594704oie.250.2020.01.30.06.25.52; Thu, 30 Jan 2020 06:26:06 -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=fail header.i=@gmail.com header.s=20161025 header.b=R3LnSqcA; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727470AbgA3OXR (ORCPT + 99 others); Thu, 30 Jan 2020 09:23:17 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38815 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbgA3OXQ (ORCPT ); Thu, 30 Jan 2020 09:23:16 -0500 Received: by mail-pg1-f196.google.com with SMTP id a33so1733697pgm.5 for ; Thu, 30 Jan 2020 06:23:16 -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=6T7BA/VeHSTmsgbu5fmQVa4i4NpuWX85GL9aH8ZEE74=; b=R3LnSqcAeDVQOAHlpG1owMpEpBN/wKJXlNPE4yy2OJftYy+o1XFdg2UvFuYOcApUCs wzj6xHPsgPqTmDBIZ31a33yVDP95XBf9aS8RiBaegWDx0USmHQD2N6xncypmbbIL/V7S pAZF1CnqdBCMYawpCCBIulwl5/aQ0566iMvNDUqD0+AwGHu/QG8wdXxZQtTPEX4MvPUC TJsILeo5ZsI7D1qb7HpdCPLQbJX37Lnr/P/obM2hE2jPsiRiv9YkcHI+EORU2tzzekTd lusGAtCSo5AWjvSe9SLGDRS1HbgWyDPTbTnruPvJ3wy/CXxvixVGmJ+tpuY6OacDhaFS i1OQ== 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=6T7BA/VeHSTmsgbu5fmQVa4i4NpuWX85GL9aH8ZEE74=; b=UmvxQX907rQRJd6z6WTBja5q5Bx5wbOR9JNnOM+yROHF8SPssv6lF2yF8654xAEgC7 XurP5W17yRCQvWFSrkea3K2BFjQcNhxw79rNqORexxPpxbUQ/uO0ykzW4cnWhiVuyon8 aZZtPDF9IJWQasFrhul6cvbf9ZSasg/jP2Y40gfRyAIvFXY11vsohiHuzS4GrKRZ1JXy IepAhi53q3ag1+Pyn9g8GOk3j49gLOt7AjKJ7I3UEd6jHc6RJr029ogmU3MJcUZSJHCh Lo2zSi63USowa7ftt4Wn40sUr/mH3iQcDTvKq/DcDyUupYtBHsT7QY4p/MqEg1ECIFeu oHxw== X-Gm-Message-State: APjAAAV8LtHLhzIBzYvn08/Qqnav6WLcnJMxtiiedhuQ52OGqR3MROFE tdqOZGtV3r7RC0vhzVIKk0A= X-Received: by 2002:aa7:874b:: with SMTP id g11mr5469169pfo.225.1580394195955; Thu, 30 Jan 2020 06:23:15 -0800 (PST) Received: from localhost.localdomain ([103.211.17.117]) by smtp.googlemail.com with ESMTPSA id m71sm9840602pje.0.2020.01.30.06.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 06:23:15 -0800 (PST) From: Amol Grover To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim Cc: linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" , Amol Grover Subject: [PATCH v2] callchain: Annotate RCU pointer with __rcu Date: Thu, 30 Jan 2020 19:48:19 +0530 Message-Id: <20200130141818.18391-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 Fixes following instances of sparse error error: incompatible types in comparison expression (different address spaces) kernel/events/callchain.c:66:9: error: incompatible types in comparison kernel/events/callchain.c:96:9: error: incompatible types in comparison kernel/events/callchain.c:161:19: error: incompatible types in comparison This introduces the following warning kernel/events/callchain.c:65:17: warning: incorrect type in assignment which is fixed as below callchain_cpus_entries is annotated as an RCU pointer. Hence rcu_dereference_protected or similar RCU API is required to dereference the pointer. Signed-off-by: Amol Grover --- v2: - Squash both the commits into a single one. kernel/events/callchain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c index c2b41a263166..a672d02a1b3a 100644 --- a/kernel/events/callchain.c +++ b/kernel/events/callchain.c @@ -32,7 +32,7 @@ static inline size_t perf_callchain_entry__sizeof(void) static DEFINE_PER_CPU(int, callchain_recursion[PERF_NR_CONTEXTS]); static atomic_t nr_callchain_events; static DEFINE_MUTEX(callchain_mutex); -static struct callchain_cpus_entries *callchain_cpus_entries; +static struct callchain_cpus_entries __rcu *callchain_cpus_entries; __weak void perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, @@ -62,7 +62,8 @@ static void release_callchain_buffers(void) { struct callchain_cpus_entries *entries; - entries = callchain_cpus_entries; + entries = rcu_dereference_protected(callchain_cpus_entries, + lockdep_is_held(&callchain_mutex)); RCU_INIT_POINTER(callchain_cpus_entries, NULL); call_rcu(&entries->rcu_head, release_callchain_buffers_rcu); } -- 2.24.1