Re: interesting skylake perf tidbit

2018-07-06 Thread Maxime Villard

Le 18/06/2018 à 14:29, m...@netbsd.org a écrit :

joerg called it stupid and said we should use monitor, he's probably
right. new arm also has a similar thing.


The thing is, there are several SPINLOCK_BACKOFF()s that we just can't
replace by monitor. For example because we want to measure the delay under
LOCKDEBUG.


(Perhaps a tunable read-mostly SPINLOCK_BACKOFF_* would be worthwhile?)


You mean, like, a configurable SPINLOCK_BACKOFF_MIN? Yes, that seems doable.

I guess we should do both; use "monitor" when possible, and in the places
that are still required to use "pause", use a lower BACKOFF_MIN (set at
boot time, depending on the cpu model) to compensate for the increased CPU
latency.

There will still be a loss in this case, because the cycle ratio is 14
(10c -> 140c), but BACKOFF_MIN equals 4.

By the way I'm wondering if KabyLake and later generations have the same
increased latency, if they do we definitely need to fix that.

I guess you have a Skylake, is there any seeable effect?


Also on the same topic: SPINLOCK_RUN_HOOK seems to be unused?


Yes, please remove.


Re: interesting skylake perf tidbit

2018-06-18 Thread Paul Goyette

On Mon, 18 Jun 2018, m...@netbsd.org wrote:


For anyone interested in performance tuning..

https://aloiskraus.wordpress.com/2018/06/16/why-skylakex-cpus-are-sometimes-50-slower-how-intel-has-broken-existing-code/

tl;dr pause in newer skylakes is a lot.
We call this internally x86_pause and do an entire function call for it
(could use an intrinsic like __builtin_ia32_pause() too for these
things...)

It's our choice for SPINLOCK_BACKOFF_HOOK.

(Perhaps a tunable read-mostly SPINLOCK_BACKOFF_* would be worthwhile?)

Also on the same topic: SPINLOCK_RUN_HOOK seems to be unused?


Just curious - does anyone know if (or how) this affects AMD processors?


+--+--++
| Paul Goyette | PGP Key fingerprint: | E-mail addresses:  |
| (Retired)| FA29 0E3B 35AF E8AE 6651 | paul at whooppee dot com   |
| Kernel Developer | 0786 F758 55DE 53BA 7731 | pgoyette at netbsd dot org |
+--+--++