Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3070940ybd; Fri, 28 Jun 2019 02:18:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqy8RFA17+PGkxYhOiphhd3xQ7F5bgLW4iumsvVvZppbhkM0pN83v8lX+jtJ31cd0GzAaWJw X-Received: by 2002:a17:90a:5884:: with SMTP id j4mr12384303pji.142.1561713537581; Fri, 28 Jun 2019 02:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561713537; cv=none; d=google.com; s=arc-20160816; b=pH3W2KmTDk2pVp7Tuq2cPHgo07nlqrLy1bwXRM1SDR732x24qhpkGwfcujsfZmtvXX W5pG6IM8gYVfFqXdEgVGwulKqvctj+2iJn/CoJoIyt6Az6ikPVUiU/PjfbyFJLA43ORt ggaENgdlv/qo1adoIO499kQKvXN7kd2ePMgZG90t4QSVixIIygO/b4X+S8QqGFdG+9eY JHDKJS5W+uM+gRzboyHVswffhDfvTWlPTCGD03l5omym2oldBtK3oLtsJ67PgdwpsCdY 46NOAT81tlAB+dTCxXeXPd8140mkMlY1XUN0Zy0aWIQDQM6FlBIcEK9bdHSA1T7wlfhO NlFw== 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=Tl73hYl5gKy5NVWCsPlgxExT56GrT/ZBXkBZb3kkx+8=; b=XxWR8RLolhXy/TfpQ4pgvqPTLW0ZmhvhwEq5Ir0bdQx9ANb9uSKE53Mnuh+hTeChsW odK09EKYWa5FqT+8lfefiSu7GQ3MYoJqWHH7FlZ2DxlAgEvwVKY1wX5/TLmmTcwBParn cbcXvkqlaFE5fcNvSlo/3R8P4+rkv+wDZgHzoqrZhwxdj0XqtxzP7nWgACknHXp/5QQQ oNfiDTktnYCxyByfW6OKqT1RflQJmrLM0nBWEXM1eHme0GZvgi68jD0PqGPW4yDKHtzv KBCqWrWjBkq9/IU6QEIHf8JafowfnVzbqT3BFk2IUbpB9luBv9zt4+DOLzu7D/nVFjUb SOHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="eq/smi/E"; 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 k29si1596072pgl.157.2019.06.28.02.18.41; Fri, 28 Jun 2019 02:18:57 -0700 (PDT) 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="eq/smi/E"; 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 S1727133AbfF1JRk (ORCPT + 99 others); Fri, 28 Jun 2019 05:17:40 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35584 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726781AbfF1JRj (ORCPT ); Fri, 28 Jun 2019 05:17:39 -0400 Received: by mail-pl1-f195.google.com with SMTP id w24so2914602plp.2 for ; Fri, 28 Jun 2019 02:17:38 -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=Tl73hYl5gKy5NVWCsPlgxExT56GrT/ZBXkBZb3kkx+8=; b=eq/smi/E4EJ5mcJyPN8BL67wvWv1GW9zKa8SbsyBdaist7qPlUkGBRpm9Mt44vqX1c czo0GytdQQefimo9rdmROBaIK8tbBv3Lg6evlx0gcHp8t/kD7JO55WOcU2nswCyyeWjs Ah7Ik3z/C/6RLxfdH9ZPG5eoV6u2jneNtx+AmrJ37LL/TexAxY1I8dlw8HogoS/dqe/u sUSf9NEVLeeFY+QxjcTI/FJYtg0aLITDwR/Q9ZZlS6bQTds8oIKzZd0uXQFdGA7Ja1h7 Dxx3hGBHrtfmxsFq33mViMaRwlST83gQf13j3agr5UwClsnSXG1xcel5ha9MeI3gEXXn 1FVw== 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=Tl73hYl5gKy5NVWCsPlgxExT56GrT/ZBXkBZb3kkx+8=; b=NYHQUyVjNx/swbQPK8srmiJmNQwLPDUMuUuGRskslNqeGRkeKSVtA2G7h2mSaqc/gP /AqNRsV+X2BWnU0MPsZWgsidOfQDnGryH/REOWuXQP2zweP/iOQ74KRf8ztlevx6f5e8 KGoDpIM1lfNcpailr7WFmuRBZ5QzYPX9BTCv5hHBS2yGi25wQbE08xImUmwnu//gZV/B uh6wjH/xUj1fC0tR5LGMi9e6om7daZEhcMkXhHv6D6r6Zl2EV+TkReGI8SwKgLYX9k/E C8RtWph7FPk/Vyl4PK6eoxeZawDr2S4JwTr9BxpeY9+cMlhG/54+0xxCiVEsUqEOT2w9 Rzzw== X-Gm-Message-State: APjAAAXBXbxVyTFwcnTm0huycFbvplBOl8p2dGC1+grY059gFl9APgO4 bw3paqU9edUGpMFXHZDn4xQ= X-Received: by 2002:a17:902:d897:: with SMTP id b23mr9877110plz.250.1561713458613; Fri, 28 Jun 2019 02:17:38 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id x65sm1754521pfd.139.2019.06.28.02.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2019 02:17:38 -0700 (PDT) From: Yuyang Du To: peterz@infradead.org, will.deacon@arm.com, mingo@kernel.org Cc: bvanassche@acm.org, ming.lei@redhat.com, frederic@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, longman@redhat.com, paulmck@linux.vnet.ibm.com, boqun.feng@gmail.com, Yuyang Du Subject: [PATCH v3 26/30] locking/lockdep: Add lock exclusiveness table Date: Fri, 28 Jun 2019 17:15:24 +0800 Message-Id: <20190628091528.17059-27-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190628091528.17059-1-duyuyang@gmail.com> References: <20190628091528.17059-1-duyuyang@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 Lock exclusiveness table gathers the information about whether two lock acquisitions for the same lock instance can be granted concurrently. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index cb3a1d3..e11ffab 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -894,6 +894,36 @@ static bool class_lock_list_valid(struct lock_class *c, int forward) #ifdef CONFIG_PROVE_LOCKING static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; static u16 chain_hlocks_type[MAX_LOCKDEP_CHAIN_HLOCKS]; + +/* + * Lock exclusiveness table. + * + * With lock X.A and X.B (X.A is on top and X.B is on bottom): + * + * T1 TB T1 TB + * -- -- -- -- + * + * X.A or X.A + * X.B X.B + * + * in the table Yes means the two locks are exclusive and No otherwise. + * + * +---------------------+------------+-----------+---------------------+ + * | X.A vs. X.B | Write lock | Read lock | Recursive-read lock | + * +---------------------+------------+-----------+---------------------+ + * | Write lock | Yes | Yes | Yes | + * +---------------------+------------+-----------+---------------------+ + * | Read lock | Yes | Yes | No | + * +---------------------+------------+-----------+---------------------+ + * | Recursive-read lock | Yes | Yes | No | + * +---------------------+------------+-----------+---------------------+ + * + */ +static int lock_excl_table[3][3] = { + {1, 1, 1}, /* Write lock vs. X.B */ + {1, 1, 0}, /* Read lock vs. X.B */ + {1, 1, 0}, /* Recursive-read lock vs. X.B */ +}; #endif static bool check_lock_chain_key(struct lock_chain *chain) -- 1.8.3.1