Skip to content
Snippets Groups Projects
Commit 1d7f856c authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

jump_label: Fix static_key_slow_dec() yet again


While commit 83ab38ef ("jump_label: Fix concurrency issues in
static_key_slow_dec()") fixed one problem, it created yet another,
notably the following is now possible:

  slow_dec
    if (try_dec) // dec_not_one-ish, false
    // enabled == 1
                                slow_inc
                                  if (inc_not_disabled) // inc_not_zero-ish
                                  // enabled == 2
                                    return

    guard((mutex)(&jump_label_mutex);
    if (atomic_cmpxchg(1,0)==1) // false, we're 2

                                slow_dec
                                  if (try-dec) // dec_not_one, true
                                  // enabled == 1
                                    return
    else
      try_dec() // dec_not_one, false
      WARN

Use dec_and_test instead of cmpxchg(), like it was prior to
83ab38ef. Add a few WARNs for the paranoid.

Fixes: 83ab38ef ("jump_label: Fix concurrency issues in static_key_slow_dec()")
Reported-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Tested-by: default avatarKlara Modin <klarasmodin@gmail.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
parent fe513c2e
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment