Re: [PATCH v2 2/3] x86/sched: Add basic support for CPU capacity scaling

From: Chen Yu
Date: Mon Aug 12 2024 - 21:28:03 EST


Hi Rafael,

On 2024-08-12 at 14:42:26 +0200, Rafael J. Wysocki wrote:
> +void arch_set_cpu_capacity(int cpu, unsigned long cap, unsigned long base_cap,
> + unsigned long max_freq, unsigned long base_freq)
> +{
> + if (static_branch_likely(&arch_hybrid_cap_scale_key)) {
> + WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->capacity,
> + div_u64(cap << SCHED_CAPACITY_SHIFT, base_cap));
> + WRITE_ONCE(per_cpu_ptr(arch_cpu_scale, cpu)->freq_ratio,
> + div_u64(max_freq << SCHED_CAPACITY_SHIFT, base_freq));
>

Would the capacity update be frequently invoked? Just wonder if we could
first READ_ONCE() to check if the value is already the value we want to
change to, to avoid one write and less cache snoop overhead (in case other
CPU reads this CPU's capacity)

thanks,
Chenyu