From a19bd8e30eba1673782376a93e9787ed9b490e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20E=C3=9Fer?= Date: Sat, 1 Jan 2022 11:41:54 +0100 Subject: [PATCH] Restore variable aliasing in the context of cpu set operations A simplification of set operations removed side-effects of the previous code, which are restored by this commit. --- sys/kern/kern_rmlock.c | 3 ++- sys/kern/sched_4bsd.c | 6 ++++-- sys/kern/subr_kdb.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c index 5e64f79e383..08a01fca982 100644 --- a/sys/kern/kern_rmlock.c +++ b/sys/kern/kern_rmlock.c @@ -548,7 +548,8 @@ _rm_wlock(struct rmlock *rm) if (CPU_CMP(&rm->rm_writecpus, &all_cpus)) { /* Get all read tokens back */ - CPU_ANDNOT(&readcpus, &all_cpus, &rm->rm_writecpus); + readcpus = all_cpus; + CPU_ANDNOT(&readcpus, &readcpus, &rm->rm_writecpus); rm->rm_writecpus = all_cpus; /* diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index ae8c77f3aa4..5233cba95c5 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -1179,7 +1179,8 @@ forward_wakeup(int cpunum) } if (forward_wakeup_use_mask) { - CPU_ANDNOT(&map, &idle_cpus_mask, &dontuse); + map = idle_cpu_mask; + CPU_ANDNOT(&map, &map, &dontuse); /* If they are both on, compare and use loop if different. */ if (forward_wakeup_use_loop) { @@ -1365,7 +1366,8 @@ sched_add(struct thread *td, int flags) kick_other_cpu(td->td_priority, cpu); } else { if (!single_cpu) { - CPU_ANDNOT(&tidlemsk, &idle_cpus_mask, &hlt_cpus_mask); + tidlemsk = idle_cpus_mask; + CPU_ANDNOT(&tidlemsk, &tidlemsk, &hlt_cpus_mask); CPU_CLR(cpuid, &tidlemsk); if (!CPU_ISSET(cpuid, &idle_cpus_mask) && diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 2218c20586f..14a0205fc09 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -707,7 +707,8 @@ kdb_trap(int type, int code, struct trapframe *tf) if (!SCHEDULER_STOPPED()) { #ifdef SMP - CPU_ANDNOT(&other_cpus, &all_cpus, &stopped_cpus); + other_cpus = all_cpus; + CPU_ANDNOT(&other_cpus, &other_cpus, &stopped_cpus); CPU_CLR(PCPU_GET(cpuid), &other_cpus); stop_cpus_hard(other_cpus); #endif