Received: by 10.213.65.68 with SMTP id h4csp554imn; Thu, 15 Mar 2018 07:50:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELuPP1yI0WLPVKCsLxXJqY/Tyo48cvdD7aLiNinO4nB23YJXdbO7KB67yjkZIpLsyq9xXA22 X-Received: by 10.98.214.218 with SMTP id a87mr7977962pfl.146.1521125434310; Thu, 15 Mar 2018 07:50:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521125434; cv=none; d=google.com; s=arc-20160816; b=KWRdJp0hVi2UVv2K5mThXAijzK0TUnxvZGIt06hH5TxEG3riUi4VYUPg9E9uj7XFOX Cmubhk8xf3wEXUQAevUduUEiSPlR3KXAbywyz4Fbo0ZtzhTowGh8M4RmYx4/4aNKnue/ PIxEHN9U6s00hf+p1OULoPkJYZ0tUfYt/01L6mJplZL4Y8qgVrjKRPXGCZaEyEgx+Dlz RW5Zp8KuKfO1MYk8J0VX/CjurCDN9Eh/h7yRd2FjGTCNpjaeFU6ayHvDfUseq9n6BGSy dLhbKaWRTkm4EYQsd8LUyCl6QmQWdlbRmEl5ePc82An0cnEGqEU2W7qZr7BXWXCU4ssy H4nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=JyGaV4kIG1etfdTiM1IP3xaoF6yUaX7IwcRwvWDWZlw=; b=gz5HUEMuTUqHhXSTkwtdYfeUZXPOgzbeYhlt0JKnhha6lbzxf94vLWlDvaCiyuiZnV SuQT2fr8zUaCgfN3idHY4BlUdwzYyDejMhFttmdsWAwtzCbScd2FkrFhuyNuBqQzDXHd AoIq5NofMg3L2QrM/sedr44wN8ulYIV9HfTLVre2/AtA0Wxk06mocpQJHOSGatVW0SLE dhySJMKIJ9HiKTTnw6dEpBdqiLIRntEldd2me7XZneLz0x43/H45LK9NUoBkxiXFqoIz l3YVCjnGYhDvvXTGRQlLIq7EZOIeSjPIqXqIromPVrW7ewfdLjbAlw9lLE1DX4K2MjEj o5dA== 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 m32-v6si4174095pld.125.2018.03.15.07.50.01; Thu, 15 Mar 2018 07:50:34 -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 S1752687AbeCOOri (ORCPT + 99 others); Thu, 15 Mar 2018 10:47:38 -0400 Received: from foss.arm.com ([217.140.101.70]:40058 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbeCOOrf (ORCPT ); Thu, 15 Mar 2018 10:47:35 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AB69D16BA; Thu, 15 Mar 2018 07:47:34 -0700 (PDT) Received: from e105550-lin.cambridge.arm.com (e105550-lin.cambridge.arm.com [10.1.211.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 327FE3F487; Thu, 15 Mar 2018 07:47:33 -0700 (PDT) From: Morten Rasmussen To: peterz@infradead.org, mingo@redhat.com Cc: valentin.schneider@arm.com, dietmar.eggemann@arm.com, vincent.guittot@linaro.org, gaku.inami.xh@renesas.com, linux-kernel@vger.kernel.org, Morten Rasmussen Subject: [PATCHv2 6/7] sched: Wrap rq->rd->overload accesses with READ/WRITE_ONCE Date: Thu, 15 Mar 2018 14:47:03 +0000 Message-Id: <1521125224-15434-7-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521125224-15434-1-git-send-email-morten.rasmussen@arm.com> References: <1521125224-15434-1-git-send-email-morten.rasmussen@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Valentin Schneider This variable can be read and set locklessly within update_sd_lb_stats(). As such, READ/WRITE_ONCE are added to make sure nothing terribly wrong can happen because of the compiler. cc: Ingo Molnar cc: Peter Zijlstra Signed-off-by: Valentin Schneider Signed-off-by: Morten Rasmussen --- kernel/sched/fair.c | 6 +++--- kernel/sched/sched.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index fe4824a37302..4e79ec8760be 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8220,8 +8220,8 @@ static inline void update_sd_lb_stats(struct lb_env *env, struct sd_lb_stats *sd if (!env->sd->parent) { /* update overload indicator if we are at root domain */ - if (env->dst_rq->rd->overload != overload) - env->dst_rq->rd->overload = overload; + if (READ_ONCE(env->dst_rq->rd->overload) != overload) + WRITE_ONCE(env->dst_rq->rd->overload, overload); } } @@ -9659,7 +9659,7 @@ static int idle_balance(struct rq *this_rq, struct rq_flags *rf) rq_unpin_lock(this_rq, rf); if (this_rq->avg_idle < sysctl_sched_migration_cost || - !this_rq->rd->overload) { + !READ_ONCE(this_rq->rd->overload)) { rcu_read_lock(); sd = rcu_dereference_check_sched_domain(this_rq->sd); diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 5379f647016d..31847b7f7d47 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1651,8 +1651,8 @@ static inline void add_nr_running(struct rq *rq, unsigned count) if (prev_nr < 2 && rq->nr_running >= 2) { #ifdef CONFIG_SMP - if (!rq->rd->overload) - rq->rd->overload = 1; + if (!READ_ONCE(rq->rd->overload)) + WRITE_ONCE(rq->rd->overload, 1); #endif } -- 2.7.4