Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2026060pxa; Fri, 7 Aug 2020 00:47:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJ7oysoFnJM8O3jFBSftFqGocr/H3PYSkV9L7Pfkw/XYRvI7AZSzcMMfS87+jcRqB+/EjI X-Received: by 2002:aa7:db50:: with SMTP id n16mr6583833edt.292.1596786450377; Fri, 07 Aug 2020 00:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596786450; cv=none; d=google.com; s=arc-20160816; b=Vm35ETCt9GInCYQoH/45d6a/E95HMQ/+etSP/I+OcaVjRC2ud+KF8/jMz8PHKbFDiU C1TnhPRW3qSFBIyjFX4y2VX38f7eqWiUAkeP/tv13hHewPO6/oSd8hqG0BdMu/jqYtIB 0Vo3A16nUwznZyPVoWXiTBfzEyi+kujZmwHNtxEr8KHEDSXCYJ+L/phdG0yp7P9gRvEx I61+RF33+zc0PdiEvSvfv4bJCZhwD1Uf/sDXXImBKzX6RCJy4/zQYvMimDqlt6phWvSb oVraxbwfPNNNCw1iyCQQMwObEuTVhc7QeughJzjvlA7zLHGAXbRbMgYfMDCK9PLvaZNx bVZw== 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=LUzE2cz+TtgYpExlFvy2HYdrMWDloN8RdEEz9paBHTE=; b=QSpXzzE6NJSTeZnnHDW+bOrCxBrCLgD12ZlFFHQRW35a8XaYp/KWDh8tYTqHxwtz4Z jd63mg4dSI8YhSvbf1efVOamPSQ0Ms5h98yPUdYvA7ygWftcUn4rSUa/YFyrLJehlWFD WyhEAjgmwh021PhJEHiSdPKdknVqYSBZuvytiDoVjqRWr00C/iHgRqSABPTlH3iUD9ok ETCxbSuZHBg+41KF9yz9roAvo3d99oX/0aBTVayfHbMZbGS9gJfBlnoDgdqu+O1ulgnk OYVzom6ns2slG2D3clL2VEgChotZF8EeAX7R9yq//mSJVVsGUwf35Ys0XpRNE8mmGvy/ 2C5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lz34vpHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id b23si4587276edy.72.2020.08.07.00.47.07; Fri, 07 Aug 2020 00:47:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lz34vpHm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726958AbgHGHnx (ORCPT + 99 others); Fri, 7 Aug 2020 03:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725805AbgHGHnx (ORCPT ); Fri, 7 Aug 2020 03:43:53 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B979AC061574; Fri, 7 Aug 2020 00:43:52 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id b2so346102qvp.9; Fri, 07 Aug 2020 00:43:52 -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=LUzE2cz+TtgYpExlFvy2HYdrMWDloN8RdEEz9paBHTE=; b=lz34vpHm4pjOKogJwm1pMOrXHHRPRP2HFLDCvVJFiNIDCeEibNHwS+DHvzz0JomN89 usSSKX4epe1BpMGN6dKhKgAsHGb1aSXWuHQGxYYZdU/2DI4PLXYl2iX7YRY9IAmTnyfn Win4kjWmcEMn73HrhwS2N+TQjjszL2pcUJa7xwW9wSA8cj2aRHgRT+mEdWpphbv4wyXs xJTfSTpvY2KlyiuH46FFpm7H4+bNM2jU0nOpMNMPq9z3Lg/SInmFLjeIAqpPySSV3gMi cjNRSEXv1fVj6qPg4ozBMj/2fQkSGARcRauqzaEz7RmcEy0ffQmvOE5VxNEs1nyjVYdQ K0Lw== 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=LUzE2cz+TtgYpExlFvy2HYdrMWDloN8RdEEz9paBHTE=; b=R1l8tdQO141ppAQ8eAHI1rPfdT4pELiYmwwWLXrXrrF3kc2n2DFLAzMf2Le+6QR1as oEeuJZgeUBJbmedjsULWGIrK2b9X/5aMhL3CEJETsn5lb5TfuvcT5SreKlEvqleVk6G6 D1JMUxXa7RTE30S0ml+efBaZ+xqJZCbS2RyE2IFdhNHDhVxz80nWknHiKd/Y+c4kxeai SdtmyFJvvDIlcBDcnj6A3Yy9bfUJUMfhQSpZ+lGaVPAokqjIFDA6BqTLs42sm6PQfZbM KTVgtrSvL44k3uOz4zCfZtFsIhKodtDEUJ64OjizPuuMcL1W2YnnaK/bNa16qXUXiNkv wCOg== X-Gm-Message-State: AOAM530Faqd33B/N0nttzPnXkAWofwbFsNzC5rSvcvd+K67ow5BqLapg tNEhKKDT0hTCIrhsu6IxJ+k8xLbN X-Received: by 2002:ad4:4ea7:: with SMTP id ed7mr13694279qvb.8.1596786232076; Fri, 07 Aug 2020 00:43:52 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id y26sm6664052qto.75.2020.08.07.00.43.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Aug 2020 00:43:51 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id 3F5AE27C0054; Fri, 7 Aug 2020 03:43:51 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 07 Aug 2020 03:43:51 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrkedugdduvdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecukfhppeduudegrdekhedrudektddrvdduheenucevlhhushhtvghrufhiiigvpe efnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsohhquhhnodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdeiledvgeehtdeigedqudejjeekheehhedvqdgsohhquhhnpe epfhhigihmvgdrnhgrmhgvsehfihigmhgvrdhnrghmvg X-ME-Proxy: Received: from localhost (unknown [114.85.180.215]) by mail.messagingengine.com (Postfix) with ESMTPA id 3E6B230600A9; Fri, 7 Aug 2020 03:43:49 -0400 (EDT) From: Boqun Feng To: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Jonathan Corbet , Waiman Long , Boqun Feng Subject: [RFC v7 05/19] lockdep: Reduce the size of lock_list::distance Date: Fri, 7 Aug 2020 15:42:24 +0800 Message-Id: <20200807074238.1632519-6-boqun.feng@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200807074238.1632519-1-boqun.feng@gmail.com> References: <20200807074238.1632519-1-boqun.feng@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_list::distance is always not greater than MAX_LOCK_DEPTH (which is 48 right now), so a u16 will fit. This patch reduces the size of lock_list::distance to save space, so that we can introduce other fields to help detect recursive read lock deadlocks without increasing the size of lock_list structure. Suggested-by: Peter Zijlstra Signed-off-by: Boqun Feng --- include/linux/lockdep.h | 2 +- kernel/locking/lockdep.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h index 6b7cb390f19f..b85973515f84 100644 --- a/include/linux/lockdep.h +++ b/include/linux/lockdep.h @@ -212,7 +212,7 @@ struct lock_list { struct lock_class *class; struct lock_class *links_to; const struct lock_trace *trace; - int distance; + u16 distance; /* * The parent field is used to implement breadth-first search, and the diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 2d9798b71f74..699e9039a9b3 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -1320,7 +1320,7 @@ static struct lock_list *alloc_list_entry(void) */ static int add_lock_to_list(struct lock_class *this, struct lock_class *links_to, struct list_head *head, - unsigned long ip, int distance, + unsigned long ip, u16 distance, const struct lock_trace *trace) { struct lock_list *entry; @@ -2489,7 +2489,7 @@ check_deadlock(struct task_struct *curr, struct held_lock *next) */ static int check_prev_add(struct task_struct *curr, struct held_lock *prev, - struct held_lock *next, int distance, + struct held_lock *next, u16 distance, struct lock_trace **const trace) { struct lock_list *entry; @@ -2622,7 +2622,7 @@ check_prevs_add(struct task_struct *curr, struct held_lock *next) goto out_bug; for (;;) { - int distance = curr->lockdep_depth - depth + 1; + u16 distance = curr->lockdep_depth - depth + 1; hlock = curr->held_locks + depth - 1; /* -- 2.28.0