Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2471979rdb; Wed, 4 Oct 2023 02:07:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGD5JD+1V8JdUqvlFLf3nJn1Oz0hcv4mQz843aFuWcYx8vKxLVY92CKczTJQuz5t4Yq1+u+ X-Received: by 2002:a05:6808:1919:b0:3ae:5442:ed1b with SMTP id bf25-20020a056808191900b003ae5442ed1bmr2639589oib.43.1696410450871; Wed, 04 Oct 2023 02:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696410450; cv=none; d=google.com; s=arc-20160816; b=n7o4NpmYzO95ZuQ/RB2vDkqNyj92LHSAI7esrP5ynYZtuK7/fVOLfIInmhy4vu/AjS 2DBwytwVFm56t39TW54mpg3ecPgggqFgVDvOCsldGZ8M4mN48fe315KBMG8bi86ljE36 9fxv38ETbf1TBVbfpqqd3cTmhzlaT0i+qREuGb2/VoyRbA96UR2mfvf6TAesFgOJnm35 5O2md+PzB7PuH5ZvY6AnzJU5/Wl0NlHV4xCtgQ7/f+eb47UafoWjB5qcwxEFhhgRW900 bUJ0Cb13DexbsVcSCvon9C3yAAJPf8H4pKJOQGtkQGmjNmIih/ldKTuEdhlAlVK0Vure WNKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tVR3+Hf5VRihCCMTZC8akJLFighbyxag/8L5v7l5lU0=; fh=DytZTu2pMywOIfCUxyQ/G2hQukJX6WKcLQPROmdBvaY=; b=kFkVqVOCT08+KVPLof4JmPMEUxffvZPuQ8VsCgNEyrEjy5GkoS3ADgGJ53xARCO+ly ib7R9KuT74dvaTZ2dxSZqDtSFuMkAxeyN+RsACbu4zyXRdiH+AbRonI48GA8DMZfMmQh MXD+5neFdaRU7AOu/Og7Q2hbyOkrAAFlcNHK8PL3Lw3TTzVB3XYqgyfrlSNQPxnq1E1J zkTRMxPRa1n+jXu0l00yhL6LAGcJHBEg9LaREKctgH/Q2XMjIwUq8SRQjJN2Hf2fOlgs sWhfFyR4IZb/pcKtqdJJfl4LKC6jGdmAbgklKEeVUdQhDvWxaCUnrjhRQfi67JRqWvKR LeXg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id y7-20020a636407000000b005893a7c43a4si2866808pgb.320.2023.10.04.02.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 02:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E66D68097143; Wed, 4 Oct 2023 02:07:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241985AbjJDJGO (ORCPT + 99 others); Wed, 4 Oct 2023 05:06:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241094AbjJDJFx (ORCPT ); Wed, 4 Oct 2023 05:05:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BE0CBF0 for ; Wed, 4 Oct 2023 02:05:44 -0700 (PDT) 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 E5187153B; Wed, 4 Oct 2023 02:06:22 -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 E08FB3F59C; Wed, 4 Oct 2023 02:05:42 -0700 (PDT) From: Hongyan Xia To: Ingo Molnar , Peter Zijlstra , Vincent Guittot , Dietmar Eggemann , Juri Lelli Cc: Qais Yousef , Morten Rasmussen , Lukasz Luba , Christian Loehle , linux-kernel@vger.kernel.org, Hongyan Xia Subject: [RFC PATCH 6/6] sched/uclamp: Simplify uclamp_eff_value() Date: Wed, 4 Oct 2023 10:04:54 +0100 Message-Id: <6006f27e2cae8c5f8b00987aa04ee29317aabcc1.1696345700.git.Hongyan.Xia2@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 04 Oct 2023 02:07:28 -0700 (PDT) From: Hongyan Xia The commit sched: Remove all uclamp bucket logic removes uclamp_{inc/dec}() functions, so now p->uclamp contains the correct values all the time after a update_uclamp_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 c5bf01e7df28..737921a9dd91 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -1483,21 +1483,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 @@ -1759,6 +1753,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 30dee8eb2ed9..896626afbedc 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2986,8 +2986,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); - /* * When uclamp is compiled in, the aggregation at rq level is 'turned off' * by default in the fast path and only gets turned on once userspace performs @@ -3001,6 +2999,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 unsigned long root_cfs_util(struct rq *rq) { return READ_ONCE(rq->root_cfs_util_uclamp); -- 2.34.1