Received: by 10.223.185.116 with SMTP id b49csp1595138wrg; Wed, 21 Feb 2018 23:09:32 -0800 (PST) X-Google-Smtp-Source: AH8x224VoQo2GtoHr/S2kguqu0orVsI7VW0hgQz1PjmZugrFcwAOVYmpt8VTaWPIrnaZAL32eD60 X-Received: by 10.99.113.90 with SMTP id b26mr4825212pgn.10.1519283371900; Wed, 21 Feb 2018 23:09:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519283371; cv=none; d=google.com; s=arc-20160816; b=g9842EN2OAJMWOCkKHlkOFmT9U/ybjX9XtC2wsQhd6A7cMjjvT8OXCi3gsQBriuB9n PdFJiaZqiAGLpEbg2tzukSrQWzBlpoQSDjM00HZ/Vg8d6ACSpYC2O078PZYKkkMnE/nl Bg7c71dIpc7y5n6MEMICCVdGLttmKbJoe0kUfQv4W9EkrDR5eR7u1UG2WYWzEvgsu2gt PWu7HRJ8x2le7L/x/bMKxTVBBNzE/UOFy6+YX/ee2tyc6fKB2y0Nm0hcGgo9zxpRPTgL gSJwG7WkeCrVhTM/10nkkhoxWQD5HhC8b8ax12Vr3/SPTK/ceqwLkKnhlkBuSEVKJmxQ /rOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=dkKQoWZV8KtCEWix0PkNOj9P1zGovDujjV3MZq8B38E=; b=k2AOr3xpdYY1U0pDTNRKRpVKkSwHX/G43HR3tJTGbuFg+kCJWNO2dUVO0hZb/pgAeU A+eaxV4aLaoQoWyOk8p3n0IVVlZQmJVuHiLNPSHtA/Q03XDNUWcF9X4ZMWo7wOfUmnqI 7v5hSlHhf4c9eMali9WCzRZVVBIhAkh7QY0u+W0Q5lxlggXRSquMhR5QRch9fSs/e58O ch1C7G0kMghLqQob+t31bvsWEMlKoe1EvwYPpnZsfxBGRkWY/y1WoH8hEA/raA/CZvIZ QkCtuTJRe9eVt/TCjbK/vqEulRN+pJ1RJW5MCWMad6GahANVK8GazblstCfWDaiR4ciq 88Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mGfWBKCh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c16si860022pgv.741.2018.02.21.23.09.17; Wed, 21 Feb 2018 23:09:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=mGfWBKCh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752722AbeBVHGf (ORCPT + 99 others); Thu, 22 Feb 2018 02:06:35 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33353 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbeBVHGb (ORCPT ); Thu, 22 Feb 2018 02:06:31 -0500 Received: by mail-wm0-f66.google.com with SMTP id s206so1051499wme.0 for ; Wed, 21 Feb 2018 23:06:31 -0800 (PST) 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=dkKQoWZV8KtCEWix0PkNOj9P1zGovDujjV3MZq8B38E=; b=mGfWBKChDdU0dSjPETikYCJAz3Adbbtv54eJgI+TKQc9KURIPM8Wfqs9HGnsvZmDpu q7HzvtHwdOi1kfH2yzw/QNxsVeGN/ptid4HR4njJ0W8eJzXzs+m7y7O1Q2PJoRyEdbxv zbVMEiUQK4WI5DSqKJtzls1oYRhUek11YMmViOfIDp0qc42+fORmr555auX9Rl3Nmzgi e1FrMN13xvMguB2/OHdCC4jhpQVPseUv1bOJPOH+pQs8DDKgio/i6+XUMqoEO/KVfk7j YgbjWf3AiiDuTXbaY2xjvXkWLFc9h8SUWeeUT6a9ZDN8IeTmXqnpnzxRZ/1aZX13ED/3 HsSw== 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=dkKQoWZV8KtCEWix0PkNOj9P1zGovDujjV3MZq8B38E=; b=P0+XE8LMt2lSX9ZoxnKOpXy9ePZaWCV113MtebCwFOfjoHX8AlKN0sSbxWbLP4/vy8 4epdz24IueMwL3/KhKH4ShYL4KAapwPCIAVCfO+WGopqS/pCdn2JQI9oPq8KUmxG15rw 2ZeTYQNjD9ivmeNgaOamVAMSOYKFiMS7OQPhCdDuEqLqZ+hi6iewwUlKUuxjKv0z8iUQ wql2Je2C6mgpbGhKxtLABk5Iky+1mDjlIrHZQfDV7be4ra5lX10Acmi7+//8WZLuBVXQ Sh07tcZehZ4GXWv07FtYHqACUDHGwIVzJsr1DedtYoP0YNTgoYdYTPO8w0wkBhY9xdeO rBqg== X-Gm-Message-State: APf1xPCr/pdOIpa/EKVzRLX5IFH7IV3UARvohqcOjxIFUpZ0qYSQDTvr nVvbDYcoZXDGfi5pHbPrT0Y= X-Received: by 10.80.220.3 with SMTP id q3mr8097121edk.176.1519283190825; Wed, 21 Feb 2018 23:06:30 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id p14sm25300616edj.46.2018.02.21.23.06.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2018 23:06:30 -0800 (PST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id ABFD4208C2; Thu, 22 Feb 2018 02:06:28 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute7.internal (MEProxy); Thu, 22 Feb 2018 02:06:28 -0500 X-ME-Sender: Received: from localhost (unknown [45.32.128.109]) by mail.messagingengine.com (Postfix) with ESMTPA id 337967E13E; Thu, 22 Feb 2018 02:06:28 -0500 (EST) From: Boqun Feng To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Andrea Parri , Boqun Feng Subject: [RFC tip/locking/lockdep v5 10/17] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior Date: Thu, 22 Feb 2018 15:08:57 +0800 Message-Id: <20180222070904.548-11-boqun.feng@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180222070904.548-1-boqun.feng@gmail.com> References: <20180222070904.548-1-boqun.feng@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- lib/locking-selftest.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index b5c1293ce147..700f9aa19db6 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -395,6 +395,49 @@ static void rwsem_ABBA1(void) MU(Y1); // should fail } +/* + * 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) @@ -2055,6 +2098,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"); /* -- 2.16.1