Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1836466pxb; Mon, 23 Aug 2021 06:00:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzInP6ZtyGHrC83T9RWaSzCWe1xG9iWxcuYrM4QabQijzKo/R1jPYgH9M+FWu+aucQSTuu X-Received: by 2002:a05:6402:10d9:: with SMTP id p25mr36581655edu.51.1629723608437; Mon, 23 Aug 2021 06:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629723608; cv=none; d=google.com; s=arc-20160816; b=sDAOLm+UMXagH56y5GAytk60SzrJjtRx0v1EHcJhNMPbRAry03mgpVFtYRCy3WBv2c BkaHQdrif/U30HjRVcfhAZn3d8D4YO0A5J+DrWz96y8CgC05m/vP7HBvoW2bkxJOi3TL Xqc6I9S+SSpsP/qC3xxnUbNVYBYqHW6IFWYzuvIzfEdpxnwV9NFIE25net7WNkLba9j2 P0gpg0eSur8Wj5PbjGiKW9Qirwje7TKh0EGHjT89kZYXY5xJuK2Z3KwHyUnQW+c6oYhl +sC+uwf8kVmdp+0rH5fDffmgVr8tWH09Hf3ualuhhriMlxGnU5giVGe60H0HwvPcPaJ+ BdWQ== 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=rUB1jEgaMyo+S7FHe9WPecovGaOGhii0DaQiCN0djSA=; b=seWeY9FxzQS5FpLmqzcfb14qb48bZJYKnDhCppXmwxB1pcrBJiLhZCAQ5+RK9EIUP8 NOOX8l4KFrgS4lh0zyHslx2cSaLrwOgJBvIax5yrzDG0aAgH8kf1j9PNfFajOMGyFKYc nMv8qO0buNdK08c/ZhDnbvR2cSZZpnt3aIoEjHOEEOGdr8ghMNP7lf7Wr8HqDz4WBCXL mB+PiXyZe9Fq/wcJJnIVqKch5Elz95yAWULEM0UXEyiTyWH1fLdVz+mdRLSShfGHQwYB I5GH/w0xL9ujOwzAxZi3pvz/OwxhOkxMtQrXIpelMig8pWQTxvIo7Stz1wlWA/KPa6j9 ZYdQ== 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 um14si14989951ejb.397.2021.08.23.05.59.43; Mon, 23 Aug 2021 06:00:08 -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 S236951AbhHWM6g (ORCPT + 99 others); Mon, 23 Aug 2021 08:58:36 -0400 Received: from foss.arm.com ([217.140.110.172]:53086 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236014AbhHWM6g (ORCPT ); Mon, 23 Aug 2021 08:58:36 -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 77B2E101E; Mon, 23 Aug 2021 05:57:53 -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 A90F13F5A1; Mon, 23 Aug 2021 05:57:52 -0700 (PDT) From: Valentin Schneider To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Vincent Guittot , Ingo Molnar , Dietmar Eggemann Subject: Re: [PATCH v3 1/2] sched/fair: Add NOHZ balancer flag for nohz.next_balance updates In-Reply-To: References: <20210823111700.2842997-1-valentin.schneider@arm.com> <20210823111700.2842997-2-valentin.schneider@arm.com> Date: Mon, 23 Aug 2021 13:57:46 +0100 Message-ID: <87fsv02u9h.mognet@arm.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/08/21 13:59, Peter Zijlstra wrote: > On Mon, Aug 23, 2021 at 12:16:59PM +0100, Valentin Schneider wrote: > >> Gate NOHZ blocked load >> update by the presence of NOHZ_STATS_KICK - currently all NOHZ balance >> kicks will have the NOHZ_STATS_KICK flag set, so no change in behaviour is >> expected. > >> @@ -10572,7 +10572,8 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, >> * 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); >> + if (flags & NOHZ_STATS_KICK) >> + WRITE_ONCE(nohz.has_blocked, 0); >> >> /* >> * Ensures that if we miss the CPU, we must see the has_blocked >> @@ -10594,13 +10595,15 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, >> * balancing owner will pick it up. >> */ >> if (need_resched()) { >> - has_blocked_load = true; >> + if (flags & NOHZ_STATS_KICK) >> + has_blocked_load = true; >> goto abort; >> } >> >> rq = cpu_rq(balance_cpu); >> >> - has_blocked_load |= update_nohz_stats(rq); >> + if (flags & NOHZ_STATS_KICK) >> + has_blocked_load |= update_nohz_stats(rq); >> >> /* >> * If time for next balance is due, >> @@ -10631,8 +10634,9 @@ static void _nohz_idle_balance(struct rq *this_rq, unsigned int flags, >> if (likely(update_next_balance)) >> nohz.next_balance = next_balance; >> >> - WRITE_ONCE(nohz.next_blocked, >> - now + msecs_to_jiffies(LOAD_AVG_PERIOD)); >> + if (flags & NOHZ_STATS_KICK) >> + WRITE_ONCE(nohz.next_blocked, >> + now + msecs_to_jiffies(LOAD_AVG_PERIOD)); >> >> abort: >> /* There is still blocked load, enable periodic update */ > > I'm a bit puzzled by this; that function has: > > SCHED_WARN_ON((flags & NOHZ_KICK_MASK) == NOHZ_BALANCE_KICK); > > Which: > > - isn't updated > - implies STATS must be set when BALANCE Yup > > the latter gives rise to my confusion; why add that gate on STATS? It > just doesn't make sense to do a BALANCE and not update STATS. AFAIA that warning was only there to catch BALANCE && !STATS, so I didn't tweak it. Now, you could still end up with flags == NOHZ_NEXT_KICK (e.g. nohz.next_balance is in the future, but a new CPU entered NOHZ-idle and needs its own rq.next_balance collated into the nohz struct) in which case you don't do any blocked load update, hence the gate. In v1 I had that piggyback on NOHZ_STATS_KICK, but Vincent noted that might not be the best given blocked load updates can be time consuming - hence the separate flag.