From nobody Mon Feb 9 07:52:52 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 3CCAD15A851 for ; Thu, 8 Aug 2024 23:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723160663; cv=none; b=OS4caFMlIw85rNCWgey5v+EByiOyGstgxcMcVQqynOf4BqUR1pCJKhU6dO6UBX3KpEQd8nwqHVaIRb5XTK9FFqwte98eIWItvpi/MIsBFeWephc3lcuCZoqkibuxdFdTPRoPy63s3N0vVEUzSazvS2CgHodyXQNcosb2VOslb/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723160663; c=relaxed/simple; bh=o/NeEUEEPbRHH+4cOkUfuiP/C6hPXj0NMTmrXdr/eys=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=db/JvZN1uPONP+6rMMF6IOoFJxAONR5tLSfQTVWHjtCXHjUYsLak0X+9MNSG6IlCuSpTnNemVN/ngDo6PG6BYQ210sZvM8PSUlFG1VcSYAuSnTYp8IHJIRjOu4R2EaeB9Y+NZzDJ8SoUQGgw588sJ2rktLjr3lDIhG9RB9xWeH4= 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=QLuaar3r; arc=none smtp.client-ip=209.85.221.47 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="QLuaar3r" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3685b3dbcdcso847169f8f.3 for ; Thu, 08 Aug 2024 16:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1723160659; x=1723765459; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wpIOIz+eJ2EDI15m0KcmC252UQEoCmNdQr22+6Ldus8=; b=QLuaar3rZ6cn30lmRVm4ZsQctLTiuwn98gsqwH9tE2fdJ5E6y1lXo5HphgW+4YPqzk 6NpqQTlFnVV4SXHZ4W/37PDZpt3IusSkhnagExHbs+CU106KMiq25lq40ZuBSLLceWPt K2jxahP1LiED3ftAiuegtOFtR4AJJmZtjU23U+JYn2cTUGmM8X/7jRKdAe2CwdFIT0Pa kPjccgVqq5qdf69ATqL6gc6+PrCuNvUhArq23LXup+lnS6J2UqqXoYVUeHucXu91g95H 5TBoVuBre87d0PLFVwr3TXjUqxI/ezNPDJIyRCpDNMJVl15HnegBkc30kzIwHQQ0ODtg 7vnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723160659; x=1723765459; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=wpIOIz+eJ2EDI15m0KcmC252UQEoCmNdQr22+6Ldus8=; b=GRIxdcE3m4JBZIbI3l2EtlXkXbRd5XDqVquO3M9nHwjzK8rtm+AyI/zZiK5tkkpN00 oLYnXLeL00uRuSW+/Q8rqesU4yHxwimx6y3MvwBNFfnjBc/dYInGwn3fUUw9w6DdFDrI 22vPHTTvlmD5MRuvi5Yel3i70K3CcHSALkFtNVLuizqz/4yZhlzkekb34fBWBVJzmvZ8 PO1BG7fcZnZZInKkfwD00sExfcG2u1hDMjg3zZe1WZUPJpcbbw+j+gWoLD2QhcWM6aK6 268bcYbQ0S5dWsAnLsP9VM1oyKPwO7mVmvRT56++2hX0omB5fEQ7kPhMsfMCsIejai0M Y0hA== X-Gm-Message-State: AOJu0YzucHadb64Gb9JuWjBKkWLdqY96U1ahutNV5ytppbhCaZF7CZTT 6LCH1HGG7l6/7RDUBZMDXjgzYI3sPBv9HPqczsKXFaSiMx0NEnnHirC/sNNcwI4= X-Google-Smtp-Source: AGHT+IF5WGofAa3s9FWKI8I6nuBJ247zT4E/5cpCXyN76sgpTHR9BEpdZYWFSSOGbuONhaebr4+sFw== X-Received: by 2002:a5d:6e48:0:b0:35f:1cc9:1d1d with SMTP id ffacd0b85a97d-36d27561030mr2592313f8f.38.1723160659259; Thu, 08 Aug 2024 16:44:19 -0700 (PDT) Received: from airbuntu.. (host81-157-90-255.range81-157.btcentralplus.com. [81.157.90.255]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36d27193339sm3466071f8f.63.2024.08.08.16.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Aug 2024 16:44:18 -0700 (PDT) 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, Qais Yousef Subject: [PATCH v3] sched: cpufreq: Rename map_util_perf to sugov_apply_dvfs_headroom Date: Fri, 9 Aug 2024 00:44:15 +0100 Message-Id: <20240808234415.554937-1-qyousef@layalina.io> X-Mailer: git-send-email 2.34.1 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 Reviewed-by: Christian Loehle --- Changes in v3: 1. Add Reviewed-by from Vincent Changes in v2: 1. Add Acked-by from Viresh and Raphael (Thanks!) 2. Move the function to cpufreq_schedutil.c instead of sched.h 3. Name space the function with sugov_ to indicate it is special to this governor only and not generic. 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