Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3739210ybz; Mon, 4 May 2020 08:50:05 -0700 (PDT) X-Google-Smtp-Source: APiQypJOX3eR7sg2BafeDDdm2/vKNc3ST5z0l22IXLrnqdYEiMAJ4TbhBMsXDRbN3QzXyhZhLKin X-Received: by 2002:a17:906:6a48:: with SMTP id n8mr14995972ejs.315.1588607405380; Mon, 04 May 2020 08:50:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588607405; cv=none; d=google.com; s=arc-20160816; b=rnIWGE/vIwwE6xtHmZuab985e/9eeCOF2yBYUsvcZ3poWWt8KsYUfp5Vb6L2XtkZ44 u31OjnK1LUB5cq5EhPX2VCre1aFoDpTdq1U/u7HdI4SDTQJFhLXhqbxzFG/9c6SvMGnU B0JBo/++5+WalMfhGC+F1w5kW/PX24mjDfgsAfkN/zLFp5F19104Tu2Ad1eC2EqBR6mj BmatH0b83j124Nh0vAluiqG/r9yb0xBqnqgvdyXvhq3VDTyBPbi0dJ3A64JD+BL8Ka5e xsU3X0Uik+ixmwmWJ2K+e18bKi6Dbh8IeTz4yGj+95zgCEdYjbECtNTiQjKfMm0v4YuM V9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:in-reply-to :subject:cc:to:from:user-agent:references; bh=6zn1FwD8LEr5UoRX8hIowrelm843ipIQ6tU6JM1Rdfk=; b=oPES7ailfyHACumuzPl0/v/3WmpAGItRkNG8zJXSkSUnUmq2JdXk4jSYBtHoSQOc1w sILkuNn7jZrqB6E/qTpnO69GdDtLGhvJvKfwu8Sk8hydKbkpWTiEt/wkB5Hl9l6slYHH K/UheHNPKm3dImerQ47K8sjU3eRDfBY93A6AJDHh+sgmzEBIus8hcTY02x4GJgQy+N9b IQA39IqMoRsjSJOXwso/LoPGDeC5dj9O3/uFZMwPhpYV++NDCWLRUwWGROADn5oxS1rq iHrmbjsvsEQVd1um/6DmbQA/X5ypc3i4mqhXh10C5sNkQiTrlPQoPrgUtx6+UvmPh5EB DhFg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b21si4299721edr.47.2020.05.04.08.49.41; Mon, 04 May 2020 08:50:05 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728437AbgEDPsO (ORCPT + 99 others); Mon, 4 May 2020 11:48:14 -0400 Received: from foss.arm.com ([217.140.110.172]:47696 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbgEDPsO (ORCPT ); Mon, 4 May 2020 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 8E5CB1FB; Mon, 4 May 2020 08:48:13 -0700 (PDT) Received: from e113632-lin (e113632-lin.cambridge.arm.com [10.1.194.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1856A3F68F; Mon, 4 May 2020 08:48:11 -0700 (PDT) References: <20200503083407.GA27766@iZj6chx1xj0e0buvshuecpZ> User-agent: mu4e 0.9.17; emacs 26.3 From: Valentin Schneider To: Vincent Guittot Cc: Peng Liu , linux-kernel , Ingo Molnar , Peter Zijlstra , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman Subject: Re: [PATCH] sched/fair: Fix nohz.next_balance update In-reply-to: Date: Mon, 04 May 2020 16:48:06 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/05/20 16:17, Vincent Guittot wrote: > On Sun, 3 May 2020 at 10:34, Peng Liu wrote: >> >> commit c5afb6a87f23 ("sched/fair: Fix nohz.next_balance update") >> During idle load balance, this_cpu(ilb) do load balance for the other >> idle CPUs, also gather the earliest (nohz.)next_balance. >> >> Since commit: >> 'b7031a02ec75 ("sched/fair: Add NOHZ_STATS_KICK")' >> >> We update nohz.next_balance like this: >> >> _nohz_idle_balance() { >> for_each_cpu(nohz.idle_cpus_mask) { >> rebalance_domains() { >> update nohz.next_balance <-- compare and update >> } >> } >> rebalance_domains(this_cpu) { >> update nohz.next_balance <-- compare and update >> } >> update nohz.next_balance <-- unconditionally update >> } >> >> For instance, nohz.idle_cpus_mask spans {cpu2,3,5,8}, and this_cpu is >> cpu5. After the above loop we could gather the earliest *next_balance* >> among {cpu2,3,8}, then rebalance_domains(this_cpu) update >> nohz.next_balance with this_rq->next_balance, but finally overwrite >> nohz.next_balance with the earliest *next_balance* among {cpu2,3,8}, >> we may end up with not getting the earliest next_balance. >> >> Since we can gather all the updated rq->next_balance, including this_cpu, >> in _nohz_idle_balance(), it's safe to remove the extra lines in >> rebalance_domains() which are originally intended for this_cpu. And >> finally the updating only happen in _nohz_idle_balance(). > > I'm not sure that's always true. Nothing prevents nohz_idle_balance() > to return false . Then run_rebalance_domains() calls > rebalance_domains(this_rq ,SCHED_IDLE) outside _nohz_idle_balance(). > In this case we must keep the code in rebalance_domains(). > > For example when the tick is not stopped when entering idle. Or when > need_resched() returns true. > I had missed that, good points. > So instead of removing the code from rebalance_domains, you should > move the one in _nohz_idle_balance() to make sure that the "if > (likely(update_next_balance)) ..." is called before calling > rebalance_domains for the local cpu > Why not just get rid of the update in _nohz_idle_balance() entirely then? The nohz.next_balance update in rebalance_domains() will always happen if it is required (and we have idle == CPU_IDLE), so the extra update in _nohz_idle_balance() doesn't seem to be any useful.