Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp3070131ybd; Fri, 28 Jun 2019 02:18:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbW8W02VNKXWcwJacE/KocYCW4UPXxzBVSgK2nRh5YMqt++zc94ATiqQPPnFhF7p0AncJP X-Received: by 2002:a63:8f09:: with SMTP id n9mr8131869pgd.249.1561713489127; Fri, 28 Jun 2019 02:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561713489; cv=none; d=google.com; s=arc-20160816; b=W4DNR2eyJmcNbpQskAFFp3wNXhG0YBy1TTM0AJE2jLwVJshCS/7eYwJDSxlMLv9X1z R1nP7c3/9CC9JuPlqhc3CPWxRjjPD31kX3F5Bwr7nAHycHG3/x5Rq9JA+uT3poWW/xHh jpX8qdYO/VLSmEFoJjs45dO9dbitzgAJzKZxwzA0oWkDqKsVPzyFlh7Pm8L1flcjXUrW qi0ROSlMVOaCsdQeX7cTAcUHRBPnYF6RxxWbsQ9LfbG3OTX9i/MIrrIxT45ePUZnEiH/ aBvcbww45P7r985Ev8PkQ3PcK1e4WzgO5g4gD7eVLD50RCQssVIWGFpzEtWo4u6YIph8 apBg== 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=183urw1MfrVHvspMp9oXDhwdMiQ5A5kZ+cnVzHTVPhU=; b=VaOxooD5AnxDkZYwq9+5pNo/CNLSpZwm35xIGxrIXA/WEy221YGjBqbFR6BKJei2I4 KPstx6WVWlgeXc4VOugHuGby9/jtKNSV+oMY1G9er7KUKiHKmCp4qI1SQ2afGKlxza2N o4vFh9nafUgdEd1XY8ZAMPUyL8y6glurLlC6QxL+SMT8pCjnau0nLocFIwGH1KWgQWza 51Hme5NKAUhJ3lrE5NIxFoi+u7eLxj5IT+tngtc02PczxrnzZYHzV7RZ0CMN3W7cBPPz 26rSuYdVJaIeH015DI6vROVL6mX2tPpuu9x+Sgy35p78ok+8olSZZ7MArhUeJCBBkjAu qpdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o3Kr9ncc; 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 a13si1566427plm.333.2019.06.28.02.17.53; Fri, 28 Jun 2019 02:18:09 -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=o3Kr9ncc; 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 S1727066AbfF1JRP (ORCPT + 99 others); Fri, 28 Jun 2019 05:17:15 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35532 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbfF1JRN (ORCPT ); Fri, 28 Jun 2019 05:17:13 -0400 Received: by mail-pl1-f194.google.com with SMTP id w24so2913943plp.2 for ; Fri, 28 Jun 2019 02:17:13 -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=183urw1MfrVHvspMp9oXDhwdMiQ5A5kZ+cnVzHTVPhU=; b=o3Kr9ncccY7J4ETX8NNJW0KwyJzwGgnfzcaarfqguC5OUu9pPwwF+wc07ht4obPYvo H4c+lXmK8VjEjdHuGQXe0lV7c6ooxrQyxqAt+x4AMailQz+co425ppy0HjUocjzrXtKs 9QiXNaqRM6XqSoC/gul2RsTZvntZqsyIb+mDCkvIX8kdKPQ+niphDhcJIvS/SmJy1/qS 0dw4CAKGurdfRUI+KnUkzJPq0UoZ4s4uPqcoWT4cFuPSoB//8O4Q5Dk57Gc9V6fZ0g89 8iq0C7QswIAyCYsxvo1m005W85CwSlIWnoSNeNoEOHVdOPem/wiVEdY2m8pk9OIws3Vu Kk6g== 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=183urw1MfrVHvspMp9oXDhwdMiQ5A5kZ+cnVzHTVPhU=; b=lttwhPOcB/7nfYG7dIIGmQhO2XmaLrn+ta9dYcfbu4lIuS/9otQMT4xJ+qeaEESRo4 six/TiHvbmyQq5bGwUfIJBrkZIlbgL4vMlIW+c2J9Ilqml1EzFXrOh9TnOjRH0vJZA0m fNc7yPYthr/nFK9MxdWLwxve29g/z99JyKuEhx8cJLpaNhJVitLot4KBr1h+pSLpCxg2 f08JH3xNfYdYIDdGLrUg0uqM60EqCYEI7xLWcbc+gJA+k7lT+TYmIxMqpoEfglqVFzNL 1MNqanWh13XjLL5DV4Q42/Ng5oLCbhyeK4JUs/8MJyktScDzi18OLN4jA7OV4eyuEXpL NFYQ== X-Gm-Message-State: APjAAAWleTpjD/QPGv2pE0Ai6/l2orCAyr0++ZdLbbobNoHRbvG/NUV3 ZzXCgIo86UGXTmjr63tAW6g= X-Received: by 2002:a17:902:b70f:: with SMTP id d15mr9833000pls.318.1561713433195; Fri, 28 Jun 2019 02:17:13 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id x65sm1754521pfd.139.2019.06.28.02.17.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Jun 2019 02:17:12 -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 20/30] locking/lockdep: Introduce chain_hlocks_type for held lock's read-write type Date: Fri, 28 Jun 2019 17:15:18 +0800 Message-Id: <20190628091528.17059-21-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 chain needs to include information about the read-write lock type. To that end, introduce: chain_hlocks_type[MAX_LOCKDEP_CHAIN_HLOCKS] in addition to: chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS] Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 2329add..27eeacc 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -882,6 +882,7 @@ 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]; #endif static bool check_lock_chain_key(struct lock_chain *chain) @@ -2592,6 +2593,7 @@ static inline void inc_chains(void) static DECLARE_BITMAP(lock_chains_in_use, MAX_LOCKDEP_CHAINS); int nr_chain_hlocks; static u16 chain_hlocks[MAX_LOCKDEP_CHAIN_HLOCKS]; +static u16 chain_hlocks_type[MAX_LOCKDEP_CHAIN_HLOCKS]; struct lock_class *lock_chain_get_class(struct lock_chain *chain, int i) { @@ -2795,9 +2797,13 @@ static inline struct lock_chain *add_chain_cache(struct task_struct *curr, chain->base = nr_chain_hlocks; for (j = 0; j < chain->depth - 1; j++, i++) { int lock_id = curr->held_locks[i].class_idx; + int lock_type = curr->held_locks[i].read; + chain_hlocks[chain->base + j] = lock_id; + chain_hlocks_type[chain->base + j] = lock_type; } chain_hlocks[chain->base + j] = class - lock_classes; + chain_hlocks_type[chain->base + j] = hlock->read; nr_chain_hlocks += chain->depth; } else { if (!debug_locks_off_graph_unlock()) @@ -4811,6 +4817,9 @@ static void remove_class_from_lock_chain(struct pending_free *pf, memmove(&chain_hlocks[i], &chain_hlocks[i + 1], (chain->base + chain->depth - i) * sizeof(chain_hlocks[0])); + memmove(&chain_hlocks_type[i], &chain_hlocks_type[i + 1], + (chain->base + chain->depth - i) * + sizeof(chain_hlocks_type[0])); } /* * Each lock class occurs at most once in a lock chain so once @@ -5278,6 +5287,7 @@ void __init lockdep_init(void) + sizeof(lock_chains_in_use) + sizeof(lock_chains_in_dep) + sizeof(chain_hlocks) + + sizeof(chain_hlocks_type) #endif ) / 1024 ); -- 1.8.3.1