Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1976041ybl; Thu, 29 Aug 2019 01:35:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqykmPvQ6YuQTRTkU5Df+w7FYwFHKRsx63eNt1QaWXR6gyM3J5wmxTTbiApy1mSZgOXRzrwI X-Received: by 2002:a62:1858:: with SMTP id 85mr10055898pfy.120.1567067706002; Thu, 29 Aug 2019 01:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567067705; cv=none; d=google.com; s=arc-20160816; b=JZKlfDbD+Dv+58khbGu57HE1STtIUNb7eJAeuBCYOvsCZtCQW0bo9o4lB9UzYffhen qv/clgPqNJPwAShHqRmK8Qt2iGCY93kiq+OQbLVXKpnFcBxx8flD7Fb0/7crQpOar3CW ZTqEftstYn/0RfTu8UVCdzqfJ6eucQeAR4Cg0SuiAZvEA/vnfnsSoHEvvUCAcKYcKozM bwD8zkc4xq1ftrBVMLM+YTf5OQ1z8sXEvylkdgJa8uoflzfIkpflHwfkJnwUvWczp8Ep s0KRaCduxxtZRsp2SkyPo0fWXSD6sEYVzuiV2hCzyWjnhuB+upYCYlAHMb1/HfFMr9iC LctQ== 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=5LJVFKQfKTSHL4xQ7udZmCSm37xuo5vIf7hCSAgl2TE=; b=LNtSRkfjUZkj6yyzzTOnjZRyonzm/xhMypbYflxqWuvGggOZBxeigpGAuDVButkcu2 Z3bM/HM6apKhvS6hFOfhRFMsCT71YTMieCisQeU2NyEGwyAfiO2dnY7E7vzVaRk/yllP LilBYXEIqO179+hfkjOzPEMxAAZOHfKBPF7j7r7JCaxNoGHBuC4cf8zHOgsF4ZZTiiP+ ZkiGgDb8Gi/hLfCweOh3Y3Ki2y6lItCIqjtZHJxc7wOPQ6a0+h2Hr88Gy0MIiW0lZ1Zs BpIozIVGjBlo4C/393XGMuGwEUtIYceS0ZjMatH5Z6SBKsZtVqLcog+EPgTebG9ykOw5 evrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Y1c/Ykbv"; 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 d11si1335500pla.243.2019.08.29.01.34.51; Thu, 29 Aug 2019 01:35:05 -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="Y1c/Ykbv"; 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 S1727072AbfH2Ida (ORCPT + 99 others); Thu, 29 Aug 2019 04:33:30 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43744 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728057AbfH2Id1 (ORCPT ); Thu, 29 Aug 2019 04:33:27 -0400 Received: by mail-pl1-f193.google.com with SMTP id 4so1232442pld.10 for ; Thu, 29 Aug 2019 01:33:27 -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=5LJVFKQfKTSHL4xQ7udZmCSm37xuo5vIf7hCSAgl2TE=; b=Y1c/YkbvEu8VxRKySUAjl0c3lltLPJzcabPKdRLw/Ss/jFZdxHg4k4hHceucFICQSq g7Nc5pMM8yxsnKbqAZDIqpOl0NlvZDBD0DnzN+B3KG0gwc/2T8yEtonUitDtfH4ZthEB s5dZ4KqEjvmaS9euEqqvWeR8eXEWO0M688zYnh/LMeGw9quvDXwB9fOG5QrRHw3d88pf RK6uPAHcnj9zGd36QScxfJkkrLWWf1/gn2CPNr+Igy6fsfaBH5PjJcaf7xtkWsdP8f/X h60dkTa2k+f86VoQRAmGGhcI1sjK052T2bqdoOdQ8ZwZ5O2hN2NuOsxkfL4nhU+OugGK GxAg== 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=5LJVFKQfKTSHL4xQ7udZmCSm37xuo5vIf7hCSAgl2TE=; b=pUcW1kjGOdFeg482q7LPwgY2V61qXJ4npzuKfIGLgHumKll0VR05DQEyBKC1fco3CK ejzqGnqxYjGIWf33sZmp1sb/YmYE6LpPdvZmQ/fduaK48LPbJmNxc2VG/JOPQjTh4NOM LO2Jw9e2LSSo8w5/FN9TWp4/f0Gr3/+nlsY+vyshxh2b2PcTHY1gItFPbEtnNRcVL2jQ 2MXpN1dLdqRQcRJxA5u62qktJh0+Wz4y6HE6cMSc19xcci7gJBfURIFRqJOcZ4ulXi9X ukUls9dgKoxI/E3rytUIyGF70W5BEBYfWXgH+p3BmWSUB9FKQQkPqr9sPZ1IzyPbPpoS fLYA== X-Gm-Message-State: APjAAAVIUYph/KwsXKICehpu5TQxfSgoOkSNKMVBS5St7T/ogHQF6SWe OfMhem/UTJRE9h2R2otTnIk= X-Received: by 2002:a17:902:b40c:: with SMTP id x12mr8594649plr.81.1567067606874; Thu, 29 Aug 2019 01:33:26 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id v22sm1260155pgk.69.2019.08.29.01.33.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Aug 2019 01:33:26 -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 v4 26/30] locking/lockdep: Add nest lock type Date: Thu, 29 Aug 2019 16:31:28 +0800 Message-Id: <20190829083132.22394-27-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190829083132.22394-1-duyuyang@gmail.com> References: <20190829083132.22394-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 Add a macro LOCK_TYPE_NEST for nest lock type and mark the nested lock in check_deadlock_current(). Unlike the other LOCK_TYPE_* enums, this lock type is used only in lockdep. No functional change. Signed-off-by: Yuyang Du --- kernel/locking/lockdep.c | 7 +++++-- kernel/locking/lockdep_internals.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 4cd844e..755b584 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2591,6 +2591,7 @@ static inline void inc_chains(void) * 0: on deadlock detected; * 1: on OK; * LOCK_TYPE_RECURSIVE: on recursive read + * LOCK_TYPE_NEST: on nest lock */ static int check_deadlock_current(struct task_struct *curr, struct held_lock *next) @@ -2620,7 +2621,7 @@ static inline void inc_chains(void) * nesting behaviour. */ if (nest) - return LOCK_TYPE_RECURSIVE; + return LOCK_TYPE_NEST; print_deadlock_bug(curr, prev, next); return 0; @@ -3126,12 +3127,14 @@ static int validate_chain(struct task_struct *curr, struct held_lock *next, if (!ret) return 0; + /* * Add dependency only if this lock is not the head of the * chain, and if it's not a second recursive-read lock. If * not, there is no need to check further. */ - if (!(chain->depth > 1 && ret != LOCK_TYPE_RECURSIVE)) + if (!(chain->depth > 1 && ret != LOCK_TYPE_RECURSIVE && + ret != LOCK_TYPE_NEST)) goto out_unlock; } diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index f499426..37f6b0d 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -26,6 +26,8 @@ enum lock_usage_bit { #define LOCK_USAGE_DIR_MASK 2 #define LOCK_USAGE_STATE_MASK (~(LOCK_USAGE_READ_MASK | LOCK_USAGE_DIR_MASK)) +#define LOCK_TYPE_NEST NR_LOCK_TYPE + /* * Usage-state bitmasks: */ -- 1.8.3.1