Index | Thread | Search

From:
Mark Kettenis <mark.kettenis@xs4all.nl>
Subject:
Re: sys/sysctl: make hw.setperf MP safe
To:
"Ted Unangst" <tedu@tedunangst.com>
Cc:
kirill@korins.ky, tech@openbsd.org, mvs@openbsd.org
Date:
Thu, 22 May 2025 00:17:43 +0200

Download raw body.

Thread
  • Ted Unangst:

    sys/sysctl: make hw.setperf MP safe

  • > From: "Ted Unangst" <tedu@tedunangst.com>
    > 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?
    
    https://lwn.net/Articles/793253/
    
    I'm still not convinced load tearing and store tearing are genuine
    problems.  All the examples I've seen from the Linux developers are
    somewhat convoluted, involving things like unions or type punning.
    But there is currently no consensus among OpenBSD developers.
    
    But yes, 
    
    > 
    > > -		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.
    
    It is code like this that makes me believe the current path mvs@ is on
    isn't right.
    
    
  • Ted Unangst:

    sys/sysctl: make hw.setperf MP safe