Re: [RFC 08/20] mm: store completed TLB generation
From: Peter Zijlstra
Date: Mon Feb 01 2021 - 06:53:17 EST
On Sat, Jan 30, 2021 at 04:11:20PM -0800, Nadav Amit wrote:
> +static inline void tlb_update_generation(atomic64_t *gen, u64 new_gen)
> +{
> + u64 cur_gen = atomic64_read(gen);
> +
> + while (cur_gen < new_gen) {
> + u64 old_gen = atomic64_cmpxchg(gen, cur_gen, new_gen);
> +
> + /* Check if we succeeded in the cmpxchg */
> + if (likely(cur_gen == old_gen))
> + break;
> +
> + cur_gen = old_gen;
> + };
> +}
u64 cur_gen = atomic64_read(gen);
while (cur_gen < new_gen && !atomic64_try_cmpxchg(gen, &cur_gen, new_gen))
;