Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1739299
| Path | csiph.com!news.redatomik.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Boqun Feng <boqun.feng@gmail.com> |
| Newsgroups | linux.kernel |
| Subject | [RFC tip/locking/lockdep v3 08/14] lockdep: Fix recursive read lock related safe->unsafe detection |
| Date | Tue, 26 Sep 2017 00:20:01 +0200 |
| Message-ID | <utJTj-47L-9@gated-at.bofh.it> (permalink) |
| References | <utJTj-47L-3@gated-at.bofh.it> |
| X-Original-To | linux-kernel@vger.kernel.org |
| Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+dNXvExiFeHpZue2rpNbMARDCzsFSJjt1whkE3JzTGM=; b=p3lZKQ3hCzn3Y8/OwcbnK6XzkifwpRsyb5SE8n1Hhq3+VPblVgRdMucp1TgpeLQ6m0 3URj4FqsJ4m5fbI08e0izHhzlJoZTlpqwgVPLmZY4qH9rb0ewRe2mdq28lP/aAfS1ufl pKUkilXUsMEq7LoEQd/AdLZ/XzL6LJnFiWWYQE4Gc2GTD/rHVr+rJgQ4/8X+hDcyIcss nB+/vYgqhNQLpHn38TPVDL7+nB94X6mtqjG+IFOjGreLmlMVoMGJWZM1tJC0rDENr4w0 lJhZkrUmCNlyaSngwsrLS6PV1PHEb9A9NMqY63oI6Y+OiPlsCzvkD9lBDfqNZyPdsvYd uWYQ== |
| X-Google-Dkim-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+dNXvExiFeHpZue2rpNbMARDCzsFSJjt1whkE3JzTGM=; b=RI2oobSIP79LVCAJO6GkudQxcIEaFjWq5dc7P2bl9O0cuWTAYLw0OWIVK6rSn1nBa9 8/2/jMpAuRUWLUN4WmuiIXu4ycV3E5DvjlnCyxuxt85sdfzyI4Z2RGZ+WLhSey47ndri e6JONs95qTYIqVq0vfNDb96nd18HhcLGniVvrjCI9Dsf1cETr8tIfbOCAnG/sDQU58XN 5Qj6gEbGdGT4xDbVjb8ioXPPGfd4CNyfKjOLOMFHDpEnegK6rY+9ypTOBvMsUedvg+LI YdJStiEKgJTWM2POLp4qNwrynP+IDH+TyJHeAV2JgSVX/P+TEbMRIsq7KkRwEr5pZQE6 6bLA== |
| X-Gm-Message-State | AHPjjUiLRX+ffWAXqarvRgUUxSUGHJK30yBamOufx12vVdhBNTu/uwQV 03SP50KHllY7jm3ZbJuZ7rpb6ADg |
| X-Google-SMTP-Source | AOwi7QATditcIoPVWzYnoPajtmP2d+TeVOrgZC1r/W0CebJFpTpGtjif0VihZKZvkJ5CGGKnUmxzQw== |
| X-Received | by 10.159.255.70 with SMTP id u6mr7091825pls.25.1506377947712; Mon, 25 Sep 2017 15:19:07 -0700 (PDT) |
| X-Mailer | git-send-email 2.14.1 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 72 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | Ingo Molnar <mingo@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Gautham R Shenoy <ego@linux.vnet.ibm.com>, Byungchul Park <byungchul.park@lge.com>, Boqun Feng <boqun.feng@gmail.com> |
| X-Original-Date | Tue, 26 Sep 2017 06:18:42 +0800 |
| X-Original-Message-ID | <20170925221848.6646-9-boqun.feng@gmail.com> |
| X-Original-References | <20170925221848.6646-1-boqun.feng@gmail.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1739299 |
Show key headers only | View raw
There are four cases for recursive read lock realted deadlocks:
(--(X..Y)--> means a strong dependency path starts with a --(X*)-->
dependency and ends with a --(*Y)-- dependency.)
1. An irq-safe lock L1 has a dependency --(*..*)--> to an
irq-unsafe lock L2.
2. An irq-read-safe lock L1 has a dependency --(N..*)--> to an
irq-unsafe lock L2.
3. An irq-safe lock L1 has a dependency --(*..N)--> to an
irq-read-unsafe lock L2.
4. An irq-read-safe lock L1 has a dependency --(N..N)--> to an
irq-read-unsafe lock L2.
The current check_usage() only checks 1) and 2), so this patch adds
checks for 3) and 4) and makes sure when find_usage_{back,for}wards find
an irq-read-{,un}safe lock, the traverse path should ends at a
dependency --(*N)-->. Note when we search backwards, --(*N)--> indicates
a real dependency --(N*)-->.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
kernel/locking/lockdep.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index f55c9012025e..c29b058c37b3 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1505,7 +1505,14 @@ check_redundant(struct lock_list *root, struct held_lock *target,
static inline int usage_match(struct lock_list *entry, void *bit)
{
- return entry->class->usage_mask & (1 << (enum lock_usage_bit)bit);
+ enum lock_usage_bit ub = (enum lock_usage_bit)bit;
+
+
+ if (ub & 1)
+ return entry->class->usage_mask & (1 << ub) &&
+ !entry->is_rr;
+ else
+ return entry->class->usage_mask & (1 << ub);
}
@@ -1816,6 +1823,10 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
exclusive_bit(bit), state_name(bit)))
return 0;
+ if (!check_usage(curr, prev, next, bit,
+ exclusive_bit(bit) + 1, state_name(bit)))
+ return 0;
+
bit++; /* _READ */
/*
@@ -1828,6 +1839,10 @@ static int check_irq_usage(struct task_struct *curr, struct held_lock *prev,
exclusive_bit(bit), state_name(bit)))
return 0;
+ if (!check_usage(curr, prev, next, bit,
+ exclusive_bit(bit) + 1, state_name(bit)))
+ return 0;
+
return 1;
}
--
2.14.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC tip/locking/lockdep v3 08/14] lockdep: Fix recursive read lock related safe->unsafe detection Boqun Feng <boqun.feng@gmail.com> - 2017-09-26 00:20 +0200
csiph-web