Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp519498imm; Wed, 20 Jun 2018 02:07:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJoy1RwwC+yM8wYXdxJ0D8FKF9zZGIoGxf3w+1pkzma9fXxuhbogZI1mtXiswkfGI5as4+d X-Received: by 2002:a63:8f56:: with SMTP id r22-v6mr1294251pgn.17.1529485674010; Wed, 20 Jun 2018 02:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529485673; cv=none; d=google.com; s=arc-20160816; b=Lh7uouYt0nk0MZq0IQHv8wrwThl5LDPedUVmPJxlT2X1KuZcKWWzzw5NKcwRahXCqe KdWTDBzSnBWBl9lUP3ESWrRVEvwylwmYnIVWwNWc/gagVHQ8ynqvz9C007yMcHXFkRk5 HhjJSYJf0e1qhCtRH678ONU83piRLvAsNvbeTh4YnZLuy7bf6wql56YBDX4Ve8TFE7P1 L9TCjytuS4rYMzXcFhaNEe0YWGEOFPFcAI40Z6zrSqy7niNmVlSur/RdKtsKJYHo17Ma EZ+HTOTRi8/ffTBMY60IleY9c2LERrYn1KRMJnxnGgzhobY6BewuokCVHZkgSsMXIACG 21qg== 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=tZR60sJwMSLdeIEUFsRXy96T1boCGUMvVNT+G3gGCTs=; b=PF9i6/axLrV5BTAQpvQOyoWlpJioOBMUywgsABvx1w2KuE2FKzGFTITkI2lqIqCxXK io6YuJLZZepCOXXQedUMjQjddhYRah0N9txf09V8zgczHwM+RWGbj0yNvqnOn4Vt5vGK Gcwg9w/nDp1wk6H+O+1e2Ia7FPhRlEu3VjMqovjz2Z3GVAFdfS4cuwd8zK6IPhokxI/E t9cfLPdZm+sysCYlzWPl8SAKzgM5rVqK3nB9apsW7oQmGusphCf5etY8I1yMrwortbFy PcEVICUQXm24AfzKdEN0bOd+lIfYTrt+JUgsAbN1xXGpeWKDpXaoJN1vwX3+sZM3ouGF Br1g== 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 z15-v6si1517969pgo.428.2018.06.20.02.07.39; Wed, 20 Jun 2018 02:07:53 -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 S932508AbeFTJG4 (ORCPT + 99 others); Wed, 20 Jun 2018 05:06:56 -0400 Received: from foss.arm.com ([217.140.101.70]:34018 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754813AbeFTJGu (ORCPT ); Wed, 20 Jun 2018 05:06:50 -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 AE2311682; Wed, 20 Jun 2018 02:06:50 -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 36D893F246; Wed, 20 Jun 2018 02:06:49 -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: [PATCHv3 7/9] sched: Wrap rq->rd->overload accesses with READ/WRITE_ONCE Date: Wed, 20 Jun 2018 10:05:47 +0100 Message-Id: <1529485549-5191-8-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529485549-5191-1-git-send-email-morten.rasmussen@arm.com> References: <1529485549-5191-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 545fa3600894..9dd147c71dd0 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8431,8 +8431,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); } } @@ -9875,7 +9875,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 f945edadd2c5..791d9badad31 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1665,8 +1665,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