Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1761700rdb; Tue, 20 Feb 2024 06:22:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0jQ1n3rI6Jil04qda+vNWHiLa0NtcLaAaeyEIcaKrXa3ulxslxu5FwgiwUy+98y6EOdpjjAwc8obJzwxebr2wAZRSkbqwOtZ1E9y+cg== X-Google-Smtp-Source: AGHT+IFOvoVwQreVuV4yjPlutjscfAd8kvuFtCMbrtcEa2tOGDxOCkJ4cc1zeRJafPGJU0CMrEi6 X-Received: by 2002:a05:6a20:ce4a:b0:19e:a45e:3b7e with SMTP id id10-20020a056a20ce4a00b0019ea45e3b7emr13978027pzb.53.1708438943840; Tue, 20 Feb 2024 06:22:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708438943; cv=pass; d=google.com; s=arc-20160816; b=B5gGPPssuDxO1vFOb3qqUAuh0ZsVO0oOy4embNSgEet30I041VqKU1fBCOUJ8xV87t qyL4a4IcvBgQ7JnekYq033MKNiG+dWrgy0V8dFpARyEWn4y7Dp6U/80CNRdJvPCh/1zc mU2/gQCSmr/EIld1pXadXVuxrAv77VIzdZyjM2m/Ufgn3Lm6RmVAVrP8ou11m0URbo5W d+KKiC4q38Z4YHZ+QeAHj/pJ9KeH/Kgl1DH2gS2djSVzn2loqaC6EFN5Z8BrNY0+IamB j1OW4we+7eQr4PMzxgEev0vBzUQiR22XmyhnYbPgub1oscKewRfAkyIH+lS/ljMMQGbK z6AQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=KBoCun9C06tVXA8wZQBtoO6pNvn7N0rtBPsUqAq+yXE=; fh=VH34wKKTMkblbSSvDZfGi5Ymr3UcJ+SbJQN0qrXjCvw=; b=nE75+teWl3yKplmuTWHcvMbWIuESQftVwqskNfT0sYZc8XCzkiGpp4V1NDTn7U9mue jdWav1d6ypQdEn4KNCZGlOCqqKk5pTkyS6vNdZc2qEc0boi/MHKo7Z6JuQR71vEsu9XN WjSyKyjfxoN8I3JeNUdVZvXZZKGUjixNKgdpeLzgUVvHUH97mdGSM0Gy5C313gdpu76x cYGHofo0jKyj2nj1Y0brH0L06IHFxb+2kElrgpQxL2V9SO7Z6ri6u9HAfbNqsJRtO4dg +uxiOkW/NTHficwSXGqPiB2sDU7KdWQvdmY4mNTanlf3qE7xmuVW1hKz3cFjOTfGES8P e1cA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hppiNdG/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-73175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k60-20020a17090a3ec200b00299363fde59si6280471pjc.18.2024.02.20.06.22.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 06:22:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="hppiNdG/"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-73175-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73175-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8851228584C for ; Tue, 20 Feb 2024 14:22:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF7586BB2D; Tue, 20 Feb 2024 14:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hppiNdG/" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 585F26A8C0 for ; Tue, 20 Feb 2024 14:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708438935; cv=none; b=EdrmRd4D/UYwbWPQWbGbsZFgklxdof+7b8s0Y3LwGgQWWId1QYMSHeQT+VpoV6bU9MULOzi6P/DMsg1Dm3CGhNWmTz6R7A4ZcO2Vxbpxd16tPY88XfaHhoXdXmzCGbqzzHfmstWXnaz/RmKs/Ifcz66UTw7y0X6POzkzQ27f0f4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708438935; c=relaxed/simple; bh=jAw2zftbgBAJKSrekDaII6VYyxCwwnVK69YNBjgCFjw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=uiP/zAZaorJP0xQL+NctlV4HhwQMszsBtehMKVoqPc2TgyXEUbrAxYlf27grHmEIvPJIy2yr0peG11IWWTelTxUeQ4qtlqT782Z+IGM1n6vGvuB9yprBGckUrf/zAkDvnjCMYcyDlryFoWexAQhG7ohSe4axkitEIRlNBrk9mTo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hppiNdG/; arc=none smtp.client-ip=209.85.215.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5d3912c9a83so4083897a12.3 for ; Tue, 20 Feb 2024 06:22:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708438934; x=1709043734; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KBoCun9C06tVXA8wZQBtoO6pNvn7N0rtBPsUqAq+yXE=; b=hppiNdG/2PZVg4ZIIrL8BrJr9fE5V4CPQm4nFkptDD6Fmw5sWN8/sabT37ghC4AZJT 8lEe2bd+Pf4Q0cqhkMjPRH940ppBZdP/YdRTx3MXvq5p7iGQuB8M4ivMXAtrKADyY/ME lAl5jJ083XbeFWSiLquBmu1j9EHZiMjZ3D49f64qd2xL/oGQkbKP7ugKpgfKCT0mbqMl U/xlwXA9oSXsUbyPXK+ur4EqWG4z6aN0qP+RpMS8LAPWwomCnC3n6b70l4McTEhkM6Du 5f3/L+AMfNfQ/oFQrwbOhoDUri9+NHvlWlFdqidlpxS1Jee9WLejFYKJUrR6BVOSG9JH knYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708438934; x=1709043734; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KBoCun9C06tVXA8wZQBtoO6pNvn7N0rtBPsUqAq+yXE=; b=Gtdi68kSZUz1Qzl1U+r3TCMbHg5kWv/QDYAA7t80396IuAHKuHr3hFauc7ObnZ3/Ab DZEoInyIgabCRxz7LF31Xzx17zRuOc9s+eSUNKWVvCHcFLoQHfw3cwX7uBg0Fb9pwEbM h+mCyl+CrDVchlgHjy/92uWV8pD0TmNUcxl+nDtL+kVpsRzP73LSsfR3sZ0pYkzuf/M8 A2YgA5Bty/I7qYEYu69MJdtT56mbPl936viKGgrFdg5CDVA1woiwVSHfWdN1O4czkevE /FMH4xgCNWAsQJ/D1vH8rp9cBqchBi2FwZCP//LjXcKAML+c5W+Y2gXxDclC66FC6fBG TTXA== X-Forwarded-Encrypted: i=1; AJvYcCXWQDYgcSIE6vcfdTlM0X0JjbBky2KxePiV/rWyenjuFNM82M2X8nMcgk7Gg7bTct8J9EGrofQJlj8RRJ4tBpEtPiqBrpdsJtHQAAC8 X-Gm-Message-State: AOJu0YyO+07r8TlAhzu7G6HItLCj3W8d2Q1kS2dqfsov88dNuxPzy+of cS61IZ7gXJU0DHRo+u1lf3hmYZok/kqPfADKrT5L3dTAUdKpnQSxTzDBRYlNa+QTec5sByZHgQE BoUDlCPmrldRbsHzzsS7bxuZt+3nyjzTMFXRoJ2rvVblhqXWE7rs= X-Received: by 2002:a17:90b:3555:b0:299:b570:bbd6 with SMTP id lt21-20020a17090b355500b00299b570bbd6mr3792421pjb.28.1708438933728; Tue, 20 Feb 2024 06:22:13 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240205022006.2229877-1-qyousef@layalina.io> <20240220135745.h5mlvutle6wn6eim@airbuntu> In-Reply-To: <20240220135745.h5mlvutle6wn6eim@airbuntu> From: Vincent Guittot Date: Tue, 20 Feb 2024 15:22:01 +0100 Message-ID: Subject: Re: [PATCH] sched: cpufreq: Rename map_util_perf to apply_dvfs_headroom To: Qais Yousef Cc: Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Viresh Kumar , Dietmar Eggemann , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Tue, 20 Feb 2024 at 14:57, Qais Yousef wrote: > > On 02/14/24 08:32, Vincent Guittot wrote: > > On Mon, 5 Feb 2024 at 03:20, Qais Yousef wrote: > > > > > > 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. > > > > The renaming makes sense. > > > > > > > > Also move it to sched.h. This function relies on updating util signal > > > > I don't see the benefit of moving it the sched.h as it is only used by > > cpufreq_schedutil() > > Hehe what's for me the reason to move it for you it's the reason not to :-) > > (I believe you meant cpufreq_schedutil.c) > > It doesn't make sense outside of schedutil, does it? I can't see it being > suitable for consumption by other governors for example as it is not generic > enough. > > And the headroom definition needs to evolve. And the tight coupling to util > which is a scheduler internal metric will make it hard once it's part of > cpufreq. The headroom IMO is a property of the governor. In this case make it part of cpufreq_schedutil.c if this is the governor that can use it. I don't like sched.h because It gives the impression that scheduler can play with it whereas it's a property of the cpufreq governor > > We can defer the moving for now if you insist. But I think it's inevitable? > > > > > > > > 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 > > > --- > > > 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 95c3c097083e..abbd1ddb0359 100644 > > > --- a/kernel/sched/cpufreq_schedutil.c > > > +++ b/kernel/sched/cpufreq_schedutil.c > > > @@ -179,7 +179,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 > > >