Re: [PATCH v2] sched/fair: Prefer waker CPU for reciprocal sync wakeups

From: Shubhang

Date: Thu Jul 23 2026 - 20:47:30 EST


Hi Prateek,

On Thu, 23 Jul 2026, K Prateek Nayak wrote:
+ if (!cpumask_test_cpu(cpu, p->cpus_ptr))
+ return false;

want_affine already covers the affinity test now that you've moved it
into the SD_WAKE_AFFINE branch.

Agreed, I'll drop this from the helper.

+ if (sched_asym_cpucap_active()) {
+ sync_entity_load_avg(&p->se);
+ if (!task_fits_cpu(p, cpu))
+ return false;
+ }
+
+ return true;

Reads a lot like WA_IDLE. Couldn't this simply be an early returns
in select_idle_sibling() if we passed wake_flags there?


This does show up as select_idle_sibling() overriding the wake-affine
target with an idle CPU.

But if we move the check there, wake_flags alone is not enough to preserve the SD_WAKE_AFFINE/isolcpus fix from v2. SIS would also need to know that the existing SD_WAKE_AFFINE check was reached.

Also, putting the early return only under sched_smt_active() &&
!has_idle_core handles the SMT case, but would drop the non-SMT case where the Ampere Altra improvement comes from.

So I can either keep the smaller check in the SD_WAKE_AFFINE block with
the cleanups, or move it into SIS with an explicit affine_sd argument and separate non-SMT/SMT handling.

if (want_affine && (tmp->flags & SD_WAKE_AFFINE) &&
cpumask_test_cpu(prev_cpu, sched_domain_span(tmp))) {
+ if (sync &&
+ READ_ONCE(p->last_wakee) == current &&

No need for READ_ONCE(), Last wakee is recorded when "p" has last
woken up a task and given we are now doing a wakeup for "p", it
is completely off the rq and p->last_wakee is stable.

Makes sense, will drop that. On the non-SMT Ampere Altra system I tested on, keeping the smaller SD_WAKE_AFFINE version with the cleanups gives the beter result in comparison.

Regards,
Shubhang Kaushik