Re: [PATCH v5] x86/hpet: Reduce HPET counter read contention

From: Dave Hansen
Date: Fri Aug 12 2016 - 17:44:15 EST


On 08/12/2016 02:25 PM, Waiman Long wrote:
> + do {
> + cpu_relax();
> + new.lockval = READ_ONCE(hpet.lockval);
> + } while ((new.value == old.value) && raw_spin_is_locked(&new.lock));

While it gets more far-fetched, this isn't guaranteed to make progress
until the saved HPET value actually changes. You could have a constant
stream of other CPUs going and doing hpet_readl() (and getting the same
value back from a sloooow HPET). So each time through this loop, this
processor sees (new.value == old.value), and sees the lock held.