From: "Ted Unangst" Subject: Re: sys/sysctl: make hw.setperf MP safe To: "Kirill A. Korinsky" Cc: "OpenBSD tech" , mvs@openbsd.org Date: Wed, 21 May 2025 13:58:13 -0400 On 2025-05-21, Kirill A. Korinsky wrote: > tech@, > > Here a diff which makes hw.setperf MP safe. Am I out of the loop? What machine doesn't load an int atomically? > - perflevel = 100; > - cpu_setperf(perflevel); > + atomic_store_int(&perflevel, 100); > + cpu_setperf(atomic_load_int(&perflevel)); Constructs like this in particular look weird. If there's a race, this doesn't fix it.