Skip to content

Commit d81ae8a

Browse files
Qais YousefPeter Zijlstra
authored andcommitted
sched/uclamp: Fix initialization of struct uclamp_rq
struct uclamp_rq was zeroed out entirely in assumption that in the first call to uclamp_rq_inc() they'd be initialized correctly in accordance to default settings. But when next patch introduces a static key to skip uclamp_rq_{inc,dec}() until userspace opts in to use uclamp, schedutil will fail to perform any frequency changes because the rq->uclamp[UCLAMP_MAX].value is zeroed at init and stays as such. Which means all rqs are capped to 0 by default. Fix it by making sure we do proper initialization at init without relying on uclamp_rq_inc() doing it later. Fixes: 69842cb ("sched/uclamp: Add CPU's clamp buckets refcounting") Signed-off-by: Qais Yousef <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Valentin Schneider <[email protected]> Tested-by: Lukasz Luba <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 85c2ce9 commit d81ae8a

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

kernel/sched/core.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,20 @@ static void uclamp_fork(struct task_struct *p)
12391239
}
12401240
}
12411241

1242+
static void __init init_uclamp_rq(struct rq *rq)
1243+
{
1244+
enum uclamp_id clamp_id;
1245+
struct uclamp_rq *uc_rq = rq->uclamp;
1246+
1247+
for_each_clamp_id(clamp_id) {
1248+
uc_rq[clamp_id] = (struct uclamp_rq) {
1249+
.value = uclamp_none(clamp_id)
1250+
};
1251+
}
1252+
1253+
rq->uclamp_flags = 0;
1254+
}
1255+
12421256
static void __init init_uclamp(void)
12431257
{
12441258
struct uclamp_se uc_max = {};
@@ -1247,11 +1261,8 @@ static void __init init_uclamp(void)
12471261

12481262
mutex_init(&uclamp_mutex);
12491263

1250-
for_each_possible_cpu(cpu) {
1251-
memset(&cpu_rq(cpu)->uclamp, 0,
1252-
sizeof(struct uclamp_rq)*UCLAMP_CNT);
1253-
cpu_rq(cpu)->uclamp_flags = 0;
1254-
}
1264+
for_each_possible_cpu(cpu)
1265+
init_uclamp_rq(cpu_rq(cpu));
12551266

12561267
for_each_clamp_id(clamp_id) {
12571268
uclamp_se_set(&init_task.uclamp_req[clamp_id],

0 commit comments

Comments
 (0)