From nobody Wed Dec 17 17:46:17 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1234E13A240 for ; Mon, 24 Jun 2024 10:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224664; cv=none; b=hXTKNQXtbceIrlfb3EYXgDyf2q49z2cQL2MlozgpUhDdIGTKqmOFoKTjzBgykDMxkG3ABEOuM5bHG+enpwagiTqHgV73gTF5bgZIM0MSjU41DGua7YUKlxlmWpZH2AgQUYFoyThBljAvOO13Muf5xdjvwjn01i7sER9AJoGSW1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719224664; c=relaxed/simple; bh=GVrexOSXchRwkLEcqMASpbL2gufR/zoy5FB93APaTvA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=H6sxTy5We6WGklYW3l+UCJez47jIOwkD7kQqXmZBHGXumF11ExGa4oGu8B6TindW76swITXor70CeaKX7xqaE4Aa2U7kg5m4kAd7P+QED35VH5hMt6/c4gABGLg6jAAg2vZ6cSKndX9emPHt/5di1Ql7rDgC3haVnFyiMGsoBBM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 625D5FEC; Mon, 24 Jun 2024 03:24:47 -0700 (PDT) Received: from e130256.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 83B663F766; Mon, 24 Jun 2024 03:24:20 -0700 (PDT) From: Hongyan Xia To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Juri Lelli , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , Pierre Gondois , Youssef Esmat , linux-kernel@vger.kernel.org Subject: [PATCH 6/7] sched/uclamp: Simplify uclamp_eff_value() Date: Mon, 24 Jun 2024 11:23:55 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: 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" The commit sched: Remove all uclamp bucket logic removes uclamp_rq_{inc/dec}() functions, so now p->uclamp contains the correct values all the time after a uclamp_update_active() call, and there's no need to toggle the boolean `active` after an update. As a result, this function is fairly simple now and can live as a static inline function. Signed-off-by: Hongyan Xia --- kernel/sched/core.c | 13 ++++--------- kernel/sched/sched.h | 10 +++++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 767894fc1562..6dc8aa730eb6 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1484,20 +1484,14 @@ uclamp_eff_get(struct task_struct *p, enum uclamp_i= d clamp_id) return uc_req; } =20 -unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp= _id) -{ - if (!uclamp_is_used() || !p->uclamp[clamp_id].active) - return uclamp_none(clamp_id); - - return p->uclamp[clamp_id].value; -} - void uclamp_update_active_nolock(struct task_struct *p) { enum uclamp_id clamp_id; =20 - for_each_clamp_id(clamp_id) + for_each_clamp_id(clamp_id) { p->uclamp[clamp_id] =3D uclamp_eff_get(p, clamp_id); + p->uclamp[clamp_id].active =3D 1; + } } =20 static inline void @@ -1652,6 +1646,7 @@ static void uclamp_fork(struct task_struct *p) for_each_clamp_id(clamp_id) { uclamp_se_set(&p->uclamp_req[clamp_id], uclamp_none(clamp_id), false); + p->uclamp[clamp_id].active =3D 0; } } =20 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index e01e42d2703d..59e5ea421a4c 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -3052,7 +3052,6 @@ static inline unsigned long cpu_util_rt(struct rq *rq) =20 #ifdef CONFIG_UCLAMP_TASK =20 -unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp= _id); void uclamp_update_active_nolock(struct task_struct *p); =20 /* @@ -3081,6 +3080,15 @@ static inline unsigned int uclamp_none(enum uclamp_i= d clamp_id) return SCHED_CAPACITY_SCALE; } =20 +static inline unsigned long +uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id) +{ + if (uclamp_is_used() && p->uclamp[clamp_id].active) + return p->uclamp[clamp_id].value; + + return uclamp_none(clamp_id); +} + static inline void uclamp_se_set(struct uclamp_se *uc_se, unsigned int value, bool user_defin= ed) { --=20 2.34.1