Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2026560rdb; Thu, 7 Dec 2023 16:24:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF12mubIkvoFuWhcoqlEvFabHbZpNCKtHqApgzvlpMV9I7bRKRHjAe83jAskCmQUyjqMmOp X-Received: by 2002:a05:6a20:3d26:b0:18f:97c:8239 with SMTP id y38-20020a056a203d2600b0018f097c8239mr3680354pzi.67.1701995081011; Thu, 07 Dec 2023 16:24:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701995080; cv=none; d=google.com; s=arc-20160816; b=bcUjTXIsGxfjVIaBSNniWdc4wf0DTludRCK/6Sefk/z4QXcd0+bxDv+jHSoFImYgjG /8fxvbvKZoAjr/ZSRIEi9K0IE/thiu+LSDvJ6aMDoPw8xu1OohDtxbauygdgDX+ndmao 1Sa51FuY1M+hRoR50GqJ+7ZaYAPFHp4OlXBh37meyGYv/Q7wKpMFS3hCEkjyZ58oDYSi 9fT0nIq7iu2PLPSiQ4YMzSSrXxpcnOIIcacKdr1arCWZ7d1YSFSP6cP9C6lNuqmuHcnC GdQvMsaju+HMjQJnuMlx5EzZTAvOxb8GBoMW8cCLf5YXrc8eSRw6kkcKUaFjAloAA6Z/ JV0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1MICklUThOT75YrGOtGs5vvoxKkTP4eSHGLbFICqC1g=; fh=yvV4jsQVDgaqc4q7qs1OXQfyZz4GAcMjFnMHO0nsM7c=; b=f4EYttHCXqBrbsjxxd7lmDZZOsZJAl1ZwnvpnTcNvQJfrwnbExpjArRgqxC258vjv6 q6Ic0D6Qvq7sNCKdrpXXzcmOaB466dHMqHZlVmmb9rkmleq58OEASOBbaBSGxhqORRFl uhEu/koBNEoX8i0xNxUz8k2bHORx3JyCZav0b+YN0BqfjJ7JMAZd7dMYNuVYSxGiJcTx 1bZzXF+70uTPZT1yH3Q8VZPfRylOdUFEgHROC0nPElcfAj/UUfHLO3Xad3SaL4FEDiHH qYwsmdYZQcqeamFBYh/opZdYSQPvwijmbOSY5QDP2E3C7PuR7RyLPee3ZqemnvoFZkho QLTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=kEcXB5ug; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id my17-20020a17090b4c9100b00286bc9f66b6si669204pjb.62.2023.12.07.16.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 16:24:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=kEcXB5ug; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 4266D833D56A; Thu, 7 Dec 2023 16:24:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1444167AbjLHAYE (ORCPT + 99 others); Thu, 7 Dec 2023 19:24:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232825AbjLHAYB (ORCPT ); Thu, 7 Dec 2023 19:24:01 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B3B171C for ; Thu, 7 Dec 2023 16:24:07 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-40c0a074e71so15625835e9.1 for ; Thu, 07 Dec 2023 16:24:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1701995045; x=1702599845; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1MICklUThOT75YrGOtGs5vvoxKkTP4eSHGLbFICqC1g=; b=kEcXB5ugh4fioltkFcR/kJAvKoJMyioY+Nr+Uga78TYQg9k6s7JKXZZt8wjGA+2l/o 2SRx2xqrFr+dSRxVTqKSFgYVLH9wnwNezmBXLp41Qtqym7A7Ik7OuVAq4zoPpQv/s3me e87F/mbpldoEhv/kqCeb3mPbgqT+Mlzj+5/kL3Qw6TQ6gxLD4vgpqehYHda9fvukve+d E2O0X6GDWYPfQi++hNwXb/LfiFsICSyKSTpu0yqBSeS8h0zefRTOOGmUeBe8lEMz8nPB thWMWg03F5sRlO6h4SVWzYA3502otvgIeMchZiTjNHDEfeVL3fpKnqjZEqMWuKj1XBAn wZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701995045; x=1702599845; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1MICklUThOT75YrGOtGs5vvoxKkTP4eSHGLbFICqC1g=; b=cOOmdzUzanQHO4S0wI1VPrnnc7UzT5WmBznYay+5S20vwKJ25hENq6HjWWMC1qIFHR qg67p2I92HhQTofWa917rrFB5V9KKCJ3lj/X3qyVjv0h5NoCiQ8W6jHaCsyiYQcGQQs8 kloPx9x5WtU8sorVvsBZEsuWqsXRIVOfapp2DnH4O/5wPt1Hdmw4Nk9k+JDnGyHlAG3w tlivEArp9WhtIpRUjATUMqpqgEfVRsO+O7X9qPpuJ1Wsu7h02Jlf+fgXtKT96eczBxAx 5tZqfXkY5U+//wJJSkyes88N2cs7JNlDKlVS2Vriv3P3lhxsYU/FY6L4FDpb+yEWMOn6 9TyA== X-Gm-Message-State: AOJu0Yw8l1owcCxvlTY0HFNp5rTjn9dmEmv95h3e/Gt64jfKsAW0g9Qr CWx3tiubKxjxh45tGTq1BZbodg== X-Received: by 2002:a05:600c:3d0b:b0:40c:314c:803e with SMTP id bh11-20020a05600c3d0b00b0040c314c803emr435922wmb.106.1701995045591; Thu, 07 Dec 2023 16:24:05 -0800 (PST) Received: from airbuntu.. (host109-153-232-45.range109-153.btcentralplus.com. [109.153.232.45]) by smtp.gmail.com with ESMTPSA id u17-20020a05600c19d100b0040c1c269264sm3339653wmq.40.2023.12.07.16.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 16:24:05 -0800 (PST) From: Qais Yousef To: 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 , Wei Wang , Rick Yiu , Chung-Kai Mei , Qais Yousef Subject: [PATCH v2 2/8] sched: cpufreq: Rename map_util_perf to apply_dvfs_headroom Date: Fri, 8 Dec 2023 00:23:36 +0000 Message-Id: <20231208002342.367117-3-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231208002342.367117-1-qyousef@layalina.io> References: <20231208002342.367117-1-qyousef@layalina.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 morse.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 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 16:24:36 -0800 (PST) We are providing headroom for the utilization to grow until the next decision point to pick the next frequency. Give the function a better name and give it some documentation. It is not really mapping anything. Also move it to sched.h. This function relies on updating util signal appropriately to give a headroom to grow. This is more of a scheduler functionality than cpufreq. Move it to sched.h where all the other util handling code belongs. Signed-off-by: Qais Yousef (Google) --- include/linux/sched/cpufreq.h | 5 ----- kernel/sched/cpufreq_schedutil.c | 2 +- kernel/sched/sched.h | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/linux/sched/cpufreq.h b/include/linux/sched/cpufreq.h index bdd31ab93bc5..d01755d3142f 100644 --- a/include/linux/sched/cpufreq.h +++ b/include/linux/sched/cpufreq.h @@ -28,11 +28,6 @@ static inline unsigned long map_util_freq(unsigned long util, { return freq * util / cap; } - -static inline unsigned long map_util_perf(unsigned long util) -{ - return util + (util >> 2); -} #endif /* CONFIG_CPU_FREQ */ #endif /* _LINUX_SCHED_CPUFREQ_H */ diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c index 4ee8ad70be99..79c3b96dc02c 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -157,7 +157,7 @@ unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual, unsigned long max) { /* Add dvfs headroom to actual utilization */ - actual = map_util_perf(actual); + actual = apply_dvfs_headroom(actual); /* Actually we don't need to target the max performance */ if (actual < max) max = actual; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e58a54bda77d..0da3425200b1 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3002,6 +3002,23 @@ unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual, unsigned long min, unsigned long max); +/* + * DVFS decision are made at discrete points. If CPU stays busy, the util will + * continue to grow, which means it could need to run at a higher frequency + * before the next decision point was reached. IOW, we can't follow the util as + * it grows immediately, but there's a delay before we issue a request to go to + * higher frequency. The headroom caters for this delay so the system continues + * to run at adequate performance point. + * + * This function provides enough headroom to provide adequate performance + * assuming the CPU continues to be busy. + * + * At the moment it is a constant multiplication with 1.25. + */ +static inline unsigned long apply_dvfs_headroom(unsigned long util) +{ + return util + (util >> 2); +} /* * Verify the fitness of task @p to run on @cpu taking into account the -- 2.34.1