Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp5399249rdb; Sat, 16 Sep 2023 15:48:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqZUQlzDXxB6TdS5pivhVY+lAkkJ5kEpMLSrevJr+Z055BQCe/kDKfMpeAKr3ZkmtnSofI X-Received: by 2002:a05:6358:2495:b0:140:f08b:4f35 with SMTP id m21-20020a056358249500b00140f08b4f35mr6391280rwc.21.1694904524169; Sat, 16 Sep 2023 15:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694904524; cv=none; d=google.com; s=arc-20160816; b=PBSJAX1ZEqhdNEukUTVSPTI/3cveZaarWzOa8EXnSJjrBuD4+G2MWLjr7ueoMz9X5k Zp3a0z5YOrsK+LYDRWW0UvTU0zAUOouqwsRNzClbCyaN8LYGuyMgY/uOMCAyC3s2M3mg BvpNQdKuVS0bg8lZIRkjIB8BM4s66GIN4Q3pzlEChXjKuKzKYhqUHeZ8Jd28s5hmcdyA rGdPZFq4jIzdmW/SQjxpygUpv32A6m4dy24MyZR2k0nFlXsr0bd6ap2DMv3Pc7uq1H46 uAKgbnftMSJ/WE9nZp0og5J0cfvU/UxJGrRXgTtdvZGyv6dM/VIqBH4nEER6wt1bgR3d nyAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aSRNOnwEQsZZMI8EIIn71RrWo2EfMJ2ZTlOi8DC8epM=; fh=w9HTVvV3vAQIecELqY+ul9kDUx9ZhrY2+vGgwuQBTeE=; b=Bsy3GVlLSZlyXizbPNo9fERfNOEcW57wOHRpCcTZnTgIB/w3iz6jU1syQgr+xnhEP9 Al+6ac8Y6joUGYKdn7RuOPYlhIYjc8nhmBT297vH25whTg2IYRykodMBGY7LgHnR8YM6 GNx/84iZVaOaG88sne4OoLord33t6oq6tdKNTpLk5U1EoVCWhfezGhSMD2JIENUgIwji QKjJjZlk8cID+jUr32xx8ku9kbF0Si4G71gJ7eLjpIs24BNJ8tG4SKI8AFlrHnXHN4Mm ZbvyvwIs93NCELw2faybYkl7l1QXdOYyILLrVyv4ZZCdpcgSNuUjy+FB+X9aNpzfas8K 6tig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=sWzvC+xk; 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 Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id q18-20020a170902c9d200b001b6788a54f4si5475883pld.191.2023.09.16.15.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 15:48:44 -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=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=sWzvC+xk; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2EED2801B901; Sat, 16 Sep 2023 12:57:27 -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 S235328AbjIPT4h (ORCPT + 99 others); Sat, 16 Sep 2023 15:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239295AbjIPT4V (ORCPT ); Sat, 16 Sep 2023 15:56:21 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23A41AD for ; Sat, 16 Sep 2023 12:56:15 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-401c90ed2ecso36478815e9.0 for ; Sat, 16 Sep 2023 12:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1694894174; x=1695498974; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=aSRNOnwEQsZZMI8EIIn71RrWo2EfMJ2ZTlOi8DC8epM=; b=sWzvC+xkAN09tmwdn6sxPM0OVO0vljZhyxtomJn1osWFSKmzTJuqgxBT2TBHcpQRw9 hW2RvbnCSD1YM1B8k7trfhP/FbB2aZrD2jn8b28VgIVaSrgiM2IkUNny5OxZ6adq2F/y Cj3Om6daiJmYS2k3MepSPdr6ZzTAO6mBeSP/qQ5JOF9fZRsFaYsVwvCWd1mXh9lOI/GX 18tklEl9/cp5rmDh6YdxMK7l5SR1Bx1M8ZA53q9qETC2YilPOfLdME1fQBk35hEV8HbZ uR2YKwSpoVfB1v2Yv45bcXCU2jYB31mrBBs/EbEyXglPkSnIioNJkJXyeP1yE/uNdX+l SBiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694894174; x=1695498974; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aSRNOnwEQsZZMI8EIIn71RrWo2EfMJ2ZTlOi8DC8epM=; b=MZs1KoPGJ6eqUvc/HigmlhljAa+POLd3cAQU7w7HgNOQd+Xuo7yQoZ7CpvcUt6gO/e aDpu1B0TGwqWmmkWgZ/Up3SrPohPJyd6EFTiUDsduDMInqLGh1j7osrQSqk5sYVaLZhp x98vmsnk692j9qMhcrjSjl3C1NuW1qcun4I3SJTFLtdIzibPbLU7tmNthFcGeaNYcFGZ A2KJjRRCiN2KY3WXxcXdH7UlHGYfALHKfyfENv4Tg63nVv7fjToRsIqsl6OY6AMmWFEJ 0zape5EsxONsd9ZNBTbLUlT91TwqXQJzBAqtJNb+TCJ9sQYmTfuSnUfmcPwhXJVy9TXB sfiQ== X-Gm-Message-State: AOJu0YyFWvCS+I3v5puTdtcYv2zWIzwwxcQG65559Q/Ckti9hM+QZBWX 7p7r8Us/i7lQTGoMMEh0owM3TA== X-Received: by 2002:a7b:c4cb:0:b0:401:b53e:6c56 with SMTP id g11-20020a7bc4cb000000b00401b53e6c56mr5131086wmk.3.1694894174399; Sat, 16 Sep 2023 12:56:14 -0700 (PDT) Received: from airbuntu (host109-151-228-137.range109-151.btcentralplus.com. [109.151.228.137]) by smtp.gmail.com with ESMTPSA id w4-20020a5d6804000000b003197efd1e7bsm7990039wru.114.2023.09.16.12.56.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Sep 2023 12:56:13 -0700 (PDT) Date: Sat, 16 Sep 2023 20:56:12 +0100 From: Qais Yousef To: Hongyan Xia Cc: Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Viresh Kumar , Vincent Guittot , Dietmar Eggemann , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, Lukasz Luba Subject: Re: [RFC PATCH 2/7] sched/pelt: Add a new function to approximate runtime to reach given util Message-ID: <20230916195612.n7iukjkdjl3dzyxt@airbuntu> References: <20230827233203.1315953-1-qyousef@layalina.io> <20230827233203.1315953-3-qyousef@layalina.io> <3fc888d4-fc18-7947-0541-9dc42892c071@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <3fc888d4-fc18-7947-0541-9dc42892c071@arm.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 16 Sep 2023 12:57:27 -0700 (PDT) On 09/15/23 10:15, Hongyan Xia wrote: > 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? Yeah as Dietmar highlighted I should pass 1 for load and it was my bad misreading the code. So it should be accumulate_sum(delta, &sa, 1, 0, 1); If that's what you meant, yes. Thanks! -- Qais Yousef