linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alfredo Alvarez Fernandez <alfredoalvarezfernandez@gmail.com>
To: mingo@redhat.com, peterz@infradead.org, sasha.levin@oracle.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 0/3] lockdep: liblockdep: Prevent chain_key collisions
Date: Thu, 11 Feb 2016 00:33:29 +0100	[thread overview]
Message-ID: <1455147212-2389-1-git-send-email-alfredoalvarezernandez@gmail.com> (raw)

This patch series prevents possible collisions in the chain_key
hashing macro iterate_chain_key(key1, key2) that can lead to lockdep 
not detecting very simple deadlocks such as AA or ABBA.

The problem only affects the first allocated lock classes. That could 
explain why it was not seen while running lockdep's test suite, since
by the time the test suite runs there are already registered lock 
classes and the indexes allocated for the lock classes under test are
high enough to avoid collisions.

The patch series also extends the tools/liblockdep test suite with 
tests covering the offending cases.

I came across the problem while testing a simple AA deadlock scenario
in userspace using a pthread_mutex and tools/liblockdep. In that 
context it is fairly easy to have a clean and deterministic initial 
state where the problem can be reproduced.

The proposed solution was tested with the newly introduced tests and
also with lockdep's test suite:
 [    0.000000] Good, all 253 testcases passed! |

Alfredo Alvarez Fernandez (3):
  tools/liblockdep: add userspace version of READ_ONCE
  tools/liblockdep: add tests
  lockdep: prevent chain_key collisions

 kernel/locking/lockdep.c                    | 14 ++++------
 tools/lib/lockdep/tests/AA.c                |  8 +++---
 tools/lib/lockdep/tests/ABA.c               | 13 +++++++++
 tools/lib/lockdep/tests/ABBA_2threads.c     | 43 +++++++++++++++++++++++++++++
 tools/lib/lockdep/uinclude/linux/compiler.h |  1 +
 5 files changed, 67 insertions(+), 12 deletions(-)
 create mode 100644 tools/lib/lockdep/tests/ABA.c
 create mode 100644 tools/lib/lockdep/tests/ABBA_2threads.c

-- 
2.5.0

             reply	other threads:[~2016-02-10 23:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 23:33 Alfredo Alvarez Fernandez [this message]
2016-02-10 23:33 ` [PATCH 1/3] tools/liblockdep: add userspace version of READ_ONCE Alfredo Alvarez Fernandez
2016-02-11 15:16   ` Peter Zijlstra
2016-02-16 16:37     ` Sasha Levin
2016-02-10 23:33 ` [PATCH 2/3] tools/liblockdep: add tests Alfredo Alvarez Fernandez
2016-02-10 23:33 ` [PATCH 3/3] lockdep: prevent chain_key collisions Alfredo Alvarez Fernandez
2016-02-17  8:38   ` Ingo Molnar
2016-02-19  6:48     ` [PATCH v2 0/3] lockdep: liblockdep: Prevent " Alfredo Alvarez Fernandez
2016-02-19  6:48       ` [PATCH v2 1/3] tools/liblockdep: add userspace version of READ_ONCE Alfredo Alvarez Fernandez
2016-02-29 11:22         ` [tip:locking/core] tools/lib/lockdep: Add userspace version of READ_ONCE() tip-bot for Alfredo Alvarez Fernandez
2016-02-19  6:48       ` [PATCH v2 2/3] tools/liblockdep: add tests Alfredo Alvarez Fernandez
2016-02-29 11:23         ` [tip:locking/core] tools/lib/lockdep: Add tests for AA and ABBA locking tip-bot for Alfredo Alvarez Fernandez
2016-02-19  6:48       ` [PATCH v2 3/3] lockdep: prevent and detect chain_key collisions Alfredo Alvarez Fernandez
2016-02-29 11:24         ` [tip:locking/core] locking/lockdep: Detect " tip-bot for Ingo Molnar
2016-02-29 11:24   ` [tip:locking/core] locking/lockdep: Prevent " tip-bot for Alfredo Alvarez Fernandez
2016-02-16 16:38 ` [PATCH 0/3] lockdep: liblockdep: " Sasha Levin
2016-02-16 17:22   ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1455147212-2389-1-git-send-email-alfredoalvarezernandez@gmail.com \
    --to=alfredoalvarezfernandez@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sasha.levin@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).