Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp689232ybv; Thu, 20 Feb 2020 05:40:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxaR3hQLEDvZCmB/7vMHigoCchzIjnn7H5mN8H0rHwK5XIw7IrVPC6VOt44h2ROlQrYtBlV X-Received: by 2002:a9d:6e0d:: with SMTP id e13mr9225131otr.316.1582206051193; Thu, 20 Feb 2020 05:40:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582206051; cv=none; d=google.com; s=arc-20160816; b=W9BGA0GhEozrr6pA4SWc6dDVPx87ESd5Bzf3Q/Ljx04nfdeetnK6cyAevu3cL2O1JW FDR0mPoKJy8IVPREj6GGTiYPya7HyR9AMY2G5NXZ4QbySdZ0Mn0se+7WxdzU8StM6CvF 2JAoB0DufUTOx29ADkNC8CGYtKUS9bv2bgubtu6pwofMYGgg5/gC92ZQAmuczpBJxJ/b FXduRs6QeDE9xQwGgmyMT0GfpWvYSL5J7pYYYiHrEJJuY54DiOVsS5dDITSwkvvGw6Jl Cyczix4M4551NxfZaC7BDOqA0vErwy0FC/6f13uqYnCUtrYFfDX85Ew3NPURBmmZJk9U zqmw== 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=/t8SObrH6HBG9pKTX5+mkoeSmkov9rTEVDOrYIGaCjU=; b=YXt5yakj793OLhnXyaBRFmTJss4zJRoCpZMDEhq6tW9mUkzjjFKFfZMvh/vLfLa+V7 NYn1HnP8H7WgEekAcVn9RNX6BLh621r/Fs6vi3Gd/VWefClJyg8tnEYajVta9TeVITZz 9RGFFZ1Y20tuVrmqMkjb77YeOUtZdvqKt7+STpFnjSihmsPmmaDjBFRTEoP/JLtdQEB1 GOKjXjaxvi1O/sM24z9XYVvdFntw0+OKKpcgVSs4FpUvMmUTJzy+aNZMVhJdZwo3P6we 6NvRUiRXHcYaD3PpLpqwQbnmVRumabiVbh2XYnBH7J6W3aO+g49R4+t+nCrYUF+b2yc0 wTSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g10si1596068otn.12.2020.02.20.05.40.38; Thu, 20 Feb 2020 05:40:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728221AbgBTNjE (ORCPT + 99 others); Thu, 20 Feb 2020 08:39:04 -0500 Received: from foss.arm.com ([217.140.110.172]:43132 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728145AbgBTNjD (ORCPT ); Thu, 20 Feb 2020 08:39:03 -0500 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 0860331B; Thu, 20 Feb 2020 05:39:03 -0800 (PST) Received: from [192.168.0.7] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 37CD83F703; Thu, 20 Feb 2020 05:39:01 -0800 (PST) Subject: Re: [PATCH v2 1/5] sched/fair: Reorder enqueue/dequeue_task_fair path To: Vincent Guittot Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel , Phil Auld , Parth Shah , Valentin Schneider , Hillf Danton References: <20200214152729.6059-1-vincent.guittot@linaro.org> <20200214152729.6059-2-vincent.guittot@linaro.org> <20200218132203.GB14914@hirez.programming.kicks-ass.net> From: Dietmar Eggemann Message-ID: <274ebb9a-9328-e312-f554-34da8b183932@arm.com> Date: Thu, 20 Feb 2020 14:38:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 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 19/02/2020 17:26, Vincent Guittot wrote: > On Wed, 19 Feb 2020 at 12:07, Dietmar Eggemann wrote: >> >> On 18/02/2020 15:15, Vincent Guittot wrote: >>> On Tue, 18 Feb 2020 at 14:22, Peter Zijlstra wrote: >>>> >>>> On Tue, Feb 18, 2020 at 01:37:37PM +0100, Dietmar Eggemann wrote: >>>>> On 14/02/2020 16:27, Vincent Guittot wrote: >>>>>> The walk through the cgroup hierarchy during the enqueue/dequeue of a task >>>>>> is split in 2 distinct parts for throttled cfs_rq without any added value >>>>>> but making code less readable. >>>>>> >>>>>> Change the code ordering such that everything related to a cfs_rq >>>>>> (throttled or not) will be done in the same loop. >>>>>> >>>>>> In addition, the same steps ordering is used when updating a cfs_rq: >>>>>> - update_load_avg >>>>>> - update_cfs_group >>>>>> - update *h_nr_running >>>>> >>>>> Is this code change really necessary? You pay with two extra goto's. We >>>>> still have the two for_each_sched_entity(se)'s because of 'if >>>>> (se->on_rq); break;'. >>>> >>>> IIRC he relies on the presented ordering in patch #5 -- adding the >>>> running_avg metric. >>> >>> Yes, that's the main reason, updating load_avg before h_nr_running >> >> My hunch is you refer to the new function: >> >> static inline void se_update_runnable(struct sched_entity *se) >> { >> if (!entity_is_task(se)) >> se->runnable_weight = se->my_q->h_nr_running; >> } >> >> I don't see the dependency to the 'update_load_avg -> h_nr_running' >> order since it operates on se->my_q, not cfs_rq = cfs_rq_of(se), i.e. >> se->cfs_rq. >> >> What do I miss here? > > update_load_avg() updates both se and cfs_rq so if you update > cfs_rq->h_nr_running before calling update_load_avg() like in the 2nd > for_each_sched_entity, you will update cfs_rq runnable_avg for the > past time slot with the new h_nr_running value instead of the previous > value. Ah, now I see: update_load_avg() update_cfs_rq_load_avg() __update_load_avg_cfs_rq() ___update_load_sum(..., cfs_rq->h_nr_running, ...) ^^^^^^^^^^^^^^^^^^^^ Not really obvious IMHO, since the code is introduced only in 4/5. Could you add a comment to this patch header? I see you mentioned this dependency already in v1 discussion https://lore.kernel.org/r/CAKfTPtAM=kgF7Fz-JKFY+s_k5KFirs-8Bub3s1Eqtq7P0NMa0w@mail.gmail.com "... But the following patches make PELT using h_nr_running ...". IMHO it would be helpful to have this explanation in the 1/5 patch header so people stop wondering why this is necessary.