Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp506222lqh; Tue, 7 May 2024 06:11:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWaZVS+OzkHe2iRekQ3KFfiOps2m1NO4VhsULwafyuJPwQBFWtEvfJEtp9M50CuzlCTSJ3Sct4nmvJfwPkViqT4FamjKuZQtC9puBfA6A== X-Google-Smtp-Source: AGHT+IEZv3m163ETlHuEPwHChNRAqVNbUVn3hrRfW2zOaQjFTqkp3qasgDbxpHlITf8GtJO22Xh4 X-Received: by 2002:a17:903:1209:b0:1eb:1462:1abe with SMTP id l9-20020a170903120900b001eb14621abemr14345026plh.69.1715087486187; Tue, 07 May 2024 06:11:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715087486; cv=pass; d=google.com; s=arc-20160816; b=Ag04M04V6qu2UttD5bN1QTLKzsrYTFepqnwOjy5drsYf/dddjrF5++L32uc3WSavSR TECYs5OmG+3i1PG1anzE2vzxWqGezcVQIlt+7tNvHWGdSu7rrTlUeGXL7tC+a+wGnyIQ i54uGhc+rdl9aLDBZ9UTkG7OL3QGK4dBxBpwwsUvd/Y1kYcaUflLdlLlXSBOw1nRVmoT qtk2AcyEyG1jAvzOQv3uSB9YP9MIxC11cGyrETo9zvax2bM0pbFU5cxSkMZK2piW8Jsw vYrE/8Jlxv62CX3EOuHW//pk3tMVH/ak4QXbXrYWA0HGEXziluTN3f+iiixrheUwyJM2 Q8cw== 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:references:in-reply-to:message-id :date:subject:cc:to:from; bh=9LE+6CwQqZyJCGp7wEohBX2uzT4uUYQ+T+k0r6Rdh1s=; fh=0Icot6U8y/jzzh4C/0m1iuu/YoTW8eUo3TM7jO/4ktk=; b=uN5Og3nZIRwsGb++HNdAQasduEVPtoA15PNnJTN9T3FpCwETpkpkwrlwQ+N55HBTGE JXPx3dKI1LmBlH6grZV6th7GJ/G6iTVf98t5yh6MDsMj9sMJK4hU4pnGqKPYkxDAUyOD E6m3e6R7LUpkM+p7lNHZyGymR6pcZOrW3YYtxkUi+gNsWRSbW/wWP7TO2mCSavOfEQqU gSUjs4617DKF/ACZ0d9Vs8F7Fg4sNvZUGOgQLHZBg7dAfomE5tYt03ctb1DZUiWY9G/k 9GhrSw0S/jsV2ccmiuorC7Ha0BP2w1/PPYUrA3IBjX+c+2DdnUE6hAXce89kBQvNUrZo 0ZoA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mf15-20020a170902fc8f00b001eb7d31eab8si10329028plb.645.2024.05.07.06.11.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 06:11:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-171314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A7DA3B23167 for ; Tue, 7 May 2024 12:51:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B67B015E5DE; Tue, 7 May 2024 12:51:00 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C469715E5C1 for ; Tue, 7 May 2024 12:50:58 +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=1715086260; cv=none; b=OPTzfpoGLZgueAOsYmFVWnChOjf52Uz9gGe8G/khR6aFXATdlMgtb0cTrs9zgXK0ckJVFyJH4I2lnFLsPrGgpN0W97QnuWKAekHrd25eM5wmMlfBLZkux0cFFPNyfbslAjPD7KZ+paeJbUrPr2pFMTYyYqpXHpmkYfYKUaHx2B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715086260; c=relaxed/simple; bh=1Vmrp0e+RcUgD8RfroNk+xVONiQfiA5uYlYtIhT3sa8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fVo4wqbNUTKUA7FbGfqvYExEbR7lg4fJpL1Mp3qXqB18MgrQcCH8agMOQTkv+q5qtCCFmrv7G+GDTmuv6j0j5QfsTIsc81kdd4jbn/ar7wFRAqmWJey2FogzZktI9fApIQjcIxxBPnKOcPcJFEG46X0BKAdnuSJI5mmgKeA1vvc= 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 1529E1063; Tue, 7 May 2024 05:51:24 -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 123F93F793; Tue, 7 May 2024 05:50:55 -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@arm.com, linux-kernel@vger.kernel.org, Hongyan Xia Subject: [RFC PATCH v3 5/6] sched/uclamp: Simplify uclamp_eff_value() Date: Tue, 7 May 2024 13:50:28 +0100 Message-Id: <6209eda0b134ad7a0be8855ffdd7b4c747fb8048.1715082714.git.hongyan.xia2@arm.com> 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: 8bit 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 | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 981ec9205fe8..876a4b05a3fe 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1500,21 +1500,15 @@ uclamp_eff_get(struct task_struct *p, enum uclamp_id clamp_id) return uc_req; } -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; -} - static inline void uclamp_update_active_nolock(struct task_struct *p) { enum uclamp_id clamp_id; - for_each_clamp_id(clamp_id) + for_each_clamp_id(clamp_id) { p->uclamp[clamp_id] = uclamp_eff_get(p, clamp_id); + p->uclamp[clamp_id].active = 1; + } } static inline void @@ -1772,6 +1766,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 = 0; } } diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index b99d176623e1..eb810cd9f3d9 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2999,8 +2999,6 @@ static inline unsigned long cpu_util_rt(struct rq *rq) #endif #ifdef CONFIG_UCLAMP_TASK -unsigned long uclamp_eff_value(struct task_struct *p, enum uclamp_id clamp_id); - static inline unsigned long root_cfs_util_uclamp(struct rq *rq) { long ret = READ_ONCE(rq->cfs.avg.util_avg); @@ -3023,6 +3021,18 @@ static inline bool uclamp_is_used(void) return static_branch_likely(&sched_uclamp_used); } +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; + + if (clamp_id == UCLAMP_MIN) + return 0; + + return SCHED_CAPACITY_SCALE; +} + static inline void util_bias_enqueue(struct sched_avg *avg, struct task_struct *p) { -- 2.34.1