Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp445077pxv; Thu, 15 Jul 2021 07:53:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUaMLA4YTWBIfnWAYxmSLMZaxg91CMa+yfOHSqH3vhnY+ILe/xGniiXFHtlBY0xzY1wAF0 X-Received: by 2002:a17:906:ee9:: with SMTP id x9mr5480361eji.44.1626360803767; Thu, 15 Jul 2021 07:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626360803; cv=none; d=google.com; s=arc-20160816; b=F6+31ffGN/2duhFSlzvIZR6AG5Zk9Ev5Kzy39gSqpB7SOf52iWNAPUAcIsw9xnjbmq cjAi/tBzSSS2e+Nf5kAasKeVmiXdkOsXdWaX/EAfmoH0uCyuDEjff6H6kijDEuee2Ed1 ryEeMT/gr9qRfyIqwqMFBlVjWcTUM/mC5ru7GRXlTggwYs+yM5k4ma3fswgI9abkafmh epZ7TV3WYrUAZzOUf8A859hpcz2Hvp75onfJ9TYXcOit6YxkZdP0VPeHkyhrHHo16gNN /MPygCiIEij8vZCbGK3bHAhw0bvVS4sipGwqFdfuSlHpMGciUWBukuUKfpEhv7L6M0ct dumQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=RnxcD06O7K2xcRbbYIGohE5aLC2IQrVtm7LxsT+jGlY=; b=uvPf9Qpwgp3C0Z3J3dp7Ill75iOGgKp39M3jwuhbsSAh5ZpqCWPVm7N+DKWq+YMKzr bT3Laa5dWZxZvlp8xyrVi+DGWF+iiy6ZfuLmKeMMA2j3TNvqzuQZgQ/vppufbodUE4XE /jQBAeAg/oF/cleU0LlItHnoeOU27+JkXMsnPkPEmBqyzXvrcXYjcbmDj1MmtKKZRFFo uEhGi9iciYqAqF3tmS3UKKtjY2xTtSUWryVSOp3/yj3xN5KRe4hVHwv9NsrummiFfmTA 0EOfMvJFdq9LTS3U584JumKjyb9+1HYdzirqBbu7mKVG1Rj0JfC86gc/jDnYkdQ9bnjn 7pFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x25si7236563ejs.544.2021.07.15.07.53.00; Thu, 15 Jul 2021 07:53:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237916AbhGOOyQ (ORCPT + 99 others); Thu, 15 Jul 2021 10:54:16 -0400 Received: from foss.arm.com ([217.140.110.172]:53382 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231745AbhGOOyQ (ORCPT ); Thu, 15 Jul 2021 10:54:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8664B6D; Thu, 15 Jul 2021 07:51:22 -0700 (PDT) Received: from e113632-lin (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2B853F774; Thu, 15 Jul 2021 07:51:21 -0700 (PDT) From: Valentin Schneider To: Vincent Guittot Cc: linux-kernel , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann Subject: Re: [PATCH] sched/fair: Update nohz.next_balance for newly NOHZ-idle CPUs In-Reply-To: References: <20210714113928.2795632-1-valentin.schneider@arm.com> <87lf67n63p.mognet@arm.com> Date: Thu, 15 Jul 2021 15:51:19 +0100 Message-ID: <87fswfmxzs.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/07/21 15:01, Vincent Guittot wrote: > On Thu, 15 Jul 2021 at 13:56, Valentin Schneider wrote: >> On 15/07/21 09:42, Vincent Guittot wrote: >> > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >> > index 44e44c235f1f..91c314f58982 100644 >> > --- a/kernel/sched/fair.c >> > +++ b/kernel/sched/fair.c >> > @@ -10657,6 +10657,9 @@ static void nohz_newidle_balance(struct rq *this_rq) >> > if (this_rq->avg_idle < sysctl_sched_migration_cost) >> > return; >> > >> > + if (time_before(this_rq->next_balance, READ_ONCE(nohz.next_balance)) >> > + WRITE_ONCE(nohz.need_update, 1); >> > + >> >> I think we have to do this unconditionally, as we can observe the old >> nohz.next_balance while a NOHZ balance is ongoing (which will update >> nohz.next_balance without taking into account this newly idle CPU). > > so maybe add this in nohz_balance_enter_idle() after the > smp_mb__after_atomic(). Ilb will see the cpu in the idle_cpus_mask so > even if nohz.next_balance is updated, it will take into account this > newly idle cpu > > My goal was to use mechanism similar to what is used of nohz.has_blocked > OK, and then clearing it above the smp_mb() in _nohz_idle_balance() should give us similar guarantees to nohz.has_blocked (i.e. if we don't observe the cpumask write, then we'll observe the needs_update write). Thanks for the suggestion, I'll go test this out.