Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3891281pxv; Mon, 19 Jul 2021 11:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdb5N7+vXz6ErRq1uT8apKwQgPs8dA8xe37a8tO9Ayx2A6VBwgu+g8mxPcdWEmE6kx1+1+ X-Received: by 2002:a05:6638:2493:: with SMTP id x19mr10294186jat.102.1626718494336; Mon, 19 Jul 2021 11:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626718494; cv=none; d=google.com; s=arc-20160816; b=UGcF3sDHaHC5B1UQ0pyAepVFo1/KR+IUI3KPAtNNxGEP1iqNtaaJOOQZLMsZJqttmS E9wMj06mapcyWPzahX9Sqy+BcNDTTNYJUJ4VT6ejkChhIjHp2icd9xO7T1Fle8UAaHxo Qu4/r+FYY872BeY2KrgWDWF5yenDxcZN4+j3ysSkqWGNhfVrJ8IOGYF+mmP7mt42tv5P QvzyfGhnQiORmVger520dQjwnuJovvu6YAm1962LvIFnhr+yBJpQjmBLAzrhRhchY2ov 12d57uXxGJBRySONwrNXXpXYcd0qsnsL0iCKrZMYepn1zfVxfKKBB8JA3n8DPVaNnMlR +ecA== 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=pwIzGAO3RONhQWHMdzO/8t2A1PQJ5rqxTkOFEtVxdz8=; b=YNyl4JyuyCZvhKI4bdQafc/GDgQfK2oH6MZyae7Nu9S/meuMQIj+xplJVuQtVWew7u qWs64jWtas/QI63nLXI4KQSojA2vnA9I35HtT1QrjB0YtMgOIM6hQF3xYUbhx2dTQZ9B 2NvuuZBybTwM0Sz5YLW4RowEiR/rFU6i+rkg2PFlz7sl5ORC9PJj/s0JFOayToEcRXEz FMkHKoClbpIiYv04PjAXYURfrUYXVBRw9LRV8czU7QVXAFT59s/1hZy/OELaj6Et1oYe RAqMlkjvKv5fNoqjeoCM/7aW9zmTdLBB8GdT04mKRjnxJ5NAVrZ+m2ItbebSyqGruhbB 7Inw== 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 x5si1022900ilq.85.2021.07.19.11.14.42; Mon, 19 Jul 2021 11:14:54 -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 S1377757AbhGSRcI (ORCPT + 99 others); Mon, 19 Jul 2021 13:32:08 -0400 Received: from foss.arm.com ([217.140.110.172]:36276 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346338AbhGSPsO (ORCPT ); Mon, 19 Jul 2021 11:48:14 -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 3B00F1FB; Mon, 19 Jul 2021 09:28:50 -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 6C87B3F73D; Mon, 19 Jul 2021 09:28:49 -0700 (PDT) From: Valentin Schneider To: Dietmar Eggemann , linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Vincent Guittot Subject: Re: [PATCH v2 2/2] sched/fair: Trigger nohz.next_balance updates when a CPU goes NOHZ-idle In-Reply-To: References: <20210719103117.3624936-1-valentin.schneider@arm.com> <20210719103117.3624936-3-valentin.schneider@arm.com> Date: Mon, 19 Jul 2021 17:28:44 +0100 Message-ID: <878s22mfnn.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/07/21 17:24, Dietmar Eggemann wrote: > On 19/07/2021 12:31, Valentin Schneider wrote: > > [...] > >> @@ -10351,6 +10352,9 @@ static void nohz_balancer_kick(struct rq *rq) >> unlock: >> rcu_read_unlock(); >> out: >> + if (READ_ONCE(nohz.needs_update)) >> + flags |= NOHZ_NEXT_KICK; >> + > > Since NOHZ_NEXT_KICK is part of NOHZ_KICK_MASK, some conditions above > will already set it in flags. Is this intended? So if no kick would be issued (e.g. flags == 0 because nohz.next_balance is later in the future), then this does the right thing and issues a NOHZ_NEXT_KICK one. However you're right to point out that even if nohz.needs_update is false, we can set NOHZ_NEXT_KICK into the ilb rq's NOHZ flags due to it being included in NOHZ_KICK_MASK, which I think is a mistake. Looking at it now, it shouldn't be part of NOHZ_KICK_MASK. > >> if (flags) >> kick_ilb(flags); >> } >> @@ -10447,12 +10451,13 @@ void nohz_balance_enter_idle(int cpu) >> /* >> * Ensures that if nohz_idle_balance() fails to observe our >> * @idle_cpus_mask store, it must observe the @has_blocked >> - * store. >> + * and @needs_update stores. >> */ >> smp_mb__after_atomic(); >> >> set_cpu_sd_state_idle(cpu); >> >> + WRITE_ONCE(nohz.needs_update, 1); >> out: >> /* >> * Each time a cpu enter idle, we assume that it has blocked load and >> @@ -10501,13 +10506,17 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, > > function header would need update to incorporate the new 'update > nohz.next_balance' functionality. It only talks about 'update of blocked > load' and 'complete load balance' so far. > >> /* >> * 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. >> + * set the has_blocked flag and trigger 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. >> + * >> + * Same applies to idle_cpus_mask vs needs_update. >> */ >> if (flags & NOHZ_STATS_KICK) >> WRITE_ONCE(nohz.has_blocked, 0); >> + if (flags & NOHZ_NEXT_KICK) >> + WRITE_ONCE(nohz.needs_update, 0); >> >> /* >> * Ensures that if we miss the CPU, we must see the has_blocked >> @@ -10531,6 +10540,8 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, >> if (need_resched()) { >> if (flags & NOHZ_STATS_KICK) >> has_blocked_load = true; > > This looks weird now? 'has_blocked_load = true' vs > 'WRITE_ONCE(nohz.needs_update, 1)'. > Well, has_blocked_load lets us factorize the nohz.has_blocked write (one is needed either when aborting or at the tail of the cpumask iteration), whereas there is just a single write for nohz.needs_update (when aborting). >> + if (flags & NOHZ_NEXT_KICK) >> + WRITE_ONCE(nohz.needs_update, 1); >> goto abort; >> } >> >>