Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp748021ybv; Wed, 19 Feb 2020 08:26:44 -0800 (PST) X-Google-Smtp-Source: APXvYqzLTYkDjeBNgQFKq/j57Eb9CCCbXLc9WGVD62tW/f497xxkgEZ2hlQ9ytbrYakNqxlniHZA X-Received: by 2002:a9d:7695:: with SMTP id j21mr20703643otl.157.1582129604434; Wed, 19 Feb 2020 08:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582129604; cv=none; d=google.com; s=arc-20160816; b=0z6WpfLAPva6LUhAS2tldFNhPKBkUqrr3wqy3uBGxnQlXCCawBRuyjo9fiYabCSQpu qIXgOVFnYdKFBK7dRHAVICSfx8a/KkORRhY1ei7ri7+02Ei6+54E0zm7Wm9menF5h8hV pa35y4xZ7L7fyqvDi0aje/cF6qK1wk4OiuFzsM3zuhbIR1e8Jn2Wg3xEf6KNb1cVsF+5 Z/BvAr4Fxl/byfQr5y0uhE8cajMvLlxM96oSc84TcDZJtvbvyIsrSXWIN2N9GLd5tN3/ OPzLGB1ScI+Tt8oYGoeGOw/NgpkadOYSSEN+P2V0BB0pCy6DjYOlqYp13xONOM8MHX83 rxrQ== 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=iAUIgzNVSjCaZCZcVDjF9RShTwUDVddbn/sJaXgNE8Q=; b=ouwiykpK2SKW18qlgjfesxcKJ/83qbAfn6HRLEdql0CCMnpjCXl4jIMhztMQmXFbsD Do/WsOsvZ6m0IrYGqjudajzIbvH4c1HhtJ4TjAZfsgysGjMUwPOsNXWEdf+kVMpn1I1y tnt+7hyPKqZv2FUOK2KQkx8Yv0HsITEg6YCvxuiP8mPIT9rf7WwIDEK0GB7ubVSAHGsl tK9QJ2p7S+7ckNnpxd2wiJ2Z6iUXAD8lgmLxoEDNmZATVPsYuRiLdxCsQNfcs7CaBX6K nbAoEBNlSVP8cJeVFPYuOrg5dsnwjexy5UY60PTz4gcs3LAVfsF19DrZjOtVG0Gd1oWO 3/BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INN9ZHKL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 185si10023261oie.52.2020.02.19.08.26.32; Wed, 19 Feb 2020 08:26:44 -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; dkim=pass header.i=@linaro.org header.s=google header.b=INN9ZHKL; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726719AbgBSQ0Z (ORCPT + 99 others); Wed, 19 Feb 2020 11:26:25 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36333 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbgBSQ0Z (ORCPT ); Wed, 19 Feb 2020 11:26:25 -0500 Received: by mail-lj1-f194.google.com with SMTP id r19so1026071ljg.3 for ; Wed, 19 Feb 2020 08:26:23 -0800 (PST) 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=iAUIgzNVSjCaZCZcVDjF9RShTwUDVddbn/sJaXgNE8Q=; b=INN9ZHKLYkbuQDSc9NqdIbYEvtoq0e4O4ocezXGSkkhSbjDYYzOZCGAQohSP5zbdgz 9G8r36hoOz6xjQ2NN3etzcC9G3WN1YULT4hS8bRbJZHCRRHjDlmIQufClyj4SzfjHYht Une46e/kNZwrEKhEgj1e9IVk7AsHp6pKIDTD4YnuRnOb4bbhl9KnGtmBpWz88ZYvTQMN PK7WasPJRSa0Mt9jPRgQnLPbDSsgf2zA3mgyKjzH+jTv86w0iEnl6mOMQTDfUI2PxnPJ 2G5Q1AgcOeO+lqKkvctm2LfbjuE4GRFGOPopgeM7alpGtSQVSYd00pHZRAHespg56RJn znKQ== 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=iAUIgzNVSjCaZCZcVDjF9RShTwUDVddbn/sJaXgNE8Q=; b=Xdpzlo1ijSaamJzBvTX88hXKxx2lVKhBmYESGTD+Qkk2uqTxpB+3fdOpJl9UcD5TwW otYAelaHCNlhlEG/lzwbURq3s+NM+yAQeNWfF/dzNQLSa0XO/ZhBplLU14+iQ7vfxL7b ucIHo1IawPsbxNK0s6z/FJQEdaV4spQWOCC0oZb180LRhH9EfBXhVVyQc6xNhbafmpML uex8vNyaQil1/SCj39DI9sqeR6Q3fwV9p7eFAujJnSKWTYCas7sKD2zS82O52izMDUh0 +q0JuSJtiAB+COZdyZyBQaIbhyKEcOkntOTX2lK6dN7YvFHffsyQKhRYN+Td0hiAFqz7 Pw/g== X-Gm-Message-State: APjAAAWeY1rvPioBOB9EkiU/SsjcA4rsPpguMsSX517PywDwFX0d2AS6 bYoQadKkacGNESxBX5+d21BBMBSXDNqL7naNDXeBbg== X-Received: by 2002:a2e:8eda:: with SMTP id e26mr16518252ljl.65.1582129582999; Wed, 19 Feb 2020 08:26:22 -0800 (PST) MIME-Version: 1.0 References: <20200214152729.6059-1-vincent.guittot@linaro.org> <20200214152729.6059-2-vincent.guittot@linaro.org> <20200218132203.GB14914@hirez.programming.kicks-ass.net> In-Reply-To: From: Vincent Guittot Date: Wed, 19 Feb 2020 17:26:11 +0100 Message-ID: Subject: Re: [PATCH v2 1/5] sched/fair: Reorder enqueue/dequeue_task_fair path To: Dietmar Eggemann Cc: Peter Zijlstra , Ingo Molnar , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , linux-kernel , Phil Auld , Parth Shah , Valentin Schneider , Hillf Danton 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 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.