Message ID | 20181002212921.30982-1-cota@braap.org |
---|---|
Headers | show |
Series | per-TLB lock | expand |
On 02/10/2018 23:29, Emilio G. Cota wrote: > This series introduces a per-TLB lock. This removes existing UB > (e.g. memset racing with cmpxchg on another thread while flushing), > and in my opinion makes the TLB code simpler to understand. > > I had a bit of trouble finding the best place to initialize the > mutex, since it has to be called before tlb_flush, and tlb_flush > is called quite early during cpu initialization. I settled on > cpu_exec_realizefn, since then cpu->env_ptr has been set > but tlb_flush hasn't yet been called. > > Perf-wise this change does have a small impact (~2% slowdown for > the aarch64 bootup+shutdown test; 1.2% comes from using atomic_read > consistently), but I think this is a fair price for avoiding UB. The UB is unlikely to be an issue in practice, but I like the simplicity. In retrospect it was premature optimization. Paolo