Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp633281imm; Wed, 4 Jul 2018 03:21:21 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcWvh7yVfEHQ7dl3ANj6wQCaUSS9ZrVgoLT89EI0PLjB/0jq8nRgCNadhANhMw9BeHCDbKq X-Received: by 2002:a63:8341:: with SMTP id h62-v6mr1335105pge.298.1530699681333; Wed, 04 Jul 2018 03:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530699681; cv=none; d=google.com; s=arc-20160816; b=gz/RU1I6iS2kmSNwezRQ2F/zL8En0YpE4bg3XOu+3TpJJhIsKacXyuioQcLiN0Aevq uLpqDyZjH3fzDe1j0bVBuTasRcOElstQwV0tDpxv3OFVDcDK7b0tT54fiE7iFBkbjOnH IqtePxWdV7+D11mcUquQZOtODVTbLPD/QfHWk4nNWvyAkd4Vdxs9bZSv8seIy+HQYGxb //fEjqxm01oVrKwKAPcB8N8O3u3X04nFUmszWL9yQeiFwkR2RRSALJ49SMZHSnH1h5DN 8C3Bs/YeLpzimKxBIFqnSAWarQUwsGtzpuzZL4+Zj6DbRhwyoRC/vdmw2x5ZlX2tfzsy pKag== 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=fAL2qgmnLENMLA5lT8Z+7ZvcDNA/nMk/2xsyFg02gbs=; b=M3zRIPCbrmwSNW+D0N8BKHuwOkC46YTjlxomtGWKLo7S3tQxMOohD+lN414uoeB6Lg tMJKhw9ee0IaxDaNP/fVDaG0aJ3JoVbU9XWruSdspmRUUrb7JnktcnjNNPyS+ch22vrJ /EtlyQJXuh5nHyeV/eUhQW7VY6aGcYTTveGqpGS2dMcsq7rSkrfQuLNKu/qmrwJV+On1 7wjLrvQoUuuys3jYiFoIWgyyDBIX0ORA+/fm/pVCH+SJOxDKlaIOc4aOZlmCKJavZ8zc p1rXtsSzy7kfFhcAJ+IrbrgZER7DwsV8Z6AX31A8txz+qSM0XC+YvCQ1hGoGXQqax+Pv 4rbw== 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 16-v6si1831792pgr.325.2018.07.04.03.21.07; Wed, 04 Jul 2018 03:21:21 -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 S934146AbeGDKTt (ORCPT + 99 others); Wed, 4 Jul 2018 06:19:49 -0400 Received: from foss.arm.com ([217.140.101.70]:35076 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934515AbeGDKSZ (ORCPT ); Wed, 4 Jul 2018 06:18:25 -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 F0B0880D; Wed, 4 Jul 2018 03:18:24 -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 722C13F5AD; Wed, 4 Jul 2018 03:18:23 -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: [PATCHv4 08/12] sched: Wrap rq->rd->overload accesses with READ/WRITE_ONCE Date: Wed, 4 Jul 2018 11:17:46 +0100 Message-Id: <1530699470-29808-9-git-send-email-morten.rasmussen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530699470-29808-1-git-send-email-morten.rasmussen@arm.com> References: <1530699470-29808-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 ee26eeb188ef..d0641ba7bea1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8428,8 +8428,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); } } @@ -9872,7 +9872,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 648224b23287..e1dc85d1bfdd 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1672,8 +1672,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