Messages in this thread | | | Date | Tue, 10 Dec 2019 18:32:09 +0100 | From | Peter Zijlstra <> | Subject | Re: [PATCH -tip 1/2] x86/alternative: Sync bp_patching update for avoiding NULL pointer exception |
| |
On Wed, Dec 11, 2019 at 01:44:01AM +0900, Masami Hiramatsu wrote:
> This looks good, but I feel it is a bit complicated. > > If we use atomic (and spin-wait) here, can we use atomic_inc_not_zero() > in the poke_int3_handler() at first for making sure the bp_batching is > under operation or not? > I think it makes things simpler, like below. > > --------- > atomic_t bp_refcnt; > > poke_int3_handler() > { > smp_rmb(); > if (!READ_ONCE(bp_patching.nr_entries)) > return 0; > if (!atomic_inc_not_zero(&bp_refcnt)) > return 0; > smp_mb__after_atomic(); > [use bp_patching] > atomic_dec(&bp_refcnt); > } > > text_poke_bp_batch() > { > bp_patching.vec = tp; > bp_patching.nr_entries = nr_entries; > smp_wmb(); > atomic_inc(&bp_refcnt); > ... > atomic_dec(&bp_refcnt); > /* wait for all running poke_int3_handler(). */ > atomic_cond_read_acquire(&bp_refcnt, !VAL); > bp_patching.vec = NULL; > bp_patching.nr_entries = 0; > }
I feel that is actually more complicated... Let me try to see if I can simplify things.
| |