Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1743882rdb; Tue, 20 Feb 2024 05:58:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU0MZWNv3iaZo+UScjxbC8ELeBPgZO8jmKuab4KKFQivAxw0KuSOLJQVZY+OSG8eHY8p4xVNFXNxnQ+FJbtOqF/8ecciUaRNvGmjyBonA== X-Google-Smtp-Source: AGHT+IGCgsbJua+B6sCenOVW0Ppd27FQECmlCsoiGNyLh4Xc9kurL2KB3QrWdQM7voDwjXLC48mv X-Received: by 2002:aa7:ce03:0:b0:564:4504:cc2 with SMTP id d3-20020aa7ce03000000b0056445040cc2mr4499575edv.16.1708437487329; Tue, 20 Feb 2024 05:58:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708437487; cv=pass; d=google.com; s=arc-20160816; b=ikfAI8PcvcJr75U13HwRUYCDD+hL1pMarNs7bJdGD8wLF3iG0Toht3LP+k3d1iCvk4 rFfy20gj7PrB1BOhN9AGeoZAdBkGusAnSrEdajqPYOpgFsNB8tp0D3IHB+SG0GNDA6DG 4i14hmxGWT+auR7FWYb9kLQIy+tqO9Etaf7kiHWjN8vEMwJs/w9BatMBdcOTG3zH4rZI 4+t6HyGpAI+k/5p371b5gmEsfcHj0FzxONXpH1p0XNPQZbykbWWUA8bi2NASgAMhxn3Z PTJngEpvrRQ4QhZGRW4hz0PJ27Ele9794ntZYOuHnR6iojYPjHv/VyCpgN+hF5paMEef H/EQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=AI5Avz0WDOYWyiRhPfNRydtZ2zETZ/BjR+NeiTklUgk=; fh=aiNgMnnqllz+4IXMYYW2enbNoLqOfDjx/kK9eRz9LjY=; b=MXqgsslkC/3vs8xBANgfy5rCri9EvXO2YvioqYY8ISE9y3XkOkk22uExKIs4m2RXpo /xNyaEZYUxqrbBRE/Grk6hyTY4DXewdVs5Er0aNWwoO+cqc5J4/ax01Je1P2L75IAKoA d/aoV22xTXjPPaqDmhFLaDNjoqYIIlYKMmdCE9z6nmdDlFFkxoXkzoRbx2fpifU4/dkQ 5xO2rjfmLf+COvlmuSe/AFn5QhNTzlPhpDEXw5wtuPpyDlw2mgBEMVH8MXmPeKE/xAU5 1k9wEK253V69iMgb7ppI04dNIWqi/C+A1DTN+hPs2EOwGjPaNFIyl+DAOifHwrLbVbaX iqFQ==; 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=Z4PjYgrT; 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-73127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73127-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m2-20020aa7c482000000b00563f8e1ceabsi3361243edq.383.2024.02.20.05.58.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:58:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=Z4PjYgrT; 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-73127-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73127-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 E4C5D1F22352 for ; Tue, 20 Feb 2024 13:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AACC26A8C6; Tue, 20 Feb 2024 13:57:51 +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="Z4PjYgrT" Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 EC5AA6A325 for ; Tue, 20 Feb 2024 13:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708437470; cv=none; b=Czmwe4YUQon0pBUhHPm62cWyXFZsEEv0qxrvDW2DJJdXGhvPvrPdkztBnujRPj5EexM9cCScyddGYRyJNsY+ClXXIpmKYKzXbbTeLBpYpz1UGlkWSddIEDXJRpm9+GBfrJcrXEpo0YiT8L6Nog+fZjvJnqzJl/TDNHlvFE/W0UM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708437470; c=relaxed/simple; bh=eKFE7ixr+z9DCFBk5T0AINAAtRILUz3VbnLZA8f10bo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UtabWAHZiII/FnaKpq5NUJ/7u/SCSB/jtNuxZUc6e82QPQE2XO3L2pz+HrxufeQNYADjQgntVtGmHsfNgzZt5GZm394ywgyXW3nFM05naCdCCNTzvR0SzfgfdZAgq0mfMj6r3KWnHQEqkA0WKljilETVhIsadgddvwosShwwTIM= 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=Z4PjYgrT; arc=none smtp.client-ip=209.85.221.48 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-wr1-f48.google.com with SMTP id ffacd0b85a97d-33d70df523dso239787f8f.2 for ; Tue, 20 Feb 2024 05:57:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1708437467; x=1709042267; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AI5Avz0WDOYWyiRhPfNRydtZ2zETZ/BjR+NeiTklUgk=; b=Z4PjYgrTObZKGaP/9+0LPZhBwYkewccMEtkcjkSfHOGvVq9KimuM9T7orMvixulWXi NDnVZeootN34yOGCgnGVKTmo1S7uvLMTSvvrTj/VEHbNjtrjrL//smoRyjP2VEw6989L NhdmAhYJiN0e4ZpsvVGXCn08MDHFVyVPNo6F9w8urb+ctNtoyu6fPQlCEuCVfSmAP1RI zwNxe9jWbvUQ8wODItDy2bGwYkOWai3b2i2r8/03XlLyN6JpFBlnQlMKk1nZA9EutHPM 1IFUuE1zbq36PJvRzXY+RrIuF3NxPJWY/KtMsL/oVuCqDa0EETIkS4qV18ifpbPoMngh N7vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708437467; x=1709042267; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AI5Avz0WDOYWyiRhPfNRydtZ2zETZ/BjR+NeiTklUgk=; b=RnUY5kFE8a/aWjZJYcV1FpvzRmx9WZFDVJ/yLZpy6a7WcD1s3sQjcbqFGckJUtMZJV 9rlFPKJuHmAMCaz0v0/tzC2Mn4qQr4diAFupV1yFXbPbDxlL/yzF1lpB7OuZ/QHrFm2x b2vnuB/HDbMGNq2823oTlTeGYnRLz+UHDcYl0+DjyqWX9ERbiC151M3UImJ1w0e6L7Ae ExRu4DmYCq5LKeOReshgVOvwsXzkXpUrsCrDrmlSlLWihbY752os4FaEeniY1R3gnaw0 6NKtssZfZH2KdY2JKTCNV3oLd1O0z8SKnaERZbBbPPtj9FB8Bvf3EUf/EmcRXxfNqw8b bFsA== X-Forwarded-Encrypted: i=1; AJvYcCXpB+Yxcs2nox7PgW1oqR3fj3uAo4k7IV0T3ZjRAqRXMNDdiPqMSb8arUKLDrYGZhzstRRDJu20Xbr5O+61vD7etEISJyQwe7EYnx1R X-Gm-Message-State: AOJu0Yz8fjQaZbprxa/niBCVmkOb4OlSCqp9UIOiS4/y9LhRHh49NsQc pgCsdLhSIlRAyj27MkQvMYY8swZguu0pQNiruTYR2/S6/WAw9vl1jgWIz+c77Zg= X-Received: by 2002:adf:f50a:0:b0:33d:14be:a6eb with SMTP id q10-20020adff50a000000b0033d14bea6ebmr8567955wro.45.1708437467042; Tue, 20 Feb 2024 05:57:47 -0800 (PST) Received: from airbuntu ([87.127.96.170]) by smtp.gmail.com with ESMTPSA id i13-20020a5d55cd000000b0033b198efbedsm13474007wrw.15.2024.02.20.05.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:57:46 -0800 (PST) Date: Tue, 20 Feb 2024 13:57:45 +0000 From: Qais Yousef To: Vincent Guittot Cc: Ingo Molnar , Peter Zijlstra , "Rafael J. Wysocki" , Viresh Kumar , Dietmar Eggemann , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: Re: [PATCH] sched: cpufreq: Rename map_util_perf to apply_dvfs_headroom Message-ID: <20240220135745.h5mlvutle6wn6eim@airbuntu> References: <20240205022006.2229877-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-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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. 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 > >