Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp472368pxx; Mon, 26 Oct 2020 12:45:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz4RIiKixkTwCk9AZlNZAEzbHW2qFwEnY9Z+nLqvXr99kGDSUfOZSZTJK5LaoulSTIal4mC X-Received: by 2002:a17:906:1c57:: with SMTP id l23mr16758567ejg.372.1603741529991; Mon, 26 Oct 2020 12:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603741529; cv=none; d=google.com; s=arc-20160816; b=OrZXFn7UuXx1m9PtZJX4YaAkqF3eO68IKSgCBlMB1dSMkqTlrDTw52DxLmIzgtE5Z2 fKFSilnd1x9zI/Lq3D+NYEST6aarh/fe+7jWhwVsfPyA+7JyqM4ibKAcuy2JUu7zhnax EJHA9p3Ry/1weXKj7nwyVUHHKSZAhB6SzZZK1MQ4Ilo0J8gC+C4KPCXB98EA1awfPyll BsSNQYNozW7Agibrnsf6ZXRwDaq1WGoaAuCh9cPsVrFCeKr+pYYRTpdZ9XHVUuuenpm+ jSqw0r5avLHSQm6OmoEvu79xSUiwF3f9CauF3bGtsUiL+HcQ9EIi+y+GJHDjtGXKGveP dDBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=zrolNUCz70dAx2P6MUYMitEKr5nhjujkcrp+V/JXYqE=; b=WNmbS6qkHIb1jg0GI4ebuONi9FbImXsfeIzVA8kUnn/6q/fsJ5fYdlL8St9fpqqRBV o6YYorGP7RlsNs+GmaChP0O4q26NrJxP1s4HDgP13bnSvfRkG2MG0EJ5RODyErmGMlOS G9oTwCMWQxiYpixkJ/ug728wtUFcmgXTM5Ck+qII5KXYLTADNfPO7e3LwyNOVqvfutJv b/Cu6K6+ZvAp9I588IK7+CaB7tCZGeB4ABOD5LSpjOTw3zwFQ3wsvzfWAcnN8WcTgP9R GhrsHjUa7vtnef29xgewwZbD8e6KxZqPbGFmAQlKBz95Vmm7VXBgL/OxdEHMCaOblRol c5UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=n7Do+y63; 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 j18si4488273eje.47.2020.10.26.12.45.07; Mon, 26 Oct 2020 12:45:29 -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=n7Do+y63; 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 S1786578AbgJZQwz (ORCPT + 99 others); Mon, 26 Oct 2020 12:52:55 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34620 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1786574AbgJZQwz (ORCPT ); Mon, 26 Oct 2020 12:52:55 -0400 Received: by mail-lj1-f195.google.com with SMTP id y16so10986625ljk.1 for ; Mon, 26 Oct 2020 09:52:53 -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:content-transfer-encoding; bh=zrolNUCz70dAx2P6MUYMitEKr5nhjujkcrp+V/JXYqE=; b=n7Do+y63HzkUNh42XzCR259asRdg469z/Pf0xS2g3xsYpJwY4/CeoqwT+UGFHTMzGl Bl6QuV0dRAwXBJwQJ3l2QZPJF2HFXmGHGLjPbDDU0Iz0cKTggzElRWiP/O3Asc44D1jP qICEh823NYIQUW8SMcSE7yMUL/1g0dReFS1nmmnOb1HcD4AGftTJbhCfl5xVQO17sNB8 qxBFuK+IK383rmjlL6WQzMBPzIG3UR3InyO+GGArmGpYaEckWSalRzINWABjhJhmZv35 ePw0QVfy6BZTSqzIPtARPkXozdkpn8AMQV7GphaiEYxg/4FpeplF8n9HZbGhpJAzBtFG 72FQ== 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:content-transfer-encoding; bh=zrolNUCz70dAx2P6MUYMitEKr5nhjujkcrp+V/JXYqE=; b=S7NyU3mjvV0diHXyiefJr1TYgZdxiv0vFy8OjxebJIMjMaF+veP3W0B+iFgmDPfRdo In+2oBHwbkdEvRCe3vqZ6xt0b6lB9nb4brQA0Oe/Ifk24OrVDXp0Cc1ZD6fkdrju43Z/ BwCjfRfj78wh02lPvtwJx6XR7c7ilYt9tzkxLVtc20aWbN/1ZI4Q5COU+jv2/F/yUTdG DApYXkpgo3PSkwYCxWVJikfahKR53cX78Kh6S2OnMdUUx/eTAOYHZa+DeSIkPduod3LI leqEBw2YSEhAEjS7LPtUvbFg+3BFU9F4yJYgREIFbdZPQsyE4CtsJ8y4zQUzpTCCwCfS TD4w== X-Gm-Message-State: AOAM532UrjCcvmd8yRXzHYZ+pK4pbp0TsJ8fSYN2N4CAeaAYP8jnbDW9 r/UhhSMpBVoL2SZ5Rt5apbWwkac/yHErdAtu3yeRf+vvOd0= X-Received: by 2002:a05:651c:291:: with SMTP id b17mr6655085ljo.177.1603731172451; Mon, 26 Oct 2020 09:52:52 -0700 (PDT) MIME-Version: 1.0 References: <0014CA62-A632-495A-92B0-4B14C8CA193C@fb.com> <20201026142455.GA13495@vingu-book> <465597a2250d69346cff73dd07817794d3e80244.camel@surriel.com> <334f491d2887a6ed7c5347d5125412849feb8a0a.camel@surriel.com> <20201026120445.6a5dbbbe@imladris.surriel.com> <20201026162029.GA11367@vingu-book> In-Reply-To: From: Vincent Guittot Date: Mon, 26 Oct 2020 17:52:41 +0100 Message-ID: Subject: Re: [PATCH] fix scheduler regression from "sched/fair: Rework load_balance()" To: Chris Mason Cc: Rik van Riel , Peter Zijlstra , Johannes Weiner , linux-kernel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Oct 2020 at 17:48, Chris Mason wrote: > > On 26 Oct 2020, at 12:20, Vincent Guittot wrote: > > > Le lundi 26 oct. 2020 =C3=A0 12:04:45 (-0400), Rik van Riel a =C3=A9cri= t : > >> On Mon, 26 Oct 2020 16:42:14 +0100 > >> Vincent Guittot wrote: > >>> On Mon, 26 Oct 2020 at 16:04, Rik van Riel wrote: > >> > >>>> Could utilization estimates be off, either lagging or > >>>> simply having a wrong estimate for a task, resulting > >>>> in no task getting pulled sometimes, while doing a > >>>> migrate_task imbalance always moves over something? > >>> > >>> task and cpu utilization are not always up to fully synced and may > >>> lag > >>> a bit which explains that sometimes LB can fail to migrate for a > >>> small > >>> diff > >> > >> OK, running with this little snippet below, I see latencies > >> improve back to near where they used to be: > >> > >> Latency percentiles (usec) runtime 150 (s) > >> 50.0th: 13 > >> 75.0th: 31 > >> 90.0th: 69 > >> 95.0th: 90 > >> *99.0th: 761 > >> 99.5th: 2268 > >> 99.9th: 9104 > >> min=3D1, max=3D16158 > >> > >> I suspect the right/cleaner approach might be to use > >> migrate_task more in !CPU_NOT_IDLE cases? > >> > >> Running a task to an idle CPU immediately, instead of refusing > >> to have the load balancer move it, improves latencies for fairly > >> obvious reasons. > >> > >> I am not entirely clear on why the load balancer should need to > >> be any more conservative about moving tasks than the wakeup > >> path is in eg. select_idle_sibling. > > > > > > what you are suggesting is something like: > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > > index 4978964e75e5..3b6fbf33abc2 100644 > > --- a/kernel/sched/fair.c > > +++ b/kernel/sched/fair.c > > @@ -9156,7 +9156,8 @@ static inline void calculate_imbalance(struct > > lb_env *env, struct sd_lb_stats *s > > * emptying busiest. > > */ > > if (local->group_type =3D=3D group_has_spare) { > > - if (busiest->group_type > group_fully_busy) { > > + if ((busiest->group_type > group_fully_busy) && > > + !(env->sd->flags & SD_SHARE_PKG_RESOURCES)) { > > /* > > * If busiest is overloaded, try to fill spare > > * capacity. This might end up creating spare > > capacity > > > > which also fixes the problem for me and alignes LB with wakeup path > > regarding the migration > > in the LLC > > Vincent=E2=80=99s patch on top of 5.10-rc1 looks pretty great: > > Latency percentiles (usec) runtime 90 (s) (3320 total samples) > 50.0th: 161 (1687 samples) > 75.0th: 200 (817 samples) > 90.0th: 228 (488 samples) > 95.0th: 254 (164 samples) > *99.0th: 314 (131 samples) > 99.5th: 330 (17 samples) > 99.9th: 356 (13 samples) > min=3D29, max=3D358 > > Next we test in prod, which probably won=E2=80=99t have answers until > tomorrow. Thanks again Vincent! Great ! I'm going to run more tests on my setup as well to make sure that it doesn't generate unexpected side effects on other kinds of use cases. > > -chris