Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4932769yba; Mon, 13 May 2019 02:16:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQx/sLUZPU3fUHLGqLZpcMixgDOhBUy5yCyEIyyCXrn32sIgTnS6Oq1uelotaE7e+ZAflx X-Received: by 2002:a65:62c4:: with SMTP id m4mr29576339pgv.308.1557739016863; Mon, 13 May 2019 02:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557739016; cv=none; d=google.com; s=arc-20160816; b=0hEQg+Z45QMrxJ++XFb+2ZBSb45tAzgSy7W8eG74P6hwBKxWmIQoeETK/b+HPKj4xQ JueBp1Ucu1eOsf/UMD4irTcV9ZMxtKeE/sjUcMyU76jpSCv9Wz3g2VHBL20CgaUo4L3H bzB4vgMugUqyHX3ZHqRhC0c7HWUnhFQOH76KnZ6taxDCxw9WioTbqgwdcVvXNzDUfWOP y1r0Kr2vHf4s/YkUKO7z/XLJbyIVJNoZdvbZ8ZLy0sr2mCu9oe27omvEkW0KDrXLQ/XF wP0HWEb7Aek7m7gooraMLB5ZQTAGoN9q1tu5vGZcnw8F0qBCiooCHxHEab58gDOgmRCR r0kQ== 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=Rp13RuRgS/joBmmO7IdXoXGX87CdLveBL2noqB/wsSo=; b=PrN1kiwE05a9R+l8IAeFqJr42JgMWGSvCjDM60HLxeuGdVDbdd/lmA13oglvC8W5Ts 39V6k2a3R+YbtNW/GMblvlzUBAzpxPEWQ5a/qa5V59vOqdr774i1WFahT+pi2o8iF4Xo 6HlGqmxQkBOeWa21aQ4EgjS7r4Ux2++Nk0WjKPGsgYh6errkphuiPt6NFmwmRaaELmtv 2eSxXvowpLL+zNCZBDK4mR1VpXzLvCXhAmTQ+tS4L6DGISsHGxeXcrGq4swh1KVJwoHZ QNUTc1Yvdsvja1UJHc/2spqn9gq8mJDA5vHKKrBHAMON/NBYdhCWFfYoeLG1oHKd/Imi 0Xlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NvczDE4S; 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 k193si15223506pge.306.2019.05.13.02.16.41; Mon, 13 May 2019 02:16:56 -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=NvczDE4S; 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 S1728702AbfEMJNp (ORCPT + 99 others); Mon, 13 May 2019 05:13:45 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34158 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728669AbfEMJNo (ORCPT ); Mon, 13 May 2019 05:13:44 -0400 Received: by mail-pf1-f194.google.com with SMTP id n19so6873542pfa.1 for ; Mon, 13 May 2019 02:13:44 -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=Rp13RuRgS/joBmmO7IdXoXGX87CdLveBL2noqB/wsSo=; b=NvczDE4SkBK+La/gZ7IllQcuv5TpwSqpSVbXqQ4fwZdPA0tFiFv0uPmUjmYMwz/7pl DtiB1cGDc/Zsxs/PyN09UJAXJxJuTQ0eSa+BEhE5jy/VV9g4yjmb0h7upNfrgKHZocbG u22muNm4OtY7Xb3jr4cgOLLfn3AeTiJ+D4uYbIiRfKeaKJulPKTjovNc8k2/41KRy4zY 04IQjTzjgQPfow0nNyXtJR5adkfsF1rWqNE7doODwO4tMH/gO9ss8tk2OUPul0gjZwSn sNijZpdbPD2YShwE1OvfRTMZ4wTAJnw0/+TUN4AwfRdYNx7ZdoLHWbTCY67Ml/LJk+ir WP8A== 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=Rp13RuRgS/joBmmO7IdXoXGX87CdLveBL2noqB/wsSo=; b=thWNaB6XUkA+mdRZCNPmRCTaQ3bRp4EhwXzMn5dNBFamIecA5J+J+gcvNtG9Ii+0jT anXtjGw4D640bD91JGTW57C5PGsE5pQfdOeLNSGSBN9Ph88OxrpJTvlTMGiVQoHaNoiW l2k5dNn3+Xj51unMRpRg47An4kkpcXRni0D+QTF2DXNhPMKp16U6FtQuIZlMdAr/abVY gHDo2LOFVx1eyNKtbDpzxQLLrMWL82M+sQdhoMzeUnSoKd+pLErkG+5kAasALcqCJsPM oWWolXSXD1WAciYkPtMIT3O/vgJQRx9ix0eUMRcjqxm8jCun0KD0YcdckkNvRTGhc9di OfXg== X-Gm-Message-State: APjAAAUIE2DFXtcWXZuI1/dGuZ7rE2yVd88bCmjP4UbYx33LlcsH80rc s/Bc7TOS7G9U/D5M+bFAqiNdBWOTwh1IEg== X-Received: by 2002:a63:6fce:: with SMTP id k197mr30142708pgc.140.1557738823854; Mon, 13 May 2019 02:13:43 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id n18sm35500837pfi.48.2019.05.13.02.13.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 May 2019 02:13:43 -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, boqun.feng@gmail.com, linux-kernel@vger.kernel.org, Yuyang Du Subject: [PATCH 08/17] locking/lockdep: Introduce chain_hlocks_type for held lock's read-write type Date: Mon, 13 May 2019 17:11:54 +0800 Message-Id: <20190513091203.7299-9-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190513091203.7299-1-duyuyang@gmail.com> References: <20190513091203.7299-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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index a2d5148..0456f75 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -861,6 +861,7 @@ static bool class_lock_list_valid(struct lock_class *c, struct list_head *h) #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) @@ -2668,6 +2669,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) { @@ -2872,9 +2874,12 @@ static inline int 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()) @@ -4824,6 +4829,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 @@ -5268,6 +5276,7 @@ void __init lockdep_init(void) + sizeof(lock_chains) + sizeof(lock_chains_in_use) + sizeof(chain_hlocks) + + sizeof(chain_hlocks_type) #endif ) / 1024 ); -- 1.8.3.1