Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1898691rdb; Tue, 20 Feb 2024 10:08:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZFcCnSsmJymwUuNDt2Lk536x/CEz+8SL3rz6WoMotZZVFUBoa6GldDuO33hMsXMNBMARVcCPRJ6Bt+Rz9kqfVQHo+yISwwrHmMJQZ6w== X-Google-Smtp-Source: AGHT+IFmLXyKcN9FpIKWcHgR52guKjGe/ZNMgn6KwdbgtlABcQ9k+5/yp1tpiLPt7i/GCpVLcM9+ X-Received: by 2002:a17:906:ccc7:b0:a3e:a98:6de0 with SMTP id ot7-20020a170906ccc700b00a3e0a986de0mr8416110ejb.46.1708452519493; Tue, 20 Feb 2024 10:08:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708452519; cv=pass; d=google.com; s=arc-20160816; b=duVIcAe8tTJMtvhOaCKQgg2JfU0uPMr4LMh2F5c65kgdmnNLSMM472Qiauo1TaNmSZ Iwd7HNRFRq2qr3TxqaA0KHSLY4ylJmUc1yLPify6Ve2OXLIkuBFO/w7S3CPkL9S5t7Vg wl8WwpbBL8IKaimBKIAAuILfCUyc3aXHlN+tApdInc++uuORdLKZYUcwrNRLxWTq/+bW UgEKpxgYCIhTGRiQ/0q3B/1dduWrRybtJQbjvooF+aTnJO/Whndso2rRHCToqP6h2nGy ACvwJsDBo5l4hqfJVNJ6wOfn8oB+2C0GUsq02kjwLX5p1HrU0seD7nxiiB74f2Ba5gZE cuhA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=HQYn2Qo6PtaFVnQpAuclGekLK37G8lvuP7kYmeLo6SY=; fh=v6qlytWQrHh2QWLWevckV4JHDPD+ubb3DJuvO+KDeFU=; b=BLcRMcsirMCvQ+4zYv40zB7aEH2jG3I33Hk8PrNI0q3E5HJSInH0f2T/rHYE7U+Uas ui6i4eFes7ohAsz/ibH2W1e/M8q6R3K1vj90Ib/T518ZKBs0UGcWXuWBA5+eFwBnYxF8 VT6XAV1SzwmVAPkl8YXGBc5fhxBJkwE2V0q2ZXEuWIPPH6GOWshtg12HYLY+ieRQ0xRR aXoXKCynNbHd7fC8KlU6K4xHTcFAJAu1Mx76ZRZcDvPTrU3eWxljIaCPq1uduqP7qbmL WlDx20CxgVXhE5QMJN1+zuqvj0KfdaPORXZ84yqBOByt3o8uCkx/2T+8H5kBIne4foRL ngrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=uzZeHjVd; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-73489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73489-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k20-20020a17090646d400b00a3e60730e09si2576930ejs.264.2024.02.20.10.08.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:08:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=uzZeHjVd; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-73489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73489-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 163771F22F22 for ; Tue, 20 Feb 2024 18:08:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 899DE77F1B; Tue, 20 Feb 2024 18:08:30 +0000 (UTC) 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="uzZeHjVd" Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) (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 C951577652 for ; Tue, 20 Feb 2024 18:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452509; cv=none; b=uGv3Gs3agbitJ7yh+bl8iL9tgx2fFYnnzgZ5+WR5skynAgqapfB4ikkwPhLxAznJgttivG0VuFjnySswnRLZ022eRKwGmMYvcUiVKZM4wmtmzLkMLjAzvjTpkO5+fOSaEKge5t2+P7ZB2sWnzoUWtrzpwfW1oFuvL5IQvkx2OaY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708452509; c=relaxed/simple; bh=Ii6ohLTbl9rTv5KRVUQJpae0ArE5eca5skPA3gXkdno=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=WxzWyTMiyCU8yFzuNgGfWSv5YHgWipHWAAqq7Va7ttU0zAy14RKqbU7nZO+ql+zaRLINxjyJRyuXAnSwrlYgR4diz8mxj1jWLqn/eKho8ehMWZEDPjFcDIV/YhLYFaUFy+kCDJQk785NI4eBLDorLOMBXNuWHi+oc4AakLCLcLE= 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=uzZeHjVd; arc=none smtp.client-ip=209.85.218.51 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 Received: by mail-ej1-f51.google.com with SMTP id a640c23a62f3a-a3e4765c86eso380192066b.0 for ; Tue, 20 Feb 2024 10:08:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1708452506; x=1709057306; 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=HQYn2Qo6PtaFVnQpAuclGekLK37G8lvuP7kYmeLo6SY=; b=uzZeHjVdmMe1YIss9g0Yjc07lTxdjRcGX1pwQqjCII5EbmdNiNB9D3aMId4ztpa3mE fth4CPcf0MWY8UIx30dkpOVNY8Je1u8AMS4I54+Imbzvs9gTkultFUqQYmvdrz3UJBQM 79wT9PBmFw4ZBRT81s94yV3W2h4sHnynH0orIdd91lDckDYQqMebGE9qxmfvPWTMAb34 GrJwlmLU93lxydWrc64QAGnrUnNuyDor3KrJo7HIYSxVQ8Rc/P21Yi9n06dISKTemLA2 Z4Mza+3ACIt3IfRwHle/FtzWsNf6oK2TOAyNWRzB6a7d0JW4L0dI6XRTUK/Oeu8OE+5m a3TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708452506; x=1709057306; 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=HQYn2Qo6PtaFVnQpAuclGekLK37G8lvuP7kYmeLo6SY=; b=CRh9ItjbpnMUkU08wXl6Yvhq+7DLEoA3tnL8+6JyMihNTR3GOE8AqxVNEOHgbJlMut KP0UVdzvCCXkQOnkHNUpZiP2RMgxwo8ItZX4JY/eMnk+M6g8OUZCw5ebsxflra5lk2Sn W7ddnN10ASKURqD5Jp9bZBKdByJ8n+oj8sqxMVrpxCOPOlhc2I8U7r3WTjhzzVhDNulu sM6iYAqnAl+zHg5BJBAWbhldGDrlYpgSwmTtOFiQyY+YCeUEAp7foCEq8y8rhe17IaCu Bx6twJWqkI5bsUc4F/nUJSuZydP2/+qTjUa/xLpafdLn1afsW+zmxZu7jyGgCsy+eFge j+Fw== X-Gm-Message-State: AOJu0YxctsXIICMo2Pw5zZJHvPBVofBaSCBXlimwvyj284yXxx+6u65Q I+xxguUd4GcEeSvPYEKHmne1r/SpK69wLw5IwL6DLhX+Jj1UlWWB3/893CFJgnQ= X-Received: by 2002:a17:906:d7b7:b0:a3f:2167:63d9 with SMTP id pk23-20020a170906d7b700b00a3f216763d9mr589037ejb.16.1708452505998; Tue, 20 Feb 2024 10:08:25 -0800 (PST) Received: from airbuntu.. (host109-154-46-208.range109-154.btcentralplus.com. [109.154.46.208]) by smtp.gmail.com with ESMTPSA id g14-20020a170906594e00b00a3edde33e7esm1274501ejr.99.2024.02.20.10.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 10:08:25 -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, Qais Yousef Subject: [PATCH v2] sched: cpufreq: Rename map_util_perf to sugov_apply_dvfs_headroom Date: Tue, 20 Feb 2024 18:08:20 +0000 Message-Id: <20240220180820.2597581-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: 8bit 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 Signed-off-by: Qais Yousef --- 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 */ #endif /* _LINUX_SCHED_CPUFREQ_H */ diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.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); } +/* + * 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 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 = map_util_perf(actual); + actual = sugov_apply_dvfs_headroom(actual); /* Actually we don't need to target the max performance */ if (actual < max) max = actual; -- 2.34.1