Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp318462yba; Thu, 16 May 2019 01:03:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgyPknRs5UpW119nVtz9kxNXy1idUpoH/nllknT5b+H+Zz73CEFgpU76l3WtU3slMhhCZD X-Received: by 2002:a17:902:868e:: with SMTP id g14mr49835369plo.183.1557993788791; Thu, 16 May 2019 01:03:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557993788; cv=none; d=google.com; s=arc-20160816; b=Fvdh5SCJ3JiBXMzKjTrEoBpPcE/CwYGvvL01bc44V5BKfpND5fKg45hJQjuPcTUmK4 J0tT9q0/mjMq4Yhdh3L/SgwuUL/Xt3cMwFKWoUuPBLlCSvnWe+LUf8VjdG22Vr8WvlDX AojYbkid1U87VBTgwEuRFUn5YphwziPElzynfkHak9mF974RaQNVnzJ4QQxEABMz5knO zNURmf6mK1H7tRsmOC4XiUzQXvOBh3W+2cxu8uSUUAy+K3XPRmpPwI9HTfiMvnKNKhxw JPFmfUmCBeJvvPQx0SlAdKsm5ltecplaMn8DhGHyTo94Ev1JWrPUFu3Wy1PY0kHT5wTe EeuQ== 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=ZHzlqjHUpBcWDeEJ3Xlm22kRNhQiFjrERpI1mkPi/eY=; b=lHHZTvOh/eF9DUzOf49TLKqnBPOb3CzSy3kItWceuViN5iO7caeGBqLwiDzDO0qckK auQO+J4TzbsPrrvh5DlmfUdU263Lh462ZnsOTapLt5+zl6cXktJOJvg8FXXVuBzC7P1W f8lndu4pLIRlnnx/0ffrYESxhRVJORti71Cg3MKKunoD5wm930FNCwhLWT+0WD7+W2Jj B3vAqtrZZbcWHXUQuZBf9VRJMOB7fLCp4zQt4j+D3V/jprCHnK809WZ65o4pFROJNzbJ ZXsnYE+YTqnVbEI2yJNWWYok6ixd115eJe5q8jJ7CmPpFQ8RcBcrIpkm3zjkYaGYH0JI 6VVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DTzLk80z; 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 l1si4268796pgi.344.2019.05.16.01.02.53; Thu, 16 May 2019 01:03:08 -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=DTzLk80z; 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 S1727058AbfEPIBM (ORCPT + 99 others); Thu, 16 May 2019 04:01:12 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36741 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726537AbfEPIBK (ORCPT ); Thu, 16 May 2019 04:01:10 -0400 Received: by mail-pf1-f196.google.com with SMTP id v80so1426508pfa.3 for ; Thu, 16 May 2019 01:01:10 -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=ZHzlqjHUpBcWDeEJ3Xlm22kRNhQiFjrERpI1mkPi/eY=; b=DTzLk80zG35jL5eAJ1GNkQ7fn32H16sfzG9eUkiK+cxTZoCPpWNWILcN6nkgVWEjvK EeHYsoxsZzOg4SkIlIsFvhYQkyZolLm2hjdv4ugj4cEr2kgzDYcZaEuSXxHwHFi45yIu kv0d0sb/FYRCeD9Pw8bmqzsUn6uBB4L2Iny5VeJoYESAkEQLj6KzDEpy8zDyeqaH/zH4 /qTPgXKR/PtFGnQ0o/jeaGJpk/EK20IWcSaXiOYZdOE5REPUjfmTf868KFxO+FOMoR6c B9IxpJ/HcKZekMkm1maxWV8hc82fPgIXb5yLzjBgtUNqZcZyvmmWbu5VbpnOEzwoSxgp JtvQ== 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=ZHzlqjHUpBcWDeEJ3Xlm22kRNhQiFjrERpI1mkPi/eY=; b=nJ7olaTjUuoVdeH0pPGv2K3z97n9XEyoEcR0ReR3XHcJdtPCwpXkpJ9HYoWbvHNsMB guem1+/2JHpsEheS0fbqWu5FGwNczAXh4A/zwppbjjpo0JHfUa76xJ7ewnvWwgnabuXa RVDTCHFDsjXLE5AqloKe7sS8qKIVySCm73aWcAo2uZZgFgRUEv++3O/FH9O35s6LF+rN 6EHBIZpFAvddP7FTWDu84QhQqUs9GrJpxTy0gDN3QaOxoq3UOpNhrxEFkforjL9lqyPM NMldYnH+ir/Fq0deN3KBMJqfm/Chj5jZyD8PUoQ7U+vIwQU7OH4vRJw4x1lcyhI8QjxI bZ+Q== X-Gm-Message-State: APjAAAWnKpfzdbhblp1cunu8p5VaHw2KQiHJtE6RdtvRiB2jbKdwiTjC Kubx69mlYCvZSZ3lyEXYTBo= X-Received: by 2002:a63:4a66:: with SMTP id j38mr29842320pgl.199.1557993669949; Thu, 16 May 2019 01:01:09 -0700 (PDT) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id p7sm2051471pgb.92.2019.05.16.01.01.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 May 2019 01:01:09 -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, paulmck@linux.ibm.com, linux-kernel@vger.kernel.org, Yuyang Du Subject: [PATCH v2 13/17] locking/lockdep: Add nest lock type Date: Thu, 16 May 2019 16:00:11 +0800 Message-Id: <20190516080015.16033-14-duyuyang@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) In-Reply-To: <20190516080015.16033-1-duyuyang@gmail.com> References: <20190516080015.16033-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 | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index ce79b5a..d8e484d 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -2527,6 +2527,7 @@ static inline void inc_chains(void) * 0: on deadlock detected; * 1: on OK; * 3: LOCK_TYPE_RECURSIVE on recursive read + * 4: LOCK_TYPE_NEST on nest lock */ static int check_deadlock_current(struct task_struct *curr, struct held_lock *next) @@ -2556,7 +2557,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; @@ -3131,11 +3132,13 @@ static int validate_chain(struct task_struct *curr, if (!ret) return 0; + /* * Add dependency only if this lock is not the head * of the chain, and if it's not a secondary read-lock: */ - if (!chain_head && ret != LOCK_TYPE_RECURSIVE) { + if (!chain_head && ret != LOCK_TYPE_RECURSIVE && + ret != LOCK_TYPE_NEST) { if (!check_prevs_add(curr, hlock)) return 0; } diff --git a/kernel/locking/lockdep_internals.h b/kernel/locking/lockdep_internals.h index c287bcb..759e740 100644 --- a/kernel/locking/lockdep_internals.h +++ b/kernel/locking/lockdep_internals.h @@ -28,6 +28,7 @@ enum lock_usage_bit { #define LOCK_TYPE_BITS 16 #define LOCK_TYPE_MASK 0xFFFF +#define LOCK_TYPE_NEST (LOCK_TYPE_RECURSIVE + 1) /* * Usage-state bitmasks: -- 1.8.3.1