Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4444292rdb; Fri, 15 Sep 2023 02:18:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8MQU7/GqVJKtveegnLY5oCbBeTqaeM7i1I02LAaaa4zcSq1XJHnBMc3i8bOqqvlKw5Woa X-Received: by 2002:a17:90b:b05:b0:273:f138:29cc with SMTP id bf5-20020a17090b0b0500b00273f13829ccmr805773pjb.35.1694769527993; Fri, 15 Sep 2023 02:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694769527; cv=none; d=google.com; s=arc-20160816; b=FJKCf7HZX+4BcZb6f65RU9Zs4IWlQkcER2yTE/MRab7Qn3Bx/w1RCA1Y6J2KlCCFlL QRgP0/6z+knSAof/mMmWfgwj9XWOkDTOEOHtCJcsJh1qLfVYDaBTuSHhkajWEOqscqPN AS6QD/hFqD06pUvn0O5BpVGlM2jzuwSOea1dZpTeq4gWSx/oqzCkMq+qfEx4oxRlrjkD o+vxLwyPYqcj1kztpFrgP5AVqWznOApHNahT1H6Ad0xKi9bHOKsxayQlWnZVPnJ992LV 1yMNm5WvBbmb5lR5bU8VeqlGps1kLPXh7xm9/QpA4spLplYFQwlm2N+3wWi7nyqkPADC fhNA== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=PhugmN2oPHwlxv+XnS9I/Kmf8xV9TDhhhzOv+TseWeE=; fh=y1wr18dLbCq6NOn9DXIzy2wYgtwllQpSa6c4aoloR5E=; b=ltGoMsp36XcBNlH7JfAxA12E+whq/wevbgdmisICMPmptCaMk+VUZgoOQ7lIcNY1xA 6UCKUpIKFxdsOoRJQOfh4pgVJw5NfLVpMQS45Q4ipMkfTQxWzwh3GfbZXzbOVO3ucASn LsYkUta5Ubv3pAUew3VkgAPSE57M0cwt3vBhHnytSpc6NKjoPv1JDY2WGc7+J7uY7Htd ZyzegdzCXApO99I3uehS+LKlkBVLGLiiTInB5NVbfy+chUmPRfst6nZS80ajbOJogf7U jRpYCDllOSzOSkp8jdY1JFo7UbejunGqSFQ98fHQKxyAGDAHx4AmpAToKN7oVATikQ+l mMlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id kx6-20020a17090b228600b00267d70fe0f7si3050974pjb.23.2023.09.15.02.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 02:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 22687826A93E; Fri, 15 Sep 2023 02:15:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233381AbjIOJPm (ORCPT + 99 others); Fri, 15 Sep 2023 05:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232435AbjIOJPl (ORCPT ); Fri, 15 Sep 2023 05:15:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CA8DFCCD; Fri, 15 Sep 2023 02:15:31 -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 58BFF1FB; Fri, 15 Sep 2023 02:16:08 -0700 (PDT) Received: from [10.57.35.82] (unknown [10.57.35.82]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C7E583F67D; Fri, 15 Sep 2023 02:15:29 -0700 (PDT) Message-ID: <3fc888d4-fc18-7947-0541-9dc42892c071@arm.com> Date: Fri, 15 Sep 2023 10:15:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [RFC PATCH 2/7] sched/pelt: Add a new function to approximate runtime to reach given util To: Qais Yousef , Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lukasz Luba References: <20230827233203.1315953-1-qyousef@layalina.io> <20230827233203.1315953-3-qyousef@layalina.io> Content-Language: en-US From: Hongyan Xia In-Reply-To: <20230827233203.1315953-3-qyousef@layalina.io> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 15 Sep 2023 02:15:47 -0700 (PDT) On 28/08/2023 00:31, Qais Yousef wrote: > It is basically the ramp-up time from 0 to a given value. Will be used > later to implement new tunable to control response time for schedutil. > > Signed-off-by: Qais Yousef (Google) > --- > kernel/sched/pelt.c | 21 +++++++++++++++++++++ > kernel/sched/sched.h | 1 + > 2 files changed, 22 insertions(+) > > diff --git a/kernel/sched/pelt.c b/kernel/sched/pelt.c > index 50322005a0ae..f673b9ab92dc 100644 > --- a/kernel/sched/pelt.c > +++ b/kernel/sched/pelt.c > @@ -487,3 +487,24 @@ unsigned long approximate_util_avg(unsigned long util, u64 delta) > > return sa.util_avg; > } > + > +/* > + * Approximate the required amount of runtime in ms required to reach @util. > + */ > +u64 approximate_runtime(unsigned long util) > +{ > + struct sched_avg sa = {}; > + u64 delta = 1024; // period = 1024 = ~1ms > + u64 runtime = 0; > + > + if (unlikely(!util)) > + return runtime; > + > + while (sa.util_avg < util) { > + accumulate_sum(delta, &sa, 0, 0, 1); This looks a bit uncomfortable as the existing comment says that we assume: if (!load) runnable = running = 0; I haven't looked at the math in detail, but if this is okay, maybe a comment saying why this is okay despite the existing comment says otherwise? > + ___update_load_avg(&sa, 0); > + runtime++; > + } > + > + return runtime; > +} > [...]