From nobody Tue Feb 10 01:36:11 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB9CC1ABEBD for ; Tue, 20 Aug 2024 16:35:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724171721; cv=none; b=VfyxX6nmJ3TVb6NSajnYO9yeKcjYVUFh0bjt06q0gLd47nWEzZrOdQlpqklVWrKnL8z03zNaCpg2bY3UwjEwmW5Cv+Wt6JIVP/end2eej9vuyVpP7SQ4XCMF1AASTqe7w2Qfc5MEB3pfpZC+HSnC70PE4eCcsO3vON9SN5uybPQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724171721; c=relaxed/simple; bh=zQ47ImMy4Dn1DCDt3xGlBdnPJ6cBUL0LZB3cTsDPnpA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oJQ3RWSC0wZsTP4iLJB7YadkapCd/R661fYDNXUcWjA3nZK9VzLwp9gKSAoIgeGP/j9X9DIpometibsUAAeeFxzry/XQBPxngxlsZxlKcWv74YpTaJRzFE0LAtRAWQGcUlujm8UunvIKHTh4DdxDFcj8O0ajeLMU/nOgqmWRbWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=B+yMZs56; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="B+yMZs56" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5332f488c6eso5297806e87.1 for ; Tue, 20 Aug 2024 09:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1724171718; x=1724776518; 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=ALljPJwr4PeLXzf4Mb7jserQc5yvW1LK2jxOSl+dUgk=; b=B+yMZs56DcUH8lwhBw7LjnX1UE4bUz+uXrsRAFZbq2wDl9WIxCE+7bQCJwVAV5dsvD 1HsSi9npTs5kShx7/YWBr/EBeHotOA4Dpbfrbr2FRXrBNy60r0xdiA3bwQ1g6i+Y/DNs C/bxMu8u18z+qiYdM/h/tJV3T9vRh/uxJxbCCKC2n9UDjv2RAhlDe9MPXAbNuxxPyfDq bMuW7p4nT+noroAo2WrnYcpYuAjP8ldg5f+Y0le8COnziAh0YLgg4T2nKPUipHxp1kK7 dILxGzzGxGrRXuCOJanfpKtPd+YKkTbvX4DuWhHIKs156AogCLT6SJAUMuiXA3HMrzCz U0nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724171718; x=1724776518; 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=ALljPJwr4PeLXzf4Mb7jserQc5yvW1LK2jxOSl+dUgk=; b=EwcT1qPi7HU8zWUKQrFWdfBgQwb7yFGs8dyEhgI1rQ12AaQZIYI4tzjNVzH2LBtPLs dcRtiunO8BRzSG51MrKdgZkTI0bljYkrEXw0VI+zQsmRktTbbC5AtNU40xhAxa5SYEYw AJC9f7/xZ2UnuYniWrsle1wusYrusvzxshgkbMqL/OUTqVSVLva5fzcVcCWNhW6v+KIz sjMm4VioL7GsrqajRMImTt08ayHVYFmy1pZ2RfKNeNMmq7QJPEjGmlbHSpy+SeyMC1G9 sotOrHV73gOFjqjojZFZ6yC9pvNLjWsD/2sLh/AynBnoO/WQ2kbZb/1utSfQw82kRBCy GgIg== X-Forwarded-Encrypted: i=1; AJvYcCWorbH2El7Kz0P05IV2+Z/Biea0DvQLrkKqz/EzUvykx3n9bdXqouMgZ/F2n4xOPpTsS+5aDhX4h+Wsd+Lb0tcksXVa7CEz/0A9aZOm X-Gm-Message-State: AOJu0Yy8ALdIa3wWkJznhfA4w+kPV7WrVQcX8K8ztbsFNU4lQMcDa2nX F3da/DnUixt1F7rFIraUSqu2HtCI7donh62E5thyWtcdh4zGpxlaDBu7KNc+GSA= X-Google-Smtp-Source: AGHT+IGuDVH/ZjqmvSREiN6JjWHaWFgiSgGpgzFBXWMg8TVU1iExwbDmMv1TgZFfKYdZJrbLW1T/7A== X-Received: by 2002:a05:6512:1193:b0:533:4620:ebec with SMTP id 2adb3069b0e04-5334620eda4mr942030e87.3.1724171717578; Tue, 20 Aug 2024 09:35:17 -0700 (PDT) Received: from airbuntu.. (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a83838cfb5esm780728766b.59.2024.08.20.09.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 09:35:17 -0700 (PDT) From: Qais Yousef To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , "Rafael J. Wysocki" , Viresh Kumar Cc: Juri Lelli , Steven Rostedt , Dietmar Eggemann , John Stultz , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Qais Yousef Subject: [RFC PATCH 01/16] sched: cpufreq: Rename map_util_perf to sugov_apply_dvfs_headroom Date: Tue, 20 Aug 2024 17:34:57 +0100 Message-Id: <20240820163512.1096301-2-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240820163512.1096301-1-qyousef@layalina.io> References: <20240820163512.1096301-1-qyousef@layalina.io> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 cpufreq_schedutil.c. This function relies on updating util signal appropriately to give a headroom to grow. This is tied to schedutil and scheduler and not something that can be shared with other governors. Acked-by: Viresh Kumar Acked-by: Rafael J. Wysocki Reviewed-by: Vincent Guittot Signed-off-by: Qais Yousef --- include/linux/sched/cpufreq.h | 5 ----- kernel/sched/cpufreq_schedutil.c | 20 +++++++++++++++++++- 2 files changed, 19 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 */ =20 #endif /* _LINUX_SCHED_CPUFREQ_H */ diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedu= til.c index eece6244f9d2..575df3599813 100644 --- a/kernel/sched/cpufreq_schedutil.c +++ b/kernel/sched/cpufreq_schedutil.c @@ -178,12 +178,30 @@ static unsigned int get_next_freq(struct sugov_policy= *sg_policy, return cpufreq_driver_resolve_freq(policy, freq); } =20 +/* + * 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 ut= il 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 cont= inues + * 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 sugov_apply_dvfs_headroom(unsigned long util) +{ + return util + (util >> 2); +} + unsigned long sugov_effective_cpu_perf(int cpu, unsigned long actual, unsigned long min, unsigned long max) { /* Add dvfs headroom to actual utilization */ - actual =3D map_util_perf(actual); + actual =3D sugov_apply_dvfs_headroom(actual); /* Actually we don't need to target the max performance */ if (actual < max) max =3D actual; --=20 2.34.1