Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3745791pxj; Tue, 11 May 2021 10:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyV8Gp+XIROCQwVi3+AKwJggWdQhQcFxAjP7U22RdjucvHi4b0gMkgx+DG3yBRYaTP4pXA X-Received: by 2002:aa7:c15a:: with SMTP id r26mr38584394edp.78.1620755875634; Tue, 11 May 2021 10:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620755875; cv=none; d=google.com; s=arc-20160816; b=Bh+A8gBKiV4Y9VAsKYAFbTSHaUWuzUzxp8ec2lFGdzAAOrVWyygL64QW3HfuBOgQMp DXnHvkh4EShDaSVo5zeyijHkXvp5CnPTjjCc69Vuw17s7Fmq3RRuYQfoiARXZJThxevJ iI00vyNn5uRvD5kA+xwjB9GErvi9yegOnib40fwZv2G1TxQ9EXXEK2cKpiOEcx1pH69z ZW0Wza263Ujn+vJruEsKQtsK6YYWeDv4HtE3cjfMVxYo5+ZZrM2UVVP5YR88YWeUcWUF gAIa3WfQkxbTi+JDkv4f1D+65xVJUICfJLVgPwwqX+02rajuDvYdNzBgfQ+A1x3PJJyE p1Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SEieUtF82cL+QRqYe/uJoshXeUJzCNwZD1aMuDjUEa8=; b=nI9GDAkOfbxxR1aMujHvy3uIVjc3WWEpohJUUUdDmrZDPIonEjbQ+jmKE0Z9ocALHB CS7dSmoNHpggQyHnqDvybp7Le2C2vIEud5VPajxtUBwq2MlbGtYmXcLvAXQmm1nphXUh jQhACrvKCJGUp4ePScl65ZullQcc6vf4WdmoeUyNmqpsqf1+AezKjF8Cxgsx/cIuIK5a IPyMQ/9hcgzx3BfcDsL47P9k05b1FWku6kP+j+v2JtVNsa+Yx9q+5MKcT94Q/dpYrlfn jhH0obTi/GW9hmbZspY6wPLnNsHyWt9uY2JCbjsyW0G/7ec0rr89j1T7h3sjdrZMSgy4 vkuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K0AP15lt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si17338438edw.187.2021.05.11.10.57.31; Tue, 11 May 2021 10:57:55 -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; dkim=pass header.i=@linaro.org header.s=google header.b=K0AP15lt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231824AbhEKR5o (ORCPT + 99 others); Tue, 11 May 2021 13:57:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231437AbhEKR5n (ORCPT ); Tue, 11 May 2021 13:57:43 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6594C061574 for ; Tue, 11 May 2021 10:56:36 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id p20so2248138ljj.8 for ; Tue, 11 May 2021 10:56:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SEieUtF82cL+QRqYe/uJoshXeUJzCNwZD1aMuDjUEa8=; b=K0AP15ltFkL8ZDnZI9Icyd51/g6JgY11d8ECI5jXb6AT0Seua97+vUY/LncHtdeFal ruPemTK4YW3vDuSQqezNQNh9bpum/zvk3lMwd2CwetRAU8dWxEtaVoHUgo/wOxxM52Tv i0eubTVMvtqkaFsEVtU6pKUOWSI1WYW3ri3uV1FSG/RnuYBwC7s3/EpjLBk5pcgbSwPS rxbj2LWqxrh+b4M4QYZNS1mM6TO/EwcC3rv8v+09sZI6ThP3cEwp9JvTPRbitarz1akJ m/AYVjtOx3HhTeJH1HvrYENZ3uBLzR9OsQTP9GSVljS2fSUJ3PsPPrXsbjChrvJWHDuQ FOEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SEieUtF82cL+QRqYe/uJoshXeUJzCNwZD1aMuDjUEa8=; b=eZUSwlisJ8bNjFpV8Ez0SCluMhyBTu7/O33bHyebDVglnONc5PnxoWitus4yNKf8Wt +CoZoDqSp4fG4qe7Ubt9d16ZL8NTVTUmkWyNOmUCPjIDxI7ODYPlCTNY5ZRa10PzmNXR Sn+fy6FG71E8eXMBNIqctAJf3Tx8lHF5RvZChZZa0OdWvcd12vPUMij/pibGmvuZ9wWK EylAccPan73j3PSArQINQF9Wu7EDrAP9WVeiOffM9GRG3rgSlGLao43UHbeG3RwC6ShA s1USxKbjvE/Ia3WKtAGaZJcJsgfJr9rJSQ471nl2u4d7oGGcUkeS0lDXHWCULs90nvrA sRRA== X-Gm-Message-State: AOAM533iUUXkE0KAztZ/udsRmlYDRGYTbwHwdmILRZqUxZRXDQjO1Iuz PDoPo2S9G4eA6JzS4Zso9hATtH4o/raiyx31WwWw5A== X-Received: by 2002:a2e:151e:: with SMTP id s30mr25241212ljd.445.1620755795356; Tue, 11 May 2021 10:56:35 -0700 (PDT) MIME-Version: 1.0 References: <20210122154600.1722680-1-joel@joelfernandes.org> <20210129172727.GA30719@vingu-book> <274d8ae5-8f4d-7662-0e04-2fbc92b416fc@linux.intel.com> <20210324134437.GA17675@vingu-book> <4aa674d9-db49-83d5-356f-a20f9e2a7935@linux.intel.com> <2d2294ce-f1d1-f827-754b-4541c1b43be8@linux.intel.com> <577b0aae-0111-97aa-0c99-c2a2fcfb5e2e@linux.intel.com> In-Reply-To: <577b0aae-0111-97aa-0c99-c2a2fcfb5e2e@linux.intel.com> From: Vincent Guittot Date: Tue, 11 May 2021 19:56:23 +0200 Message-ID: Subject: Re: [PATCH] sched/fair: Rate limit calls to update_blocked_averages() for NOHZ To: Tim Chen Cc: Joel Fernandes , linux-kernel , Paul McKenney , Frederic Weisbecker , Dietmar Eggeman , Qais Yousef , Ben Segall , Daniel Bristot de Oliveira , Ingo Molnar , Juri Lelli , Mel Gorman , Peter Zijlstra , Steven Rostedt , "Uladzislau Rezki (Sony)" , Neeraj upadhyay , Aubrey Li Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 11 May 2021 at 19:25, Tim Chen wrote: > > > > On 5/11/21 8:25 AM, Vincent Guittot wrote: > > Hi Tim, > > > > Sometimes, we want to set this_rq->next_balance backward compared to > > its current value. When a CPU is busy, the balance interval is > > multiplied by busy_factor which is set to 16 by default. On SMT2 sched > > domain level, it means that the interval will be 32ms when busy > > instead of 2ms. But if a busy load balance happens just before > > becoming idle, the this_rq->next_balance will be set 32ms later > > whereas it should go down to 2ms as the CPU is now idle. And this > > becomes even worse when you have 128 CPUs at die sched_domain level > > because the idle CPU will have to wait 2048ms instead of the correct > > 128ms interval. > > > >> > >> out: > >> /* Move the next balance forward */ > >> - if (time_after(this_rq->next_balance, next_balance)) > >> + if (time_after(next_balance, this_rq->next_balance)) > > > > The current comparison is correct but next_balance should not be in the past. > > I understand then the intention is after the update, > this_rq->next_balance should have a minimum value of jiffies+1. So > we will need > > out: > /* Move the next balance forward */ > + this_rq->next_balance = max(jiffies+1, this_rq->next_balance); > if (time_after(this_rq->next_balance, next_balance)) > this_rq->next_balance = next_balance; > > as next_balance computed will be at least jiffies+1 after your fix to > update_next_balance(). We still need to take care of the case when > this_rq->next_balance <= jiffies. > > So combining with your suggestion on the fix to update_next_balance(), > the fix will be > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 1d75af1ecfb4..2dc471c1511c 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -9901,7 +9901,7 @@ update_next_balance(struct sched_domain *sd, unsigned long *next_balance) > > /* used by idle balance, so cpu_busy = 0 */ > interval = get_sd_balance_interval(sd, 0); > - next = sd->last_balance + interval; > + next = max(jiffies+1, sd->last_balance + interval); > > if (time_after(*next_balance, next)) > *next_balance = next; > @@ -10681,6 +10681,7 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf) > > out: > /* Move the next balance forward */ > + this_rq->next_balance = max(jiffies+1, this_rq->next_balance); > if (time_after(this_rq->next_balance, next_balance)) > this_rq->next_balance = next_balance; > > > > > > update_next_balance() is only used in newidle_balance() so we could > > modify it to have: > > > > next = max(jiffies+1, next = sd->last_balance + interval) > > Is the extra assignment "next = sd->last_balance + interval" needed? No it's a typo mistake while copy pasting the line > This seems more straight forward: > > next = max(jiffies+1, sd->last_balance + interval) > > I will try to get the benchmark folks to do another run with this change. > Hopefully I'll get some bandwidth from them soon. > > Thanks. > > Tim >