Re: [PATCH v3 01/21] sched/cache: Introduce infrastructure for cache-aware load balancing

From: Madadi Vineeth Reddy

Date: Sat Feb 14 2026 - 07:27:45 EST


Hi Tim,
Thanks for the patch series.

On 11/02/26 03:48, Tim Chen wrote:
> From: "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>
>
> Adds infrastructure to enable cache-aware load balancing,
> which improves cache locality by grouping tasks that share resources
> within the same cache domain. This reduces cache misses and improves
> overall data access efficiency.

[..snip..]

> +void mm_init_sched(struct mm_struct *mm,
> + struct sched_cache_time __percpu *_pcpu_sched)
> +{
> + unsigned long epoch;
> + int i;
> +
> + for_each_possible_cpu(i) {
> + struct sched_cache_time *pcpu_sched = per_cpu_ptr(_pcpu_sched, i);
> + struct rq *rq = cpu_rq(i);
> +
> + pcpu_sched->runtime = 0;
> + pcpu_sched->epoch = rq->cpu_epoch;
> + epoch = rq->cpu_epoch;

Shouldn't cpu_epoch be read under cpu_epoch_lock, similar to how fraction_mm_sched()
and __update_mm_sched() acquire the lock before accessing this field?

Thanks,
Vineeth

> + }
> +
> + raw_spin_lock_init(&mm->sc_stat.lock);
> + mm->sc_stat.epoch = epoch;
> + mm->sc_stat.cpu = -1;
> +
> + /*
> + * The update to mm->sc_stat should not be reordered
> + * before initialization to mm's other fields, in case
> + * the readers may get invalid mm_sched_epoch, etc.
> + */
> + smp_store_release(&mm->sc_stat.pcpu_sched, _pcpu_sched);
> +}

[..snip..]