Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4407237rwl; Mon, 3 Apr 2023 04:43:51 -0700 (PDT) X-Google-Smtp-Source: AKy350Zak+gI4/XPScMbK2Lg2OhOndQjHsTRnLd9kFR4mnd+1l4Vbs6DniBLtAEwMjrQtOaWcfVy X-Received: by 2002:a17:90b:3847:b0:233:e1e6:33d4 with SMTP id nl7-20020a17090b384700b00233e1e633d4mr40304833pjb.47.1680522230921; Mon, 03 Apr 2023 04:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680522230; cv=none; d=google.com; s=arc-20160816; b=m1drVSDOFmy3BiOb6hODGzrE+GDM9Q6StTg0CafPRjTR1ADgLA94b2JLPBXKcnHVZN bnA2vDFr8vBjneoBK0xVyN5ChcdaSEs7tG3D3fA1kqGg0+201OSD+Jsg4zed4UO3gwvY /O1yLlba6MjevL/UDd0NtLNbTnWdVSdiSld0c4FeIX7pHuHLtBBzsLugTo+QMtVLh+4E Z/IqdZ2JUZNYNc7dCcFSilOaanFphAXZqOJO++9vm6DtGALHBrNogWhcpVXGukvKPztY wCv+zjji1OpL8XwZvgttKCM2e8ecgUwT5x9q/6QxaL3Oy+acE125j3T7yePSpcZuyzdl ALfg== 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=03QMEjZoQ+X0+AlPHw/ezAk9dCXWmBN9qpvNetD9rkQ=; b=A9EvmkSR5bQ6vqpVSF5/799sgiU4KU3Pay0oRA6EG2LfQFXDuk4U0YeIIxLZ3r8mCl XCIsbqv70lNEucJ0j/s73LoiNAsh3s/yMazgZUAJBbhePliC5NlTdYvPvXOtU+f4fZPF xs2Xbf9SvEk1C95UNqpOYyWt/0tYXjMphpLJMJLBC3YlBU26R81WnO6Z7pJ7+6WQB8rS IxVXRBWmWdF3VQouGwk5VicMzmJuJtlR6sACM7V5gsh0bj8p6tY4f5oApzCf3zUl7L38 cClOHnPMmcm5oxFge8wr4uCnrlbaI8kyiCeEK9SrSVcj5iOPhg/Bb4UyXqs/wnqAWXLk DRAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot15-20020a17090b3b4f00b00233c7c617e7si13204818pjb.101.2023.04.03.04.43.40; Mon, 03 Apr 2023 04:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjDCLki (ORCPT + 99 others); Mon, 3 Apr 2023 07:40:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjDCLkh (ORCPT ); Mon, 3 Apr 2023 07:40:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55ACE35AF for ; Mon, 3 Apr 2023 04:40:36 -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 4B0981063; Mon, 3 Apr 2023 04:41:20 -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 E9D1F3F6C4; Mon, 3 Apr 2023 04:40:33 -0700 (PDT) Message-ID: Date: Mon, 3 Apr 2023 13:40:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [RFC PATCH 1/6] sched/fair: Add util_guest for tasks Content-Language: en-US To: David Dai , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Saravana Kannan , kernel-team@android.com, linux-kernel@vger.kernel.org References: <20230330224348.1006691-1-davidai@google.com> <20230330224348.1006691-2-davidai@google.com> From: Dietmar Eggemann In-Reply-To: <20230330224348.1006691-2-davidai@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On 31/03/2023 00:43, David Dai wrote: > For virtualization usecases, util_est and util_avg currently tracked > on the host aren't sufficient to accurately represent the workload on > vCPU threads, which results in poor frequency selection and performance. > For example, when a large workload migrates from a busy vCPU thread to > an idle vCPU thread, it incurs additional DVFS ramp-up latencies > as util accumulates. > > Introduce a new "util_guest" member as an additional PELT signal that's > independently updated by the guest. When used, it's max aggregated to > provide a boost to both task_util and task_util_est. > > Updating task_util and task_util_est will ensure: > -Better task placement decisions for vCPU threads on the host > -Correctly updating util_est.ewma during dequeue > -Additive util with other threads on the same runqueue for more > accurate frequency responses > > Co-developed-by: Saravana Kannan > Signed-off-by: Saravana Kannan > Signed-off-by: David Dai > --- [...] > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 6986ea31c984..998649554344 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -4276,14 +4276,16 @@ static int newidle_balance(struct rq *this_rq, struct rq_flags *rf); > > static inline unsigned long task_util(struct task_struct *p) > { > - return READ_ONCE(p->se.avg.util_avg); > + return max(READ_ONCE(p->se.avg.util_avg), > + READ_ONCE(p->se.avg.util_guest)); > } > > static inline unsigned long _task_util_est(struct task_struct *p) > { > struct util_est ue = READ_ONCE(p->se.avg.util_est); > > - return max(ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED)); > + return max_t(unsigned long, READ_ONCE(p->se.avg.util_guest), > + max(ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED))); > } I can't see why the existing p->uclamp_req[UCLAMP_MIN].value can't be used here instead p->se.avg.util_guest. I do understand the issue of inheriting uclamp values at fork but don't get the not being `additive` thing. We are at task level here. The fact that you have to max util_avg and util_est directly in task_util() and _task_util_est() tells me that there are places where this helps and uclamp_task_util() is not called there. When you say in the cover letter that you tried uclamp_min, how exactly did you use it? Did you run the existing mainline or did you use uclamp_min as a replacement for util_guest in this patch here? > static inline unsigned long task_util_est(struct task_struct *p) > @@ -6242,6 +6244,15 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > */ > util_est_enqueue(&rq->cfs, p); > > + /* > + * The normal code path for host thread enqueue doesn't take into > + * account guest task migrations when updating cpufreq util. > + * So, always update the cpufreq when a vCPU thread has a > + * non-zero util_guest value. > + */ > + if (READ_ONCE(p->se.avg.util_guest)) > + cpufreq_update_util(rq, 0); This is because enqueue_entity() -> update_load_avg() -> attach_entity_load_avg() -> cfs_rq_util_change() requires root run-queue (&rq->cfs == cfs_rq) to call cpufreq_update_util()? [...]