Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3458829pxb; Tue, 20 Apr 2021 08:45:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOAGREFC57bKBanzJKELL+MXZP5K4Z+Gsz6hFUNbHoGJh9Y4v/3NQzNJG9f8ZEGxHxKvC+ X-Received: by 2002:a17:902:a9c7:b029:e8:de49:6a76 with SMTP id b7-20020a170902a9c7b02900e8de496a76mr30338962plr.63.1618933552034; Tue, 20 Apr 2021 08:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618933552; cv=none; d=google.com; s=arc-20160816; b=woF6zNSx9YeQezT1eDLesu6pkjKE9/zwGWtdJSZK/5u+GOmc/OyIT36O3luozjiXKk X8xN7zZvmkOoIbWYCeW0tas+LjfJsAOiYjQjEzzcB7am7mo0XRbaSePZ6meIJiYUiWje 5aip2HYV8pP3s7y7xY5hnTCzfJN8LDvcVZ0HwJtL4Bo/dh8XUf0pwHBxdbjpQDm/+fNW Jor9PzgLt39zs/MLH2/k9P6dhrJAGeBV9rmHHQWGfcM/u8GNxWLzAuAslBcgmOWdW1bO NmK/j/ABkuLaghnsOI18b1vWObb4bIS5oWd4eaYs+ohC3BMjli58Rpp5o59TDN8QrlEE +iDQ== 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=BAPvvtwfIwS2cMONM+8rdChOeN4vzoXdvSyqPwacZ8s=; b=OhkNiCIwQOgL2HIRWMnsCIWP4o1p+n3eq8MjYV0kpGVjOR0bKbkk5vi1wVXwbNb2nh haMPS3ybbze9kEgbpclQs2pyhbVz0JIGvFFmkvxmUagRR0A8MyFxGa5qrj9bWnyFRZit A9rEOT8ZburaJshLI1JiULRzyAz+J5bpTdGY5rPSLThFdrKaf+58NLZRL1vwynNrZMI/ vviwm12iujS/Uy23+w1/1TUtfRuDWCA3tjymJ5MlmOrxTgkpgqzRa2uq2168kOyhqcGa hYEgGL9+xIOm4X/dhja3p/1+q+KD9DpkhB0C6H7fs9YDPKlCJf34IYGQ0S/IshjijW5J 4Vdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nNHda3qL; 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 c1si24772683pfv.12.2021.04.20.08.45.39; Tue, 20 Apr 2021 08:45:52 -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=nNHda3qL; 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 S233019AbhDTPpa (ORCPT + 99 others); Tue, 20 Apr 2021 11:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233041AbhDTPp2 (ORCPT ); Tue, 20 Apr 2021 11:45:28 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EC15C06174A for ; Tue, 20 Apr 2021 08:44:57 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id y4so22023554lfl.10 for ; Tue, 20 Apr 2021 08:44:57 -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=BAPvvtwfIwS2cMONM+8rdChOeN4vzoXdvSyqPwacZ8s=; b=nNHda3qLj+q/zArpUIAbHfAd2dJeyQQ68PYyOrtjZ0vd6iJiPHXgCGykBBwT2dWATd mixMrQMx79Co+YlpROaAhWDBqAyRQKCVss646HjFmc6ZtkSsRL9xaHYyx7VDHm/WuT/v 0jv7sfl2xdP3pnJNV91ZLOfT5nD57f2tInKjp53MS9nu5OIe3dYuQemcNrpFArgwDX79 JcP96snc9n9TsazqWnu3XCU6oIXKJUQ9fVXdW8Tf685Hdy8Zgo2T5KkmS1jJn69wytPY sZsmPqqEAu4EG7Qt9zeT9ridIgbCV5D8K/1phoPodwmxkEec1nUixDyLj4VTBwDzlk3C Gxjg== 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=BAPvvtwfIwS2cMONM+8rdChOeN4vzoXdvSyqPwacZ8s=; b=Wf8AneyVuRqCoxRl4mpanp15W0pqA6ECs1Hy9/VuUTS+QvSGOXFQnLNYjWH8bvYcbt be7G+xNbW2JTl92Vr9OVO6AyXuZFV8jGSylbpwNeC/OlBoZGSyqhgdG3KH4weyjpxMi7 xMU2zwrfE8MVdSMh30jKpRwXVrgVDAei/lLKXCDfvRsVnogPtz2F7mSTzs3eaKXodqL9 DsxCLqhvdjw6+3EKhEUEV/tuFgpaM4wkbbAq/TlFhtJuEwsc5UUcvxH9gi9GM2hNpJj+ PAfgo33KrDtXqdplekzZR9ZdsiBRWYwPuFm2sz5MTXHAdLaZRig4eTHYzJLuoWqe9n5p njoA== X-Gm-Message-State: AOAM533sZZ7XBko13wMhCvFT3Dl5+kEtUE0qKNK3niisRH19QLsHsAYZ hPrU/Agd/5iPsp/Pz9c2q9w8eUOED76r5SCOw/skjAgDeq8= X-Received: by 2002:a19:4082:: with SMTP id n124mr16639312lfa.154.1618933495630; Tue, 20 Apr 2021 08:44:55 -0700 (PDT) MIME-Version: 1.0 References: <20210419125134.5cab12ea@imladris.surriel.com> <5e21452a727dcd6d3257496a2c42f49bd16e9cb5.camel@surriel.com> In-Reply-To: <5e21452a727dcd6d3257496a2c42f49bd16e9cb5.camel@surriel.com> From: Vincent Guittot Date: Tue, 20 Apr 2021 17:44:44 +0200 Message-ID: Subject: Re: [PATCH v2] sched,fair: skip newidle_balance if a wakeup is pending To: Rik van Riel Cc: linux-kernel , Kernel Team , Peter Zijlstra , Ingo Molnar , Dietmar Eggemann , Mel Gorman , Valentin Schneider Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Apr 2021 at 17:20, Rik van Riel wrote: > > On Tue, 2021-04-20 at 11:04 +0200, Vincent Guittot wrote: > > On Mon, 19 Apr 2021 at 18:51, Rik van Riel wrote: > > > > > > @@ -10688,7 +10697,7 @@ static int newidle_balance(struct rq > > > *this_rq, struct rq_flags *rf) > > > if (this_rq->nr_running != this_rq->cfs.h_nr_running) > > > pulled_task = -1; > > > > > > - if (pulled_task) > > > + if (pulled_task || this_rq->ttwu_pending) > > > > This needs at least a comment to explain why we must clear > > this_rq->idle_stamp when this_rq->ttwu_pending is set whereas it is > > also done during sched_ttwu_pending() > > > > > this_rq->idle_stamp = 0; > > I spent some time staring at sched_ttwu_pending and > the functions it calls, but I can't seem to spot > where it clears rq->idle_stamp, except inside > ttwu_do_wakeup where it will end up adding a > non-idle period into the rq->avg_idle, which seems > wrong. Not sure that this is really wrong because it ends up scheduling the idle task which is immediately preempted. But the preemption happened in the idle task, isn't it ? > > If we are actually idle, and get woken up with a > ttwu_queue task, we do not come through newidle_balance, > and we end up counting the idle time into the avg_idle > number. > > However, if a task is woken up while the CPU is > in newidle_balance, because prev != idle, we should > not count that period towards rq->avg_idle, for > the same reason we do so when we pulled a task. As mentioned above, we have effectively schedule the idle task in your case whereas we don't in the other cases IIUC, your problem comes from rq->avg_idle decreasing a lot in such cases. And because rq->avg_idle is used to decide if you have time to run newlyidle_balance,you skip it more often. > > I'll add a comment in v3 explaining why idle_stamp > needs to be 0. Yes please. > > -- > All Rights Reversed.