Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2252162imc; Fri, 22 Feb 2019 22:36:04 -0800 (PST) X-Google-Smtp-Source: AHgI3IZa5wiVR7zGK+CajU11vLVjdJErlcIdkPA8Q3jE68YRIm2IFANo1Iq4VY6n0lamXMkrap9x X-Received: by 2002:a17:902:290b:: with SMTP id g11mr8066616plb.269.1550903764588; Fri, 22 Feb 2019 22:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550903764; cv=none; d=google.com; s=arc-20160816; b=sze5bKfPka0//XZq2rQnu5fEHZ04LLh26fl/bm2eG8UhIe2IyB9QTfWPQVqRsQpswu A+8CPGn1BMjGH2gqKp63HYO1NDWKRClxbUE52RuEOVoUWe5nbGFpSmDPrTycaft6vez3 jnKYthPyx8cVWkrmnMCirAuXEM7oiqx+50e4v3Y8myMe4Xd6SE0kmIIsa3w23KTuB5ax /8Hj/BlGUZaI4+pyGYB1nZEARuxIvfIHob28q+QeoyUMKJ/4kdYP4ss3KzpaiZebyTub J6ZmOwOH2X4GduvpDBRcCmtnWyR3Bcv76ZncRRgUvqWdYtPPaU12b3FX7hfjedFSLeeX nM8w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jdV6wy+jDVHFrKow+yC2lWMVIASermFDO9APgnn8BDA=; b=qjpXTqvGWavWbjPLCOOF/9+8XeEI+9l3JKB2pgp+Kpz48GTC1/8agVcv/4m7Hq1zxK lmfYMBtJhOZuyL7BTwoyHbol80ZymErJyjlNenLQBq3ivaVjsGgBIVsh+Z7QdDryJCpD pWowV8q1t092q5r4HwkZj0rIqzMyYMnDd/bTcckQgQj5Gb0mfAkaNI+10b3og0bwkI8c aadfmGJZTZy27a+M3YBdWlcKznTmlgBVlnm+uFlL9tUtWV+oieNr8+2iTaHCN2wH/voF fCEpyj05IY5JneDsqodxCLj4uBuW03JqJcWonCbM/UTjk8g8SarCo7uf9bfbEw/UqhX3 gabA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=e93WQJoN; 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 33si3256601plk.213.2019.02.22.22.35.49; Fri, 22 Feb 2019 22:36:04 -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=@joelfernandes.org header.s=google header.b=e93WQJoN; 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 S1727809AbfBWGfD (ORCPT + 99 others); Sat, 23 Feb 2019 01:35:03 -0500 Received: from mail-qt1-f196.google.com ([209.85.160.196]:33402 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727757AbfBWGe7 (ORCPT ); Sat, 23 Feb 2019 01:34:59 -0500 Received: by mail-qt1-f196.google.com with SMTP id z39so5163131qtz.0 for ; Fri, 22 Feb 2019 22:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jdV6wy+jDVHFrKow+yC2lWMVIASermFDO9APgnn8BDA=; b=e93WQJoNz7sL11KjqrcaGD5cGCsOh2htcsisG1aGdQYshASs4Jc8YIlLUcBv+PFM33 D5SWT5Nbb9ONDe8CUUIld7RbTnOXcTah8lcBA2VAi3xuQVZszD3UQ2BKlE/VdsuMB5KH PaecNNtBBlmH9U1q0e7SJNBT9GNC8OsaTTc0s= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=jdV6wy+jDVHFrKow+yC2lWMVIASermFDO9APgnn8BDA=; b=AF3YVYITjGWcW0mgGEtHVuEuBGz6eSYSja5b8+KjGoo/BK6jyrEq6KRxzTDn6aZHDx CQLbnLglOqTjCsLwMaxvLGV60RHc2hpaNDka2/lyUJkZ1gxIpiSWfZPFGGBRZUaEDqyN 831/VOf07FoyuoaFXPZlDQHaJmKRdD5ltK5XKS9r5Zc3m1mP0IQ21fbWBFSljHB/6JwE BGMPEIsl4JbNYW+S0ru2afvK0rBxfiKqo+RoK9x7Fx7HKOOSU4FLhn8nBuShoJVVX2qY CgxhD6NONtiZCgajUWMcWJJHI0/r72UsF3IhKRuGoG/Tn9H1P61wv2bOSWIf7uI5e0s3 MOzw== X-Gm-Message-State: AHQUAubVPo8z2MBX3hjfDXbUrHpblxwGt0Cmh1JvkgX8apWBZoXww4AZ ZwCnRdr5R2aYIWYUmt3S/w3ERngc4Dc= X-Received: by 2002:ac8:166b:: with SMTP id x40mr6020562qtk.363.1550903697258; Fri, 22 Feb 2019 22:34:57 -0800 (PST) Received: from joelaf.cam.corp.google.com ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id d32sm2189408qtc.88.2019.02.22.22.34.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 22:34:56 -0800 (PST) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: "Joel Fernandes (Google)" , 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, "Paul E. McKenney" , Peter Zijlstra , Quentin Perret , rcu@vger.kernel.org, Song Liu , Steven Rostedt , Vincent Guittot , xdp-newbies@vger.kernel.org, Yonghong Song Subject: [PATCH v2 4/6] sched_domain: Annotate RCU pointers properly Date: Sat, 23 Feb 2019 01:34:32 -0500 Message-Id: <20190223063434.6793-5-joel@joelfernandes.org> X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog In-Reply-To: <20190223063434.6793-1-joel@joelfernandes.org> References: <20190223063434.6793-1-joel@joelfernandes.org> 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 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) --- 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