Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4897388imc; Mon, 25 Feb 2019 13:12:18 -0800 (PST) X-Google-Smtp-Source: AHgI3IbhuYTBAUO9XmdDbr9od+ATfgSgDv7ZjNA37Fp4HK+qHWwj8Pjd5gNsqV/cz5yfW9Oo+LE+ X-Received: by 2002:a17:902:33c1:: with SMTP id b59mr22155106plc.220.1551129138454; Mon, 25 Feb 2019 13:12:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551129138; cv=none; d=google.com; s=arc-20160816; b=SgQaAoPWeLj8lgQ8LwvBHF9Kv9jbelyXaNtyV9sFRt5xgAuuymfrs9vM6040Oot7lf /4iP3pWlPjwdQyHxmzkAp/Iq5glAL9EhkZTwiV002g8Zj82u8BGzUgviw/pL970z8st2 rUpHnCtV0CtLnuT8gJb7J8kOuI22pzVoLUO96WuQIrv2GUfXeaAECEjetJSeQEu4w/fu DZTWTOd7nT4lcemqadbh62TFjQKTAwu4k6RG45mCuAOSleUJjQK9pDFpOC497vzY0RZ/ wGqbgW7aI1Mwx1WWfwty9jowrn93eGRQKQekJgu+SnmEdqTSmvTp910YDFSeF5zalX5o MP+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date; bh=YLbyRMbMMc5w6cPewEcfnU7NFvixRXy0opfeHYVzyXU=; b=schCIP2JIqfFp998dEfUVHiXGtJpu5Q1nstN5zU8dxnmZCQZvcDVrrmPqdXot0GU6K g0EdwEFZorrG02oWpexevI9PS3bxUrsbJ43aiBqKYmFi9h5/c2LmznWgulqnUlwyuwjq ivgkC+hwZIJtY2JwR8w9t7JWU90lW8MI8/kA+CXXJKYo+OFnXIeyCTjh6enejk+JPJzZ I+IZ5RH4u33xcCoiLPwvc5QmwUrMzmKYkuvti6fyelmsZXwckNyO0gJ+0BeMtzPqCNHp f0GO3qRBqX5dcp2NX+Y3j2UR6GPieXDkGuzoet3OrDsXWNzEgP3FWlxIcDtOO/kLXljd LdIQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39si10982130pld.70.2019.02.25.13.12.02; Mon, 25 Feb 2019 13:12:18 -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; 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=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728309AbfBYVLT (ORCPT + 99 others); Mon, 25 Feb 2019 16:11:19 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54158 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726770AbfBYVLT (ORCPT ); Mon, 25 Feb 2019 16:11:19 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1PL4t4s034354 for ; Mon, 25 Feb 2019 16:11:17 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2qvnc7qnpr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 25 Feb 2019 16:11:17 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 25 Feb 2019 21:11:16 -0000 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 25 Feb 2019 21:11:09 -0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x1PLB8rS16842864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Feb 2019 21:11:08 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67214B205F; Mon, 25 Feb 2019 21:11:08 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 35205B206C; Mon, 25 Feb 2019 21:11:08 +0000 (GMT) Received: from paulmck-ThinkPad-W541 (unknown [9.70.82.188]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Mon, 25 Feb 2019 21:11:08 +0000 (GMT) Received: by paulmck-ThinkPad-W541 (Postfix, from userid 1000) id 579E616C1510; Mon, 25 Feb 2019 13:11:08 -0800 (PST) Date: Mon, 25 Feb 2019 13:11:08 -0800 From: "Paul E. McKenney" To: "Joel Fernandes (Google)" Cc: linux-kernel@vger.kernel.org, Alexei Starovoitov , Christian Brauner , Daniel Borkmann , David Ahern , "David S. Miller" , Ingo Molnar , Jakub Kicinski , Jeff Kirsher , Jesper Dangaard Brouer , John Fastabend , Josh Triplett , keescook@chromium.org, kernel-hardening@lists.openwall.com, kernel-team@android.com, Kirill Tkhai , Lai Jiangshan , Martin KaFai Lau , Mathieu Desnoyers , netdev@vger.kernel.org, Peter Zijlstra , Quentin Perret , rcu@vger.kernel.org, Song Liu , Steven Rostedt , Vincent Guittot , xdp-newbies@vger.kernel.org, Yonghong Song Subject: Re: [PATCH v2 4/6] sched_domain: Annotate RCU pointers properly Reply-To: paulmck@linux.ibm.com References: <20190223063434.6793-1-joel@joelfernandes.org> <20190223063434.6793-5-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190223063434.6793-5-joel@joelfernandes.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 19022521-0060-0000-0000-000003122830 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010663; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01166317; UDB=6.00609217; IPR=6.00946921; MB=3.00025738; MTD=3.00000008; XFM=3.00000015; UTC=2019-02-25 21:11:15 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19022521-0061-0000-0000-0000486CC237 Message-Id: <20190225211108.GY4072@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-25_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902250151 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 23, 2019 at 01:34:32AM -0500, Joel Fernandes (Google) wrote: > 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) From an RCU perspective: Reviewed-by: Paul E. McKenney > --- > 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 c31d3a47a47c..4819c9e01e42 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 2ab545d40381..ca6a79f57e7a 100644 > --- a/kernel/sched/sched.h > +++ b/kernel/sched/sched.h > @@ -866,8 +866,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; > @@ -1305,13 +1305,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 3f35ba1d8fde..0844ee757dad 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -586,13 +586,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) > -- > 2.21.0.rc0.258.g878e2cd30e-goog >