Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1823713ybk; Mon, 11 May 2020 05:17:07 -0700 (PDT) X-Google-Smtp-Source: APiQypJs+BEfBzPyNs/iS0h9IybiJ0IedNYfEJjJMIsu62wuEWp1jDKNG6rXQRiu1ipfU8pk2bpB X-Received: by 2002:a05:6402:7d6:: with SMTP id u22mr13065087edy.149.1589199427201; Mon, 11 May 2020 05:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589199427; cv=none; d=google.com; s=arc-20160816; b=UV7ui4mqqGQHUMD3qo17vtzHyNTxFYtbw0h9Z3d/ORflmrmq42gZ7KEGGdXNmqeAuq 8IdODTy8cI/jlK6HYkRjc3Syl+fXKdq63PGN6clcOt2IsjUbnIy45WdTfc0jWnQJsCkZ C9gC+5NpDaIdU7T4YjZC564A7vDYKAeD98OcY9l1PSkHuKkoCgjYLXGe42nZ24JHsYJu uUocb07nqn1j7Zlfe1d22MflV7gdSBZN5g4J6dMS1glWp7SL4NDvpNqmX6v5wIWMMSgO 9PpT7HkvdghocG4Ywz6sB48gtSmw1rlMahYIUc9IWRxyUofEds1IsB/Ic6JfkjFg4L9p kjLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pQOTyYCriClwhL5kMMHkf2pHgjcWZeNqjWfK1A+40PQ=; b=LTfJRrL4dBOn9ofZHzvu6UzCk0LRQpSPIwR0Io+lBko8VWq8jgEdHMwhkFqJ+BW0Uw J3ckEFma1wFmK5zIamBPwtFzUvJGc04Xh+fHggAqHgFlCJB78WUTY5Eia5t14DbKwo8s 1ArhpnoRqhop+HvKW4tuMtdWkWyJPM9CnvILnlu5w6shsxAFjwKuLDBEU1wKYhd62a5u DqZVzZT0+OWWxNZDy71Gz2dzLC5Ta7kx56IpIthD/fpPVGgxZ2Y9i6nsurozXkczK4v5 rw7E0Y84rm5mH8Kpjk5FbCQXIyGPWImAZeYZVbxpld/JuZqm+zWUyprC/hIy+9hLldqv 9hzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rQKZE2oq; 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 x20si674999eds.451.2020.05.11.05.16.42; Mon, 11 May 2020 05:17:07 -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=rQKZE2oq; 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 S1727994AbgEKMMu (ORCPT + 99 others); Mon, 11 May 2020 08:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725913AbgEKMMu (ORCPT ); Mon, 11 May 2020 08:12:50 -0400 Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3D42C061A0C for ; Mon, 11 May 2020 05:12:49 -0700 (PDT) Received: by mail-lf1-x143.google.com with SMTP id 8so4585517lfp.4 for ; Mon, 11 May 2020 05:12:49 -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=pQOTyYCriClwhL5kMMHkf2pHgjcWZeNqjWfK1A+40PQ=; b=rQKZE2oqiAp2v2n+wVdwzKRPTv0PDBavkNLblUaT4hFTrV5z66qfT1MTbXdzGvP9No AcMkbtPnjvaG5dCxoD22VTEE6BNW3/TmKGto1ZRBzfOsBd34V93IPITiguy13vfKSTI2 bPHAC43FGrM0YE8CiweSNrB2Vbfc6Bq0vWwv5u5PjnhnJJV86Vi12fiOQas6ESYSVRvn ghryRWwsD3Gcjj4zTz+70JU4ADtmHHa/LmBvjESfFQO/DsKRdVdK7LInBHg09bPEvp4G dIYn0omLlppbjqjYC+EwJ5F8e6MQbwr0hZsXltB1gg7eCxMM0UFabGfanBWxo7/otQKj 3oMw== 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=pQOTyYCriClwhL5kMMHkf2pHgjcWZeNqjWfK1A+40PQ=; b=f49EP/9B6Cw840fB1zzAyA+kvAVj2Tc2V0INnz87o3FGHGTPe7yT9WHib0kVuAVq41 5aqD13P4Q8Zlf2reaOrua/2JZcfA6v0k7GWvCyT35U4b0ghhchu4nMu7Pybhwl8s1sPU 3Tw/OKBLLjuIcsVdJHYoM7cQBQN43r6rcfvAOxCO68+2RDITKhHYeQJ48sgS8PUK2v4O 9mCv8V+76XYLMIz3nNZ5ZIRTcFzftji55n5BAYwE/Llt3voi5TAHu7OxqBg9P+rixFkb B+1Y/Ebrr4uCLgvoBA2PDx8eu6dm/GJOgARHo2ZI4Qll6VeC4OwcV0/LpJgF34yNcBzE +21A== X-Gm-Message-State: AOAM5330fcXN5H7zAXfAnlWkUe594p5vPsVCoHOIy9HoFYLdDoy1b+Lo i8Y4SDNv2vLTG4s1XW/4NS/T/gz5roFN0d/jjZqxXA== X-Received: by 2002:ac2:563b:: with SMTP id b27mr10998447lff.149.1589199167157; Mon, 11 May 2020 05:12:47 -0700 (PDT) MIME-Version: 1.0 References: <20200506141821.GA9773@lorien.usersys.redhat.com> <20200507203612.GF19331@lorien.usersys.redhat.com> <20200508151515.GA25974@geo.homenetwork> <20200508170213.GA27353@geo.homenetwork> <801229de-200d-c9d5-7fd3-8556c5abc064@arm.com> In-Reply-To: From: Vincent Guittot Date: Mon, 11 May 2020 14:12:35 +0200 Message-ID: Subject: Re: [PATCH v2] sched/fair: Fix enqueue_task_fair warning some more To: Dietmar Eggemann Cc: Tao Zhou , Phil Auld , Peter Zijlstra , linux-kernel , Ingo Molnar , Juri Lelli , Tao Zhou Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 11 May 2020 at 12:39, Dietmar Eggemann wrote: > > On 11/05/2020 11:36, Vincent Guittot wrote: > > On Mon, 11 May 2020 at 10:40, Dietmar Eggemann wrote: > >> > >> On 08/05/2020 19:02, Tao Zhou wrote: > >>> On Fri, May 08, 2020 at 05:27:44PM +0200, Vincent Guittot wrote: > >>>> On Fri, 8 May 2020 at 17:12, Tao Zhou wrote: > >>>>> > >>>>> Hi Phil, > >>>>> > >>>>> On Thu, May 07, 2020 at 04:36:12PM -0400, Phil Auld wrote: > >>>>>> sched/fair: Fix enqueue_task_fair warning some more > > [...] > > >> I'm not 100% sure if this is exactly what Tao pointed out here but I > >> also had difficulties understanding understanding how this patch works: > >> > >> p.se > >> | > >> __________________| > >> | > >> V > >> cfs_c -> tg_c -> se_c (se->on_rq = 1) > >> | > >> __________________| > >> | > >> v > >> cfs_b -> tg_b -> se_b > >> | > >> __________________| > >> | > >> V > >> cfs_a -> tg_a -> se_a > >> | > >> __________________| > >> | > >> V > >> cfs_r -> tg_r > >> | > >> V > >> rq > >> > > > > In your example, which cfs_ rq has been throttled ? cfs_a ? > > Yes, cfs_a. 0xffffa085e48ce000 in Phil's trace. > > > > >> (1) The incomplete update happens with cfs_c at the end of > >> enqueue_entity() in the first loop because of 'if ( .... || > >> cfs_bandwidth_used())' (cfs_b->on_list=0 since cfs_a is throttled) > > > > so cfs_c is added with the 1st loop > > Yes. > > >> (2) se_c breaks out of the first loop (se_c->on_rq = 1) > >> > >> (3) With the patch cfs_b is added back to the list. > >> But only because cfs_a->on_list=1. > > > > hmm I don't understand the link between cfs_b been added and cfs_a->on_list=1 > > cfs_b, 0xffffa085e48ce000 is the one which is now added in the 2. loop. > > Isn't the link between cfs_b and cfs_a the first if condition in on_list is only there to say if the cfs_rq is already in the list but there is not dependency with the child > list_add_leaf_cfs_rq(): > > if (cfs_rq->tg->parent && > cfs_rq->tg->parent->cfs_rq[cpu]->on_list) > > to 'connect the branch' or not (default, returning false case)? > In your example above if the parent is already on the list then we know where to insert the child. > > cfs_b is added with 2nd loop because its throttle_count > 0 due to > > cfs_a been throttled (purpose of this patch) > > > >> > >> But since cfs_a is throttled it should be cfs_a->on_list=0 as well. > > > > So 2nd loop breaks because cfs_a is throttled > > Yes. > > > The 3rd loop will add cfs_a > > Yes, but in the example, cfs_a->on_list=1, so we bail out of > list_add_leaf_cfs_rq() early. Because the cfs_rq is on the list already so we don't have to add it > > I don't grasp how can cfs_a->on_list=1, when cfs_a is throttled and > cfs_b, cfs_c are in a throttled hierarchy? > > >> throttle_cfs_rq()->walk_tg_tree_from(..., tg_throttle_down, ...) should > >> include cfs_a when calling list_del_leaf_cfs_rq(). > >> > >> IMHO, throttle_cfs_rq() calls tg_throttle_down() for the throttled > >> cfs_rq too. > >> > >> > >> Another thing: Why don't we use throttled_hierarchy(cfs_rq) instead of > >> cfs_bandwidth_used() in enqueue_entity() as well? > > > > Mainly to be conservative because as this patch demonstrates, there > > are a lot of possible use cases and combinations and I can't ensure > > that it is always safe to use the throttled_hierarchy. > > Maybe this deserves a comment then.