Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp254635pxa; Thu, 27 Aug 2020 01:01:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz53MUt27+Zs+pa8Gml+Vet/DKJKYnncdu2KycSFYBKhidUI+p6BS+0nEaxX1OPSfmiuJTt X-Received: by 2002:a17:907:2173:: with SMTP id rl19mr2023640ejb.514.1598515307524; Thu, 27 Aug 2020 01:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598515307; cv=none; d=google.com; s=arc-20160816; b=fUB0Qn4l4GjSrPcKMABkvi/G/t/DYV9JMcEhKa4he90jqQ1gZkB47Zq72FG0gOsQhk fUkD1+MeAQFJcab3JWpiZK0PGvvrvIvcNEhp+Ww30pjFSjwXLwBxhXqau2uaHTO8XlmY 09n7JqE4Ro1JfHt4c0MQciUFOHNomgBTWHKeh5ngLrVQjhH7z5jgNAKOEIbzivVjXJl0 uys8W5t5/FuReD1Gm/moP3CfZH49UvzRSqPch58GO7ZHTVj9tc5hA353AN152JotqshZ guJO6Ftq7YEmkxp/hrQxr1zDZumKkZsonmCmwiOApUpik0HePr7+3oki8V4N4xByruMA wpIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=CJNGFXmIzTTKA+mr7sy1cpSLK/82tJMzknTULsKXe08=; b=d60YC6XOfPFiardX+VF3BAkPvxwXjR1bgppuHnm3re9nmsq7InxHmrG5PKqG+F1lyh 4Se1L0FEdP1vMwku7t0kmYnXgibNeeXVFLmyLK8S9hOrP3TSZDSq5Ejqh6UrnwBqpwa5 MKJdL+Oh0N4MoLR119MfDjvR0b1dnoz4t74nlqKWZZZ68RRn0imAvZ1HiFdVgiwu+9vg opavKUkGW3XFqWx5ZufIuCRR9lzdPRHexfDQ+qZZNmoS5bcGm5U2hb6tgbaDvkD5R3KB kidX3fQSrwQhve2Bzy9xA+FO8tuTTEjEJDdi1F+Wg7GS9m4/uTTHAVKTp7UIytSAhuOR 777w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=s8OIq+si; dkim=neutral (no key) header.i=@vger.kernel.org header.b=XoJWfpSK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si992814eds.137.2020.08.27.01.01.25; Thu, 27 Aug 2020 01:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=s8OIq+si; dkim=neutral (no key) header.i=@vger.kernel.org header.b=XoJWfpSK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbgH0IAI (ORCPT + 99 others); Thu, 27 Aug 2020 04:00:08 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:36550 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbgH0HyU (ORCPT ); Thu, 27 Aug 2020 03:54:20 -0400 Date: Thu, 27 Aug 2020 07:54:17 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1598514857; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CJNGFXmIzTTKA+mr7sy1cpSLK/82tJMzknTULsKXe08=; b=s8OIq+siHj8Csj140JQY/sQ4LbMb14Gy68mO7eV+UxzpAa9dAyFGerq0ny3rSChsVt69ys uRpD6qiSJb4wTz/X6qxvurfcL/jBdc1VB+84hz55ga22p0o7ZR7CM5g6YFdIlWcvsgbn0w OtrxLQU43HJCdHrW0vyHO6LvlZffErHz2shxxyE+vBDIXCrzS9kj9/e6AqfHQYxzKwpYjG /Xe+Jo0xBLmvmFlYKVmgp7O/V7Ry9FIwznvZO/JZSO6jVYeWgIosLsu02gmTcf9kQZkGkZ goXx1ZDkJ6aA1o+iBroUkk1S3xpr6ondy96Xb8BntE0LejL3EMsu09ZYxwAWWw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1598514857; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CJNGFXmIzTTKA+mr7sy1cpSLK/82tJMzknTULsKXe08=; b=XoJWfpSKzAbveU5ddHKTI4tieQ+L6Ou+vPqxRcS5ze3apSfFQSVlnO2Y5Ff4YUdEcrcZ7L KcXiz0jJwCZGnUBg== From: "tip-bot2 for Boqun Feng" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior Cc: Boqun Feng , "Peter Zijlstra (Intel)" , x86 , LKML In-Reply-To: <20200807074238.1632519-14-boqun.feng@gmail.com> References: <20200807074238.1632519-14-boqun.feng@gmail.com> MIME-Version: 1.0 Message-ID: <159851485713.20229.4453836851225791723.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the locking/core branch of tip: Commit-ID: d4f200e579e96051f1f081f795820787826eb234 Gitweb: https://git.kernel.org/tip/d4f200e579e96051f1f081f795820787826eb234 Author: Boqun Feng AuthorDate: Fri, 07 Aug 2020 15:42:32 +08:00 Committer: Peter Zijlstra CommitterDate: Wed, 26 Aug 2020 12:42:06 +02:00 lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior As our chain cache doesn't differ read/write locks, so even we can detect a read-lock/lock-write deadlock in check_noncircular(), we can still be fooled if a read-lock/lock-read case(which is not a deadlock) comes first. So introduce this test case to test specific to the chain cache behavior on detecting recursive read lock related deadlocks. Signed-off-by: Boqun Feng Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20200807074238.1632519-14-boqun.feng@gmail.com --- lib/locking-selftest.c | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index caadc4d..002d1ec 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -400,6 +400,49 @@ static void rwsem_ABBA1(void) * read_lock(A) * spin_lock(B) * spin_lock(B) + * write_lock(A) + * + * This test case is aimed at poking whether the chain cache prevents us from + * detecting a read-lock/lock-write deadlock: if the chain cache doesn't differ + * read/write locks, the following case may happen + * + * { read_lock(A)->lock(B) dependency exists } + * + * P0: + * lock(B); + * read_lock(A); + * + * { Not a deadlock, B -> A is added in the chain cache } + * + * P1: + * lock(B); + * write_lock(A); + * + * { B->A found in chain cache, not reported as a deadlock } + * + */ +static void rlock_chaincache_ABBA1(void) +{ + RL(X1); + L(Y1); + U(Y1); + RU(X1); + + L(Y1); + RL(X1); + RU(X1); + U(Y1); + + L(Y1); + WL(X1); + WU(X1); + U(Y1); // should fail +} + +/* + * read_lock(A) + * spin_lock(B) + * spin_lock(B) * read_lock(A) */ static void rlock_ABBA2(void) @@ -2062,6 +2105,10 @@ void locking_selftest(void) pr_cont(" |"); dotest(rwsem_ABBA3, FAILURE, LOCKTYPE_RWSEM); + print_testname("chain cached mixed R-L/L-W ABBA"); + pr_cont(" |"); + dotest(rlock_chaincache_ABBA1, FAILURE, LOCKTYPE_RWLOCK); + printk(" --------------------------------------------------------------------------\n"); /*