Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2026513pxa; Fri, 7 Aug 2020 00:48:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSQZH/O9OfprmGKSYnkKkPf0M5G4NTsz4wf9Kn/4udx/b9qLqPMTgCZGNR8EN5Ply+46Mm X-Received: by 2002:a17:906:e46:: with SMTP id q6mr8122613eji.234.1596786507897; Fri, 07 Aug 2020 00:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596786507; cv=none; d=google.com; s=arc-20160816; b=EQ7vRhKGdIB7tq++QyCBKe/duI1hEfva36QUYlWdFPUXkvyypt0bqTTENGnngx1Vex LSCVJ9hFbTnBbLYNy85VAC6X1VXcgYf+YTBcyXgwNyw0oCKDqDLqG0CJUaSUsQ5+Lkhq gAgmqF+X+WzeRp/Lz20FdB93H0ArTcR1q5CsCOKb9udUESgIzs6yxMUJFeS3Amo6rQSp 3Kb3BFRkiichAFF6DIfJcAii2xrje9uv+IfM64f3+alvrpbASO1ewaitw4BZlyp4sCGQ fSbqQcSRfpj6hhzj+dKI2ikE9Rc87L88PmSv6cupVAgUHhQP6Hig6D+2VMEFqgT731Zx ebXw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=FG0FROUYaTe04KGNWr02FTBUT0DIequTKC7GJACiEKg=; b=LvBtHdFT5eRYz5hj/let8zDnhLFQEbac12qtcaeZ30rTw5R5tm7v2L0Tu+Pucx+06Z K2cYoF+oc8B6ZlyXD+xTjsNpsjDu0RM6vKzr3QEF42mhvbbW4Mp8A/MbJSP5FWrhq04W BXuIoS/iW4Xz4pL5clVPWasHhOn+Yb+YC1ZDY3lyxpw/5YzmH27Ki/7BGT7qwLdh9QYB 4oHfmvK87BmGIQAsGB41n8TLv7cMvDi90yXvJoVzLCh3Iwwdnjpy1DqyqCFIzG3rS5nk TS9n/xIfFEe0NqZzHjU8TRj4SvoHrcVZ9CXArcKMURQvC03Ownc9djDFSdUNm0YdqF09 Htfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H43nUh+7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si5164463ejd.431.2020.08.07.00.48.05; Fri, 07 Aug 2020 00:48:27 -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=pass header.i=@gmail.com header.s=20161025 header.b=H43nUh+7; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbgHGHp2 (ORCPT + 99 others); Fri, 7 Aug 2020 03:45:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGHp1 (ORCPT ); Fri, 7 Aug 2020 03:45:27 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05F31C061574; Fri, 7 Aug 2020 00:45:27 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id 6so682721qtt.0; Fri, 07 Aug 2020 00:45:26 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=FG0FROUYaTe04KGNWr02FTBUT0DIequTKC7GJACiEKg=; b=H43nUh+7aOSwklc6p2JAHdd34OneCTSPLY/7L9Y8wGHoAcIDBGOjYhJ8XKuwkxJvGa MUTl8ms7pkc1TFpk/oGgQG+LYD4ZVozHbRL74dyB5H13LmF7sM6M5CdQ8CqNnTQWxFuX PEiA5Jm2Qst4VFKoFjsHfm1hMG59wnz7GkXSDbhwAF08LJIIzo8rfBU177rX+RGgvH9k +jE1C25PG/7pHCZTEQeIheWKvq7wDWoCgmg+dpBRrA7J4yVjMxtHD+A6Fqy0/iVMvw+y k9It4L88/Lt7QtqAXjnbfjpD7Hu33+BdfZRm3iG3xeNy5mpIQA5v4IEoJcA7nyFmSRo8 cO+g== 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:mime-version:content-transfer-encoding; bh=FG0FROUYaTe04KGNWr02FTBUT0DIequTKC7GJACiEKg=; b=Yls5kfFJ3Xor7GSxwCSZxu+X3lNwFsmGa85kRyrXeS7p3lBHTbKpEOK7oZL6xYBB0w hYeJGTkqxUU2genklKpjyBT07e1+4HMC+wAWktm8QCYHJUrMwk3dZ5hyDzTw/tggA0MY 1YTTK80X1SL+i8Ku/3v95hiAjT2fp0lMv8X0JhL4y4F2ZxnBvqcAN8nkDGqQXJ5Qq/i4 UgILtuJe88W0EExfU9qi8TbbQAj7cusf5JM/rdqatjri9nI/QsIvb36lvPUwYVxF/nAD w6f7ZIZIVFWHm3+tCfQpBJLH474uIsE5fVRgTR+xn0bEalq0FlOI7Z77fdHM30rVXIhV Xkxw== X-Gm-Message-State: AOAM532J7Tj5CUgcJRPEZ9omjkGtSwe0cx0X9Dn/lUUsZUBUf1Huh62z z865mzMHc/R2l70O+36Qd9o= X-Received: by 2002:ac8:130a:: with SMTP id e10mr13423866qtj.38.1596786326319; Fri, 07 Aug 2020 00:45:26 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id r48sm7497073qtr.17.2020.08.07.00.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2020 00:45:25 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 6F81727C0054; Fri, 7 Aug 2020 03:45:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 07 Aug 2020 03:45:25 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrkedugdduvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppeduudegrdekhedrudektddrvdduheenucevlhhushhtvghrufhiiigvpe efnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnpe epfhhigihmvgdrnhgrmhgvsehfihigmhgvrdhnrghmvg X-ME-Proxy: Received: from localhost (unknown [114.85.180.215]) by mail.messagingengine.com (Postfix) with ESMTPA id 57BCD30600A3; Fri, 7 Aug 2020 03:45:23 -0400 (EDT) From: Boqun Feng To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Jonathan Corbet , Waiman Long , Boqun Feng Subject: [RFC v7 13/19] lockdep/selftest: Add a R-L/L-W test case specific to chain cache behavior Date: Fri, 7 Aug 2020 15:42:32 +0800 Message-Id: <20200807074238.1632519-14-boqun.feng@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200807074238.1632519-1-boqun.feng@gmail.com> References: <20200807074238.1632519-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 caadc4dd3368..002d1ec09852 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -396,6 +396,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) @@ -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"); /* -- 2.28.0