Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2126866yba; Wed, 3 Apr 2019 01:43:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvBk9Up6LZhlPGTen5+8zDr0rTi/XF7aH0oLKN7YFMYnmB7X7FWPrgu4WuvGH7rgB7F5q0 X-Received: by 2002:a65:50cc:: with SMTP id s12mr70492826pgp.130.1554280995290; Wed, 03 Apr 2019 01:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554280995; cv=none; d=google.com; s=arc-20160816; b=fd3FJL7HEnfTigd0vwPUVM/Yb/O0uSo/N1He5CHIUhzCChryZnMlOcQ6l0aIWcRZRQ g2is4MHL5m9KMdiVzQirF34hNgRzOQv6BTTL5mj80vNG34mAMboBIw/P4dbGtd9LviX5 LRzwWGYmUyJfKT1MjaGOUzToIctEzVgoEqIlSFeUMrgGBkyXuxflwDF7z/Dmr+DJnxvW oDkYK12u4NEB808rV6Xnmqtl2zniaemoUx5qwqZLM3J3YRatzwcRFPcMz4/g/1V2Q2UZ mzKlMDYZapsQ81Chzp4Q/ZNBPj0IAixxsHB9g5tQlPpY5adka+D/KwQ3oRaX4SVNdGFX 737Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=0SpHxMm/ijXlyu7azUVnH1lLDc6pimR5Ul33po/8sPk=; b=BkPPT1s6Xpah1M7/7/KwdgH9SDZglY5PB29pd4hF89XOS5QAUk69VSrCM8WUEURGPZ MnAbPIPLaXeo09cy8tCidx3+S+Nnislz9wb7pRgEOXnfhOEfW+8kReFiNDpEb5mMrrXK KLZyfPFXJx7FpsGTYk6lchX/cfWp25lFWB+RBEsB4VZIBsJJ3s/SvMr4fOohYqxtnZrc sKzsXoN0LhUmQt/XiVr2lSQzIHxgP3UZlTgyDqcJVNTAFksNcfrrtbdU1wyELWwCJ50H 2Yc87qsBrfW2G/BAvMLw9F7b3L2lSS20JIuVsrWb83V+GC5ORI5lhFR1mmeX5yEdjgSn SmnQ== 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 h18si6581529plr.321.2019.04.03.01.43.00; Wed, 03 Apr 2019 01:43:15 -0700 (PDT) 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 S1729086AbfDCIkm (ORCPT + 99 others); Wed, 3 Apr 2019 04:40:42 -0400 Received: from terminus.zytor.com ([198.137.202.136]:53489 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbfDCIkk (ORCPT ); Wed, 3 Apr 2019 04:40:40 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x338dxVx1775143 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 3 Apr 2019 01:39:59 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x338dx0s1775140; Wed, 3 Apr 2019 01:39:59 -0700 Date: Wed, 3 Apr 2019 01:39:59 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: "tip-bot for Joel Fernandes (Google)" Message-ID: Cc: mingo@kernel.org, jiangshanlai@gmail.com, peterz@infradead.org, torvalds@linux-foundation.org, efault@gmx.de, linux-kernel@vger.kernel.org, luc.vanoostenryck@gmail.com, paulmck@linux.ibm.com, morten.rasmussen@arm.com, mathieu.desnoyers@efficios.com, rostedt@goodmis.org, josh@joshtriplett.org, hpa@zytor.com, joel@joelfernandes.org, tglx@linutronix.de Reply-To: josh@joshtriplett.org, hpa@zytor.com, tglx@linutronix.de, joel@joelfernandes.org, mathieu.desnoyers@efficios.com, rostedt@goodmis.org, morten.rasmussen@arm.com, paulmck@linux.ibm.com, mingo@kernel.org, jiangshanlai@gmail.com, peterz@infradead.org, linux-kernel@vger.kernel.org, luc.vanoostenryck@gmail.com, torvalds@linux-foundation.org, efault@gmx.de In-Reply-To: <20190321003426.160260-3-joel@joelfernandes.org> References: <20190321003426.160260-3-joel@joelfernandes.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:sched/core] sched_domain: Annotate RCU pointers properly Git-Commit-ID: 8e000ec0716d953f905e8f8ca2a6c71bb31bbf5d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,BAYES_00, FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 8e000ec0716d953f905e8f8ca2a6c71bb31bbf5d Gitweb: https://git.kernel.org/tip/8e000ec0716d953f905e8f8ca2a6c71bb31bbf5d Author: Joel Fernandes (Google) AuthorDate: Wed, 20 Mar 2019 20:34:24 -0400 Committer: Ingo Molnar CommitDate: Wed, 3 Apr 2019 09:51:03 +0200 sched_domain: Annotate RCU pointers properly The scheduler uses RCU API in various places to access sched_domain pointers. These cause sparse errors as below. Many new errors show up because of an annotation check I added to rcu_assign_pointer(). Let us annotate the pointers correctly which also will help sparse catch any potential future bugs. This fixes the following sparse errors: rt.c:1681:9: error: incompatible types in comparison expression deadline.c:1904:9: error: incompatible types in comparison expression core.c:519:9: error: incompatible types in comparison expression core.c:1634:17: error: incompatible types in comparison expression fair.c:6193:14: error: incompatible types in comparison expression fair.c:9883:22: error: incompatible types in comparison expression fair.c:9897:9: error: incompatible types in comparison expression sched.h:1287:9: error: incompatible types in comparison expression topology.c:612:9: error: incompatible types in comparison expression topology.c:615:9: error: incompatible types in comparison expression sched.h:1300:9: error: incompatible types in comparison expression topology.c:618:9: error: incompatible types in comparison expression sched.h:1287:9: error: incompatible types in comparison expression topology.c:621:9: error: incompatible types in comparison expression sched.h:1300:9: error: incompatible types in comparison expression topology.c:624:9: error: incompatible types in comparison expression topology.c:671:9: error: incompatible types in comparison expression stats.c:45:17: error: incompatible types in comparison expression fair.c:5998:15: error: incompatible types in comparison expression fair.c:5989:15: error: incompatible types in comparison expression fair.c:5998:15: error: incompatible types in comparison expression fair.c:5989:15: error: incompatible types in comparison expression fair.c:6120:19: error: incompatible types in comparison expression fair.c:6506:14: error: incompatible types in comparison expression fair.c:6515:14: error: incompatible types in comparison expression fair.c:6623:9: error: incompatible types in comparison expression fair.c:5970:17: error: incompatible types in comparison expression fair.c:8642:21: error: incompatible types in comparison expression fair.c:9253:9: error: incompatible types in comparison expression fair.c:9331:9: error: incompatible types in comparison expression fair.c:9519:15: error: incompatible types in comparison expression fair.c:9533:14: error: incompatible types in comparison expression fair.c:9542:14: error: incompatible types in comparison expression fair.c:9567:14: error: incompatible types in comparison expression fair.c:9597:14: error: incompatible types in comparison expression fair.c:9421:16: error: incompatible types in comparison expression fair.c:9421:16: error: incompatible types in comparison expression Signed-off-by: Joel Fernandes (Google) Signed-off-by: Peter Zijlstra (Intel) [ From an RCU perspective. ] Reviewed-by: Paul E. McKenney Cc: Josh Triplett Cc: Lai Jiangshan Cc: Linus Torvalds Cc: Luc Van Oostenryck Cc: Mathieu Desnoyers Cc: Mike Galbraith Cc: Morten Rasmussen Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Thomas Gleixner Cc: keescook@chromium.org Cc: kernel-hardening@lists.openwall.com Cc: kernel-team@android.com Link: https://lkml.kernel.org/r/20190321003426.160260-3-joel@joelfernandes.org Signed-off-by: Ingo Molnar --- include/linux/sched/topology.h | 4 ++-- kernel/sched/sched.h | 14 +++++++------- kernel/sched/topology.c | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/linux/sched/topology.h b/include/linux/sched/topology.h index 57c7ed3fe465..cfc0a89a7159 100644 --- a/include/linux/sched/topology.h +++ b/include/linux/sched/topology.h @@ -76,8 +76,8 @@ struct sched_domain_shared { struct sched_domain { /* These fields must be setup */ - struct sched_domain *parent; /* top domain must be null terminated */ - struct sched_domain *child; /* bottom domain must be null terminated */ + struct sched_domain __rcu *parent; /* top domain must be null terminated */ + struct sched_domain __rcu *child; /* bottom domain must be null terminated */ struct sched_group *groups; /* the balancing groups of the domain */ unsigned long min_interval; /* Minimum balance interval ms */ unsigned long max_interval; /* Maximum balance interval ms */ diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 713715dd00cf..2b452d68ab2e 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -869,8 +869,8 @@ struct rq { atomic_t nr_iowait; #ifdef CONFIG_SMP - struct root_domain *rd; - struct sched_domain *sd; + struct root_domain *rd; + struct sched_domain __rcu *sd; unsigned long cpu_capacity; unsigned long cpu_capacity_orig; @@ -1324,13 +1324,13 @@ static inline struct sched_domain *lowest_flag_domain(int cpu, int flag) return sd; } -DECLARE_PER_CPU(struct sched_domain *, sd_llc); +DECLARE_PER_CPU(struct sched_domain __rcu *, sd_llc); DECLARE_PER_CPU(int, sd_llc_size); DECLARE_PER_CPU(int, sd_llc_id); -DECLARE_PER_CPU(struct sched_domain_shared *, sd_llc_shared); -DECLARE_PER_CPU(struct sched_domain *, sd_numa); -DECLARE_PER_CPU(struct sched_domain *, sd_asym_packing); -DECLARE_PER_CPU(struct sched_domain *, sd_asym_cpucapacity); +DECLARE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); +DECLARE_PER_CPU(struct sched_domain __rcu *, sd_numa); +DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing); +DECLARE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity); extern struct static_key_false sched_asym_cpucapacity; struct sched_group_capacity { diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index ab7f371a3a17..64bec54ded3e 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -615,13 +615,13 @@ static void destroy_sched_domains(struct sched_domain *sd) * the cpumask of the domain), this allows us to quickly tell if * two CPUs are in the same cache domain, see cpus_share_cache(). */ -DEFINE_PER_CPU(struct sched_domain *, sd_llc); +DEFINE_PER_CPU(struct sched_domain __rcu *, sd_llc); DEFINE_PER_CPU(int, sd_llc_size); DEFINE_PER_CPU(int, sd_llc_id); -DEFINE_PER_CPU(struct sched_domain_shared *, sd_llc_shared); -DEFINE_PER_CPU(struct sched_domain *, sd_numa); -DEFINE_PER_CPU(struct sched_domain *, sd_asym_packing); -DEFINE_PER_CPU(struct sched_domain *, sd_asym_cpucapacity); +DEFINE_PER_CPU(struct sched_domain_shared __rcu *, sd_llc_shared); +DEFINE_PER_CPU(struct sched_domain __rcu *, sd_numa); +DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_packing); +DEFINE_PER_CPU(struct sched_domain __rcu *, sd_asym_cpucapacity); DEFINE_STATIC_KEY_FALSE(sched_asym_cpucapacity); static void update_top_cache_domain(int cpu)