On Wed, Dec 02, 2020 at 07:44:02PM +0100, Anton Lindqvist wrote:
> I'm wondering if smr_grace_wait() could be improved on amd64, assuming
> SMT is disabled, by skipping offline CPUs.
>
> Index: kern/kern_smr.c
> ===================================================================
> RCS file: /cvs/src/sys/kern/kern_smr.c,v
> retrieving revision 1.8
> diff -u -p -r1.8 kern_smr.c
> --- kern/kern_smr.c 3 Apr 2020 03:36:56 -0000 1.8
> +++ kern/kern_smr.c 2 Dec 2020 18:41:29 -0000
> @@ -142,7 +142,7 @@ smr_grace_wait(void)
>
> ci_start = curcpu();
> CPU_INFO_FOREACH(cii, ci) {
> - if (ci == ci_start)
> + if (ci == ci_start || !cpu_is_online(ci))
> continue;
> sched_peg_curproc(ci);
> }
That is not safe. The code should coordinate with switching of hw.smt.
Also, the CPUs that are offline because of hw.smt are not totally
inactive. They might still access SMR-protected data as a result of
interrupts for example.