Skip to content

Commit 16a03c7

Browse files
Liao Changrafaeljw
authored andcommitted
cpufreq: schedutil: Merge initialization code of sg_cpu in single loop
The initialization code of the per-cpu sg_cpu struct is currently split into two for-loop blocks. This can be simplified by merging the two blocks into a single loop. This will make the code more maintainable. Signed-off-by: Liao Chang <[email protected]> Acked-by: Viresh Kumar <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 37b6ddb commit 16a03c7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

kernel/sched/cpufreq_schedutil.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -767,14 +767,6 @@ static int sugov_start(struct cpufreq_policy *policy)
767767

768768
sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
769769

770-
for_each_cpu(cpu, policy->cpus) {
771-
struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
772-
773-
memset(sg_cpu, 0, sizeof(*sg_cpu));
774-
sg_cpu->cpu = cpu;
775-
sg_cpu->sg_policy = sg_policy;
776-
}
777-
778770
if (policy_is_shared(policy))
779771
uu = sugov_update_shared;
780772
else if (policy->fast_switch_enabled && cpufreq_driver_has_adjust_perf())
@@ -785,6 +777,9 @@ static int sugov_start(struct cpufreq_policy *policy)
785777
for_each_cpu(cpu, policy->cpus) {
786778
struct sugov_cpu *sg_cpu = &per_cpu(sugov_cpu, cpu);
787779

780+
memset(sg_cpu, 0, sizeof(*sg_cpu));
781+
sg_cpu->cpu = cpu;
782+
sg_cpu->sg_policy = sg_policy;
788783
cpufreq_add_update_util_hook(cpu, &sg_cpu->update_util, uu);
789784
}
790785
return 0;

0 commit comments

Comments
 (0)