Skip to content
  • Byungchul Park's avatar
    locking/lockdep: Handle non(or multi)-acquisition of a crosslock · 28a903f6
    Byungchul Park authored
    
    
    No acquisition might be in progress on commit of a crosslock. Completion
    operations enabling crossrelease are the case like:
    
       CONTEXT X                         CONTEXT Y
       ---------                         ---------
       trigger completion context
                                         complete AX
                                            commit AX
       wait_for_complete AX
          acquire AX
          wait
    
       where AX is a crosslock.
    
    When no acquisition is in progress, we should not perform commit because
    the lock does not exist, which might cause incorrect memory access. So
    we have to track the number of acquisitions of a crosslock to handle it.
    
    Moreover, in case that more than one acquisition of a crosslock are
    overlapped like:
    
       CONTEXT W        CONTEXT X        CONTEXT Y        CONTEXT Z
       ---------        ---------        ---------        ---------
       acquire AX (gen_id: 1)
                                         acquire A
                        acquire AX (gen_id: 10)
                                         acquire B
                                         commit AX
                                                          acquire C
                                                          commit AX
    
       where A, B and C are typical locks and AX is a crosslock.
    
    Current crossrelease code performs commits in Y and Z with gen_id = 10.
    However, we can use gen_id = 1 to do it, since not only 'acquire AX in X'
    but 'acquire AX in W' also depends on each acquisition in Y and Z until
    their commits. So make it use gen_id = 1 instead of 10 on their commits,
    which adds an additional dependency 'AX -> A' in the example above.
    
    Signed-off-by: default avatarByungchul Park <byungchul.park@lge.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: akpm@linux-foundation.org
    Cc: boqun.feng@gmail.com
    Cc: kernel-team@lge.com
    Cc: kirill@shutemov.name
    Cc: npiggin@gmail.com
    Cc: walken@google.com
    Cc: willy@infradead.org
    Link: http://lkml.kernel.org/r/1502089981-21272-8-git-send-email-byungchul.park@lge.com
    
    
    Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
    28a903f6