mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
sched: Simplify sysctl_sched_uclamp_handler()
Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Link: https://lore.kernel.org/r/20230801211811.896559109@infradead.org
This commit is contained in:
parent
7537b90c00
commit
0f92cdf36f
|
|
@ -1827,7 +1827,8 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
|
|||
int old_min, old_max, old_min_rt;
|
||||
int result;
|
||||
|
||||
mutex_lock(&uclamp_mutex);
|
||||
guard(mutex)(&uclamp_mutex);
|
||||
|
||||
old_min = sysctl_sched_uclamp_util_min;
|
||||
old_max = sysctl_sched_uclamp_util_max;
|
||||
old_min_rt = sysctl_sched_uclamp_util_min_rt_default;
|
||||
|
|
@ -1836,7 +1837,7 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
|
|||
if (result)
|
||||
goto undo;
|
||||
if (!write)
|
||||
goto done;
|
||||
return 0;
|
||||
|
||||
if (sysctl_sched_uclamp_util_min > sysctl_sched_uclamp_util_max ||
|
||||
sysctl_sched_uclamp_util_max > SCHED_CAPACITY_SCALE ||
|
||||
|
|
@ -1872,16 +1873,12 @@ static int sysctl_sched_uclamp_handler(struct ctl_table *table, int write,
|
|||
* Otherwise, keep it simple and do just a lazy update at each next
|
||||
* task enqueue time.
|
||||
*/
|
||||
|
||||
goto done;
|
||||
return 0;
|
||||
|
||||
undo:
|
||||
sysctl_sched_uclamp_util_min = old_min;
|
||||
sysctl_sched_uclamp_util_max = old_max;
|
||||
sysctl_sched_uclamp_util_min_rt_default = old_min_rt;
|
||||
done:
|
||||
mutex_unlock(&uclamp_mutex);
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user