Received: by 10.223.185.116 with SMTP id b49csp1033059wrg; Fri, 16 Feb 2018 11:10:14 -0800 (PST) X-Google-Smtp-Source: AH8x226DjceaRcbDRCqEv1adK+oSYo36qeoxDVgd4B2YJlaPI2dtMPR+QajoQCovlXz/4A6e2xm3 X-Received: by 10.98.131.139 with SMTP id h133mr6953086pfe.155.1518808214135; Fri, 16 Feb 2018 11:10:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518808214; cv=none; d=google.com; s=arc-20160816; b=txgKI9X10Ey+VSplNncgmw9xJH4VeHRmfUPiVdae5b88KsFqbqceSfVjGzZ/rvg5VH K1Wz74CwDMXJL/cUKaAB9qfrZN06X8nJ1/vh2Qdm+eAWpmdqN7WHQ9O2bB02sZodKhya yXe0CaqPWx94TH8j13nLmvt5QGnQU00X4PGIwqQymb2iRimBbmdQH8rXV9RRebjbeIH/ l7BPDTs/Ubg9moVgBgwHsE0djlUhd1+EZua1EdeOyi2pqXhG1abGQdY+OtbhjzpXzhaw L4vmJ238mYShFj29jsgQFmALAP45iZfni5orcg32utI6+2k3C5BeqxoZeIHT0L+6XGx+ J+pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=eiAIQkW19Uch1ib4zSv2Arv3cvuG/TaHkdlxTGx3i04=; b=lNWLlSbfFgZjoLxoCQfJmjmGuzn+F5GttdisEmrDJkpSA27eBSQHSKZw2qX8VZ8/eQ 1otneO15pPvIUk03vRVx2Mm8WmOQ0ZY85O6u2WoKFk5q8zEHkpxBAwVj9KRkJwWnQOBH L/G/rzEOoEH6OZmPALchgJWBPhhEfFajPuVAvz0byNqHnfrXvLCHwliZ/7oyvFLpkqUp KnJyvmwzrRKHRHm4FGeMXT+CPjgjDptp20EmdBnlxhzn0PHucaUnVhs69kb1COoR66zb XfIPDwBpctemqw7/N1Zy3eRbg5OVlJamteoKrBC+BIOQ7w9Vad9knX662opIG7k4eh1O KU+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S3lfu8Zq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6-v6si3347913plj.126.2018.02.16.11.09.59; Fri, 16 Feb 2018 11:10:14 -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=@linaro.org header.s=google header.b=S3lfu8Zq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031995AbeBPNo3 (ORCPT + 99 others); Fri, 16 Feb 2018 08:44:29 -0500 Received: from mail-io0-f196.google.com ([209.85.223.196]:46201 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031757AbeBPNoZ (ORCPT ); Fri, 16 Feb 2018 08:44:25 -0500 Received: by mail-io0-f196.google.com with SMTP id p78so4130163iod.13 for ; Fri, 16 Feb 2018 05:44:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eiAIQkW19Uch1ib4zSv2Arv3cvuG/TaHkdlxTGx3i04=; b=S3lfu8ZqAak0/E/ZxtHEFuIk0nzuyDXlfqlQSMWF6Ibxwlarpknln7L+Hk1afAsNlk CrjCZ8PE1aNJiSCS/nhVzDpljRBNLv4VW117IoVZrcMWDEWEkUOliqYVGS5vTZ0x/zCz kgDoqsiXDCMSNZHH2mflxyJoKMiAVBK1Q1/fo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eiAIQkW19Uch1ib4zSv2Arv3cvuG/TaHkdlxTGx3i04=; b=MZi5aDD/HqcFib0TII2Au/poGW60Y50jKY+gGFotojBYuYQXnn506mIDXT8VnGYuSD QmpLpLVi2plmvHOw3vsCeKXw5LUwuP71MHfWTBVtOsTUZ/EUtlRAlgtyjy5Q9ENFecUv +xIPwMIKQUsrtSJcMucihOPyWYV62778uNUKQSAM5+fOmdGH0hnHuv/HcEw4M/W219j1 QJdN/EpoAtkx7m0uy2kEp8/JpVS+RY576wg+dwCxWNAQCqY+f1mM99ThkGxbocdqRAa0 O7dz0nsoxYYfmsNvkX3L5LgKNKZdMI82XGUqhP+YXzKULDkt8MymVGYwK0ooPAFFAlpw 5xDw== X-Gm-Message-State: APf1xPDbg+65x9DXW7tCg9or0HtPgBqA8wLBR36t1RS5O3h8WCsAwHdH WN24o19SoO7cZKVuL7LLeE1o1ZaLUY97TN2i1NP1IcUi208= X-Received: by 10.107.6.161 with SMTP id f33mr8576590ioi.196.1518788664847; Fri, 16 Feb 2018 05:44:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.50.83 with HTTP; Fri, 16 Feb 2018 05:44:04 -0800 (PST) In-Reply-To: <44a7d9dc-f6f3-e003-44d6-b0c4aa7dc046@arm.com> References: <1518622006-16089-1-git-send-email-vincent.guittot@linaro.org> <1518622006-16089-2-git-send-email-vincent.guittot@linaro.org> <44a7d9dc-f6f3-e003-44d6-b0c4aa7dc046@arm.com> From: Vincent Guittot Date: Fri, 16 Feb 2018 14:44:04 +0100 Message-ID: Subject: Re: [PATCH v5 1/3] sched: Stop nohz stats when decayed To: Valentin Schneider Cc: Peter Zijlstra , Ingo Molnar , linux-kernel , Morten Rasmussen , Brendan Jackman , Dietmar Eggemann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16 February 2018 at 13:13, Valentin Schneider wrote: > On 02/14/2018 03:26 PM, Vincent Guittot wrote: >> Stopped the periodic update of blocked load when all idle CPUs have fully >> decayed. We introduce a new nohz.has_blocked that reflect if some idle >> CPUs has blocked load that have to be periodiccally updated. nohz.has_blocked >> is set everytime that a Idle CPU can have blocked load and it is then clear >> when no more blocked load has been detected during an update. We don't need >> atomic operation but only to make cure of the right ordering when updating >> nohz.idle_cpus_mask and nohz.has_blocked. >> >> Suggested-by: Peter Zijlstra (Intel) >> Signed-off-by: Vincent Guittot >> --- >> kernel/sched/fair.c | 122 ++++++++++++++++++++++++++++++++++++++++++--------- >> kernel/sched/sched.h | 1 + >> 2 files changed, 102 insertions(+), 21 deletions(-) >> >> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> index 7af1fa9..5a6835e 100644 >> --- a/kernel/sched/fair.c >> +++ b/kernel/sched/fair.c >> >> [...] >>> @@ -9374,6 +9427,22 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) >> >> SCHED_WARN_ON((flags & NOHZ_KICK_MASK) == NOHZ_BALANCE_KICK); >> >> + /* >> + * We assume there will be no idle load after this update and clear >> + * the has_blocked flag. If a cpu enters idle in the mean time, it will >> + * set the has_blocked flag and trig another update of idle load. >> + * Because a cpu that becomes idle, is added to idle_cpus_mask before >> + * setting the flag, we are sure to not clear the state and not >> + * check the load of an idle cpu. >> + */ >> + WRITE_ONCE(nohz.has_blocked, 0); >> + >> + /* >> + * Ensures that if we miss the CPU, we must see the has_blocked >> + * store from nohz_balance_enter_idle(). >> + */ >> + smp_mb(); >> + >> for_each_cpu(balance_cpu, nohz.idle_cpus_mask) { >> if (balance_cpu == this_cpu || !idle_cpu(balance_cpu)) >> continue; >> @@ -9383,11 +9452,16 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) >> * work being done for other cpus. Next load >> * balancing owner will pick it up. >> */ >> - if (need_resched()) >> - break; >> + if (need_resched()) { >> + has_blocked_load = true; >> + goto abort; >> + } >> >> rq = cpu_rq(balance_cpu); >> > > I'd say it's safe to do the following here. The flag is raised in > nohz_balance_enter_idle() before the smp_mb(), so we won't skip a CPU > that just got added to nohz.idle_cpus_mask. rq->has_blocked_load will be set before the barrier only if nohz_tick_stopped is not already set, Otherwise, we skip cpumask update and the barrier in nohz_balance_enter_idle > > /* > * This cpu doesn't have any remaining blocked load, skip it. > * It's sane to do this because this flag is raised in > * nohz_balance_enter_idle() > */ > if ((flags & NOHZ_KICK_MASK) == NOHZ_STATS_KICK && > !rq->has_blocked_load) > continue; > >> + update_blocked_averages(rq->cpu); >> + has_blocked_load |= rq->has_blocked_load; >> + >> /* >> * If time for next balance is due, >> * do the balance. >> @@ -9400,7 +9474,6 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) >> cpu_load_update_idle(rq); >> rq_unlock_irq(rq, &rf); >> >> - update_blocked_averages(rq->cpu); >> if (flags & NOHZ_BALANCE_KICK) >> rebalance_domains(rq, CPU_IDLE); >> } >> @@ -9415,7 +9488,13 @@ static bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle) >> if (flags & NOHZ_BALANCE_KICK) >> rebalance_domains(this_rq, CPU_IDLE); >> >> - nohz.next_stats = next_stats; >> + WRITE_ONCE(nohz.next_blocked, >> + now + msecs_to_jiffies(LOAD_AVG_PERIOD)); >> + >> +abort: >> + /* There is still blocked load, enable periodic update */ >> + if (has_blocked_load) >> + WRITE_ONCE(nohz.has_blocked, 1); >> >> /* >> * next_balance will be updated only when there is a need.