Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp405091rdb; Thu, 19 Oct 2023 07:50:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/Q8Xp5HBalJPt74C1T9a8oR/YrzbBSVPiUiTzPSeBLSLzKhHu71+YmQOOcSa7AVDLPS+p X-Received: by 2002:a05:6a20:4295:b0:161:346a:e7a1 with SMTP id o21-20020a056a20429500b00161346ae7a1mr2690330pzj.5.1697727018596; Thu, 19 Oct 2023 07:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697727018; cv=none; d=google.com; s=arc-20160816; b=cf0gGBIXqOjLNF/IJxQHtYiWIeKEbW4cxoqI1gpmM5QoTLLP29S1V1MGEs7wzVN6hB qXfGugMJ7cq8VNCFTonRfBt29VXQwuIBItioDm8fYnzGgmzj7x5hhiyTk+OM8C03R0AG W8Ygif2Ob/IZArT4JO24sYvd4hUtdt6rlqspfvxX5Jk9yKTW33O4YT36C9PmSIVQ3XNr jPpabrZGPYEbcDyq5sH3DtOqBz5YzujmuNJBoARy4/R8GEdtNrErgGe4rCSVSHpmQZF/ Nm1d6hny3UeWpfrj8kmiWGXB8T94egsz1+hr0PL7ARhrDb7ZLww6/VXS/phEQ8KftVH6 xabg== 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:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=ecDmU1du+y5X78+FIJSY2EqnJ9st8t4a/thAebgDysA=; fh=Bted0NJFiBs6MHMZlwHKjq47SsewAApnvnlxthZAXp8=; b=kfAxqMY7D+MZUc/s3UZlVzT8j9M+ugvr56t9W/gj1RZwHAJ2aLVvCF1fewD1OBA+gH HOb5ywBAJ1NI7ID85c+eh+h65qUjg9HFMNFTAiy8BZSMt7RZwGr4kJmUtlqn+3pmEd4A CE5qk7Nprs3zhmxR1fApXNlFgvkY3ByuVN85XdBvFQe/FKGUG4cCXpiXPJGKfx/UYpsE s5rVM6D2iErItBz83K5rE5Kg5hF06e8M1Qpw53I6CvjtzmnxT4WSk5exC+ttWP98ViGr LYQsK5cfDJiZ6xeBuKpL72Tee7gOQTXcEHCjloo6KIRlWOYq0KY/n+8fr7OtS4S+BCbX zplw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="R/zARI/G"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q8-20020aa78428000000b006be1dd2313asi6294882pfn.210.2023.10.19.07.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:50:18 -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; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b="R/zARI/G"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 7342C82A3986; Thu, 19 Oct 2023 07:50:15 -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 S1345862AbjJSOtJ (ORCPT + 99 others); Thu, 19 Oct 2023 10:49:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346193AbjJSOtD (ORCPT ); Thu, 19 Oct 2023 10:49:03 -0400 Received: from smtpout.efficios.com (unknown [IPv6:2607:5300:203:b2ee::31e5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43BC4130 for ; Thu, 19 Oct 2023 07:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1697726939; bh=YtPB/bcm1WOSJ3edgMyZVNvIWoEsNXaq7OYC/JmnN3w=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=R/zARI/GPSG2OhkM1+oFsFAmRhzZ15toStKv1R/paNjvOCh2Ya0ji0ftg23LCHlG5 pWqvwlYTBLEQd5+9PzDjl9v0iXbieigADwB7yJQmikhh/FVkhaSxfFPttaV9HPONvy UdcPKW5gZ9q0BzBvd5tkirFZhgXST7f5w0T79RFBAOw+51LvA4cPEDjYKlXyZ+J13M LiFVvn3rCG8HCmvHgrKVZkw6J0UeejkRIa2Dd3pbhN0QdVacQxDL6OH9d0B6nPiG8z OE1G7itmdrPA09GGOnkMe+InuJlRnbvpDYl/kiqRRCIQkTe/dsEWc4jcuk6Ky+Kl9J 07q13Q53bc4Xw== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4SB9Zz0n4sz1Y2V; Thu, 19 Oct 2023 10:48:59 -0400 (EDT) Message-ID: <6bb3bfe5-13d6-413a-bf31-cec5596757f2@efficios.com> Date: Thu, 19 Oct 2023 10:49:09 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 1/2] sched/fair: Introduce UTIL_FITS_CAPACITY feature Content-Language: en-US From: Mathieu Desnoyers To: Chen Yu Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Ingo Molnar , Valentin Schneider , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Vincent Guittot , Juri Lelli , Swapnil Sapkal , Aaron Lu , Tim Chen , K Prateek Nayak , "Gautham R . Shenoy" , x86@kernel.org References: <20231018204511.1563390-1-mathieu.desnoyers@efficios.com> <20231018204511.1563390-2-mathieu.desnoyers@efficios.com> <25e778e2-d91a-4f4d-9f6b-ff144eab3211@efficios.com> In-Reply-To: <25e778e2-d91a-4f4d-9f6b-ff144eab3211@efficios.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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]); Thu, 19 Oct 2023 07:50:15 -0700 (PDT) On 2023-10-19 09:28, Mathieu Desnoyers wrote: > On 2023-10-19 07:35, Chen Yu wrote: [...] >>> +/* >>> + * Returns true if adding the task utilization to the estimated >>> + * utilization of the runnable tasks on @cpu does not exceed the >>> + * capacity of @cpu. >>> + * >>> + * This considers only the utilization of _runnable_ tasks on the @cpu >>> + * runqueue, excluding blocked and sleeping tasks. This is achieved by >>> + * using the runqueue util_est.enqueued, and by estimating the capacity >>> + * of @cpu based on arch_scale_cpu_capacity and >>> arch_scale_thermal_pressure >>> + * rather than capacity_of() because capacity_of() considers >>> + * blocked/sleeping tasks in other scheduler classes. >>> + * >>> + * The utilization vs capacity comparison is done without the margin >>> + * provided by fits_capacity(), because fits_capacity() is used to >>> + * validate whether the utilization of a task fits within the overall >>> + * capacity of a cpu, whereas this function validates whether the task >>> + * utilization fits within the _remaining_ capacity of the cpu, >>> which is >>> + * more precise. >>> + */ >>> +static inline bool task_fits_remaining_cpu_capacity(unsigned long >>> task_util, >>> +                            int cpu) >>> +{ >>> +    unsigned long total_util, capacity; >>> + >>> +    if (!sched_util_fits_capacity_active()) >>> +        return false; >>> +    total_util = READ_ONCE(cpu_rq(cpu)->cfs.avg.util_est.enqueued) + >>> task_util; >>> +    capacity = arch_scale_cpu_capacity(cpu) - >>> arch_scale_thermal_pressure(cpu); >> >> scale_rt_capacity(cpu) could provide the remaining cpu capacity after >> substracted by >> the side activity(rt tasks/thermal pressure/irq time), maybe it would >> be more accurate? > > AFAIU, scale_rt_capacity(cpu) works similarly to capacity_of(cpu) and > considers blocked and sleeping tasks in the rq->avg_rt.util_avg and > rq->avg_dl.util_avg. I'm not sure sure about rq->avg_irq.util_avg and > thermal_load_avg(). > > This goes against what is needed here: we need a utilization that only > considers enqueued runnable tasks (exluding blocked and sleeping tasks). > Or am I missing something ? > I was wrong. Looking more closely at dl and rt sched classes, unlike the fair sched class, they don't appear to take into account sleeping/blocked tasks in their util_avg. They just accumulate the rq util_sum and derive a rq util_avg from it. Likewise for thermal and irq. So both capacity_of(cpu) and scale_rt_capacity(cpu) would appear to do what we need here, but AFAIU capacity_of(cpu) is based on a metric which is only updated once per jiffy or so. Let me try using scale_rt_capacity(cpu) then. Thanks! Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com