@@ -1043,6 +1043,54 @@ static inline void uclamp_rq_dec(struct rq *rq, struct task_struct *p)
1043
1043
uclamp_rq_dec_id (rq , p , clamp_id );
1044
1044
}
1045
1045
1046
+ static inline void
1047
+ uclamp_update_active (struct task_struct * p , unsigned int clamp_id )
1048
+ {
1049
+ struct rq_flags rf ;
1050
+ struct rq * rq ;
1051
+
1052
+ /*
1053
+ * Lock the task and the rq where the task is (or was) queued.
1054
+ *
1055
+ * We might lock the (previous) rq of a !RUNNABLE task, but that's the
1056
+ * price to pay to safely serialize util_{min,max} updates with
1057
+ * enqueues, dequeues and migration operations.
1058
+ * This is the same locking schema used by __set_cpus_allowed_ptr().
1059
+ */
1060
+ rq = task_rq_lock (p , & rf );
1061
+
1062
+ /*
1063
+ * Setting the clamp bucket is serialized by task_rq_lock().
1064
+ * If the task is not yet RUNNABLE and its task_struct is not
1065
+ * affecting a valid clamp bucket, the next time it's enqueued,
1066
+ * it will already see the updated clamp bucket value.
1067
+ */
1068
+ if (!p -> uclamp [clamp_id ].active ) {
1069
+ uclamp_rq_dec_id (rq , p , clamp_id );
1070
+ uclamp_rq_inc_id (rq , p , clamp_id );
1071
+ }
1072
+
1073
+ task_rq_unlock (rq , p , & rf );
1074
+ }
1075
+
1076
+ static inline void
1077
+ uclamp_update_active_tasks (struct cgroup_subsys_state * css ,
1078
+ unsigned int clamps )
1079
+ {
1080
+ struct css_task_iter it ;
1081
+ struct task_struct * p ;
1082
+ unsigned int clamp_id ;
1083
+
1084
+ css_task_iter_start (css , 0 , & it );
1085
+ while ((p = css_task_iter_next (& it ))) {
1086
+ for_each_clamp_id (clamp_id ) {
1087
+ if ((0x1 << clamp_id ) & clamps )
1088
+ uclamp_update_active (p , clamp_id );
1089
+ }
1090
+ }
1091
+ css_task_iter_end (& it );
1092
+ }
1093
+
1046
1094
#ifdef CONFIG_UCLAMP_TASK_GROUP
1047
1095
static void cpu_util_update_eff (struct cgroup_subsys_state * css );
1048
1096
static void uclamp_update_root_tg (void )
@@ -7160,8 +7208,13 @@ static void cpu_util_update_eff(struct cgroup_subsys_state *css)
7160
7208
uc_se [clamp_id ].bucket_id = uclamp_bucket_id (eff [clamp_id ]);
7161
7209
clamps |= (0x1 << clamp_id );
7162
7210
}
7163
- if (!clamps )
7211
+ if (!clamps ) {
7164
7212
css = css_rightmost_descendant (css );
7213
+ continue ;
7214
+ }
7215
+
7216
+ /* Immediately update descendants RUNNABLE tasks */
7217
+ uclamp_update_active_tasks (css , clamps );
7165
7218
}
7166
7219
}
7167
7220
0 commit comments