lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 28 Sep 2020 16:26:43 +0800
From:   Yun Hsiang <hsiang023167@...il.com>
To:     dietmar.eggemann@....com, peterz@...radead.org
Cc:     linux-kernel@...r.kernel.org, Yun Hsiang <hsiang023167@...il.com>
Subject: [PATCH 1/1] sched/uclamp: release per-task uclamp control if user set to default value

If the user wants to release the util clamp and let cgroup to control it,
we need a method to reset.

So if the user set the task uclamp to the default value (0 for UCLAMP_MIN
and 1024 for UCLAMP_MAX), reset the user_defined flag to release control.

Signed-off-by: Yun Hsiang <hsiang023167@...il.com>
---
 kernel/sched/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9a2fbf98fd6f..fa63d70d783a 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1187,6 +1187,7 @@ static void __setscheduler_uclamp(struct task_struct *p,
 				  const struct sched_attr *attr)
 {
 	enum uclamp_id clamp_id;
+	bool user_defined;
 
 	/*
 	 * On scheduling class change, reset to default clamps for tasks
@@ -1210,14 +1211,16 @@ static void __setscheduler_uclamp(struct task_struct *p,
 	if (likely(!(attr->sched_flags & SCHED_FLAG_UTIL_CLAMP)))
 		return;
 
+	user_defined = attr->sched_util_min == 0 ? false : true;
 	if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MIN) {
 		uclamp_se_set(&p->uclamp_req[UCLAMP_MIN],
-			      attr->sched_util_min, true);
+			      attr->sched_util_min, user_defined);
 	}
 
+	user_defined = attr->sched_util_max == 1024 ? false : true;
 	if (attr->sched_flags & SCHED_FLAG_UTIL_CLAMP_MAX) {
 		uclamp_se_set(&p->uclamp_req[UCLAMP_MAX],
-			      attr->sched_util_max, true);
+			      attr->sched_util_max, user_defined);
 	}
 }
 
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ