Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1760526ybk; Mon, 11 May 2020 03:42:59 -0700 (PDT) X-Google-Smtp-Source: APiQypJ6rJyc84MFwV4azJ7wKTYX4VRLlhmz9jDJfvyRJ9N86acyhyqCr/VypRjOuxK2Ap2jFQRX X-Received: by 2002:a17:906:4548:: with SMTP id s8mr12489483ejq.349.1589193779398; Mon, 11 May 2020 03:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589193779; cv=none; d=google.com; s=arc-20160816; b=tElDRh23m6eywWgXZLLoweq4S9L/nVsgdBA3k+9jhFYfe3NU0d1whHcmv6JF2btpWu 8UU4pQ9wGnw/e+W8s/sP7MIh8lwSpTWP1UBHAmsZMUXLWMYAXCbZs0U4JWjdO1gkiyB8 4uuuS6rIyUQXizAlwGScl6NBcesisjgOuuCfbzWX76m0sY7PIYuq9rat8jQZAMjwviXa I3qcJ9c3Cn8IQUvzlPzle+mTDhGptb+LTZrg40wu6frSwe7icboiSfqgKzWmDge1/Vml 1SppGWd8/NYvEmlWwwbo23pCL7XapKXviK+LdO1jL65V5fOnGja/l33yRfyzvTGdq/SD uF2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Zqubu4e99ZWa/QuqbUbo65RhDoyjlcESF6oLUk1DeRg=; b=hRpNpLrEp6kwLmkLwjQYR3xo9SyDbFdRIu5v197E4oBhWVDYi4gfTFKZTCR9IoTMpN Fuc/IZz2P/j95cEaLwQ1TJbAoyFOPUNq0HtFu6yEszFTkYE1NYDyGxif8nKyo5O7qNgq iduLvkMB6orCtUDhbWI+/ip0+lYPjAoZWbyTxUlSsZqR5myorNTKU2WPQ+a9w8aS5Qsl SReQ/W4Y/Uy3jmqsKXYH3xlUlYcQYf6XS3zohMvEW975wSe1W9fLVVkGdjSSSqE6HqFw ZnfjJKh7P+Hvbxa36Zcwa67MK0DwtgytJSwo2nzpQ/ExW1aL7NoGQlEa2UQWfx9C0hno DQFg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v29si5139016eda.533.2020.05.11.03.42.36; Mon, 11 May 2020 03:42:59 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729546AbgEKKj4 (ORCPT + 99 others); Mon, 11 May 2020 06:39:56 -0400 Received: from foss.arm.com ([217.140.110.172]:55940 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728209AbgEKKjz (ORCPT ); Mon, 11 May 2020 06:39:55 -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 E40951FB; Mon, 11 May 2020 03:39:54 -0700 (PDT) Received: from [192.168.0.7] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 865453F305; Mon, 11 May 2020 03:39:53 -0700 (PDT) Subject: Re: [PATCH v2] sched/fair: Fix enqueue_task_fair warning some more To: Vincent Guittot Cc: Tao Zhou , Phil Auld , Peter Zijlstra , linux-kernel , Ingo Molnar , Juri Lelli , Tao Zhou 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> From: Dietmar Eggemann Message-ID: Date: Mon, 11 May 2020 12:39:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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)? > 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. 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.