lkml.org 
[lkml]   [2019]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.

\
 
 \ /
  Last update: 2019-12-10 18:33    [W:0.049 / U:10.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site