Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp338165rdb; Tue, 31 Oct 2023 08:52:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPuTwv9Z0HIjtcKPDAOfQhCE0w24LzFJLoT/HnXrgpe8X0lzTEb4/hKvyBi5gLpgbXaLjj X-Received: by 2002:a05:6a20:2451:b0:15d:2bff:77b with SMTP id t17-20020a056a20245100b0015d2bff077bmr12397357pzc.34.1698767559596; Tue, 31 Oct 2023 08:52:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698767559; cv=none; d=google.com; s=arc-20160816; b=Nre/7CWQ315NcGSIxZmgB8IpdOZsC7TRA7ZUwgnjc6EGgFwClr339d0LIRVv+GnN08 zGLIWH4yDadaXzJ5C/+DyZ5tcJsAQRRTFtkVAf1LwMrsIR54JykxohUwqW9EXcaZgtBE mr6aLrvS63cLrZef08VxW5d1Sj0J/KLmMOxgrxBdzmGau0jgSn+Z/9eHEz0kC6CNn28s 7lht3KaT8bRQjZycBynwhydcxiAxckX/RMR7Y8dfVnoZipDBoV9cHtsBVB4yzLL3ahVb hzgtzqgjquCYOGSAaFdCnPoqFKlnUm5GwENLKAEItmz7vuutDZ+VF1bVHEHEuzcm7Hr5 gPUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=toUUBhC3Su3bIqAuPZ/WCBp0nLupyVyFA1ZxsinsL9E=; fh=AfLL/DKK2gQQEoZBzmnH4pb//TwGt2KTQ6T6ssunXrA=; b=goSnQnMcu5GfY+fygKd7PNA2o0rLcNXfHrRvlea8YATjMD1v+G1ujL2zRvVirhmDQu rJLUU4DX7y4S+M6N9MtoQBK3RcYIHQSVhfqb9OzS+5kca1Tni4c33aRxeJRSYjjyJAKO pSFGCt2LJrhbWT0tMKOQPaiZiFlTuK8aao9c0JcJwGidHUBbaWRoC7mzOZPdLEuscAAb yPBdSdUfiVR5Y91+d4xeR8dHWsZkSEzBikZsn+CWcjjXhj5x9wkGjrbicRSjnujtXgWg htpUQ/7ks8JRAPa5XzjxhzW5zs3gi/Ee3M5INvX9XJgb+IONxyKJdnIwuI18fBNlKXUk a1JA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id f21-20020a056a00229500b0068fe12b361dsi1147747pfe.249.2023.10.31.08.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 08:52:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 052998031F1E; Tue, 31 Oct 2023 08:52:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345115AbjJaPwa (ORCPT + 99 others); Tue, 31 Oct 2023 11:52:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231131AbjJaPw3 (ORCPT ); Tue, 31 Oct 2023 11:52:29 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8D48DF for ; Tue, 31 Oct 2023 08:52:26 -0700 (PDT) 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 02DA42F; Tue, 31 Oct 2023 08:53:08 -0700 (PDT) Received: from [192.168.178.6] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F3073F67D; Tue, 31 Oct 2023 08:52:24 -0700 (PDT) Message-ID: Date: Tue, 31 Oct 2023 16:52:23 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/6] sched/uclamp: Track uclamped util_avg in sched_avg Content-Language: en-US To: Hongyan Xia , Ingo Molnar , Peter Zijlstra , Vincent Guittot , Juri Lelli Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , linux-kernel@vger.kernel.org References: <5564fc23d5e6425d069c36b4cef48edbe77fe64d.1696345700.git.Hongyan.Xia2@arm.com> From: Dietmar Eggemann In-Reply-To: <5564fc23d5e6425d069c36b4cef48edbe77fe64d.1696345700.git.Hongyan.Xia2@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 31 Oct 2023 08:52:37 -0700 (PDT) On 04/10/2023 11:04, Hongyan Xia wrote: > From: Hongyan Xia [...] > @@ -6445,6 +6450,21 @@ static int sched_idle_cpu(int cpu) > } > #endif > > +void ___update_util_avg_uclamp(struct sched_avg *avg, struct sched_entity *se); IMHO, `struct sched_avg *avg` can only be the one of a cfs_rq. So passing a cfs_rq would eliminate the question whether this can be from another se. > +static void update_se_chain(struct task_struct *p) > +{ > +#ifdef CONFIG_UCLAMP_TASK > + struct sched_entity *se = &p->se; > + struct rq *rq = task_rq(p); > + > + for_each_sched_entity(se) { > + struct cfs_rq *cfs_rq = cfs_rq_of(se); > + > + ___update_util_avg_uclamp(&cfs_rq->avg, se); > + } > +#endif > +} > /* > * The enqueue_task method is called before nr_running is > * increased. Here we update the fair scheduling stats and > @@ -6511,6 +6531,16 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > goto enqueue_throttle; > } > > + /* > + * Re-evaluate the se hierarchy now that on_rq is true. This is > + * important to enforce uclamp the moment a task with uclamp is > + * enqueued, rather than waiting a timer tick for uclamp to kick in. > + * > + * XXX: This duplicates some of the work already done in the above for > + * loops. > + */ > + update_se_chain(p); I try to figure out why this is necessary here: enqueue_task_fair() for_each_sched_entity() enqueue_entity() update_load_avg() __update_load_avg_se() ___update_util_avg_uclamp() <-- if se->on_rq, update p (se) if we cross PELT period (1) boundaries ___decay_util_avg_uclamp_towards() <-- decay p (se) (2) enqueue_util_avg_uclamp() <-- enqueue p into cfs_rq (3) se->on_rq = 1 <-- set p (se) on_rq (4) for_each_sched_entity() update_load_avg() <-- update all on_rq se's in the hierarchy (5) update_se_chain() <-- update p (se) and its se hierarchy (6) (1) Skip p since it is !se->on_rq. (2) Decay p->se->avg.util_avg_uclamp to 0 since it was sleeping. (3) Attach p to its cfs_rq ... (6) Update all all se's and cfs_rq's involved in p's task_group hierarchy (including propagation from se (level=x+1) to cfs_rq (level=x)) Question for me is why can't you integrate the util_avg_uclamp signals for se's and cfs_rq's/rq's much closer into existing PELT functions? [...]