From patchwork Wed May 24 10:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 98443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2762910vqo; Wed, 24 May 2023 04:13:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70wpnyQ5XIM7nMbBCmY7dMp2w/9W/ERgMGstu5VG/+Y7yz33wf55x3g1P3qUBaA6Iz7GU8 X-Received: by 2002:a17:90b:818:b0:253:8e59:a867 with SMTP id bk24-20020a17090b081800b002538e59a867mr13971202pjb.42.1684926817555; Wed, 24 May 2023 04:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684926817; cv=none; d=google.com; s=arc-20160816; b=0+dYywVn0aCu/0dOJ9PNrPEo4ALyUKCmL4FzMGdbF2CQIw18fPt+tiYIZ3Zm8EWzQv WubMBnnh9FQBPcX0bjw1zd24RUIvBK+7k7RHVgcOYnCD3IAVDOxpgsLZUoxdDF4Q5bbA ZrHw9Z6kCWIxSRzjxcqK/H9t+XAvCokrwqE3SsYi23eDhODn/nM2fblU4A5nCwcpBMrX pGTXcCPfapL8jkAxXbpMypbkALf4Rbdt0t7IDrgfstpClULAdqcpCT5NCTOMTQkPvbiP k79RQfDsJhZGxuFVl2bOQ40bCYqxyu2ZPT4rHgbIp+1U8URAGQg7630tmsAd2U/LHE/m 9Ogg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=NHInt8PsCTTZea00osUteaIh5I/RtrIGNZBHdsJKGws=; b=uxklA/OTbA0qoTRcJShab9F7VViIoq698qM6a+IE6apzsG238xV5ZK4cvbWltVRicR 28hGCEzWo09RAQFYXKXIH8kP6N4vsrxeGY9mVhgZrQbil+w8m278Ntsl84UBusiZP3d2 EVIWZDHb2tw7eWmznFFRd4ciuieiPB3qPZzqOnGkicC155qO2ajy9KkZH4dR4f4EBsxX 61X69YhuB2Zg7y6YDddP0JISh69K9GZQN41qw1qh4E0+vt3OIK5V/hJ/DuG1VZ8sS5bK B/nzP1LPMEH4g9jCRoUaBjahLJiwQUEB/oKfiq8qDrS7GN5Ota9FMxGlIn6Pyj9JW+Wd N3sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ITmiUsLq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=5iwnW01F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi7-20020a17090b4b4700b002532f02f026si1180773pjb.57.2023.05.24.04.13.24; Wed, 24 May 2023 04:13:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ITmiUsLq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=5iwnW01F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229485AbjEXKcF (ORCPT + 99 others); Wed, 24 May 2023 06:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231588AbjEXKbu (ORCPT ); Wed, 24 May 2023 06:31:50 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18F7C1B9; Wed, 24 May 2023 03:31:47 -0700 (PDT) Date: Wed, 24 May 2023 10:31:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684924305; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NHInt8PsCTTZea00osUteaIh5I/RtrIGNZBHdsJKGws=; b=ITmiUsLq8Jfo+zPaO/OrzXXnqDY9ShFIVpVm0kiyFGXO482cwL8noGTBU6e31S5j+zl/N9 Po4L2wraBHC4Xwh0X5GSQ1dQwl6lvv3GQVEYtudnbUE6bdw921qXC3o8nJH+mkNQ/7a5oT yiKFl4mHM03dCMCsdkHtZKglY+S+xgs5aPbMmfmdMMIKllFd2PWB5+0cyer37J2i+dkD5r bwyboLFyHdJukWRQgUV5r840Pi+bsfXTx904QZ+db6Mbl08D++U322VSCziohJGMeNIJvb y6g5fh8z7j1xlswC0CVQZabknZnFNN9J8Tjm9pC1YtePPEJmdsreAJEm+94lXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684924305; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NHInt8PsCTTZea00osUteaIh5I/RtrIGNZBHdsJKGws=; b=5iwnW01FWYxmUmADJXci4GEaxxaMZPVchAhkayW5nS/WgjHmFnwWIWtAYeeaEA2uvJVkpY VRsfMJxXmETcXsCw== From: "tip-bot2 for Kent Overstreet" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] bcache: Convert to lock_cmp_fn Cc: Kent Overstreet , "Peter Zijlstra (Intel)" , Coly Li , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230509195847.1745548-2-kent.overstreet@linux.dev> References: <20230509195847.1745548-2-kent.overstreet@linux.dev> MIME-Version: 1.0 Message-ID: <168492430501.404.11013548302420797278.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765448804446450378?= X-GMAIL-MSGID: =?utf-8?q?1766773822603587573?= The following commit has been merged into the locking/core branch of tip: Commit-ID: 4c8a49244c6abc5fb829d81abaaf2435ad2a44bf Gitweb: https://git.kernel.org/tip/4c8a49244c6abc5fb829d81abaaf2435ad2a44bf Author: Kent Overstreet AuthorDate: Tue, 09 May 2023 15:58:47 -04:00 Committer: Peter Zijlstra CommitterDate: Wed, 24 May 2023 12:21:22 +02:00 bcache: Convert to lock_cmp_fn Replace one of bcache's lockdep_set_novalidate_class() usage with the newly introduced custom lock nesting annotation. [peterz: changelog] Signed-off-by: Kent Overstreet Signed-off-by: Peter Zijlstra (Intel) Acked-by: Coly Li Link: https://lkml.kernel.org/r/20230509195847.1745548-2-kent.overstreet@linux.dev --- drivers/md/bcache/btree.c | 23 ++++++++++++++++++++++- drivers/md/bcache/btree.h | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 147c493..569f489 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -559,6 +559,27 @@ static void mca_data_alloc(struct btree *b, struct bkey *k, gfp_t gfp) } } +#define cmp_int(l, r) ((l > r) - (l < r)) + +#ifdef CONFIG_PROVE_LOCKING +static int btree_lock_cmp_fn(const struct lockdep_map *_a, + const struct lockdep_map *_b) +{ + const struct btree *a = container_of(_a, struct btree, lock.dep_map); + const struct btree *b = container_of(_b, struct btree, lock.dep_map); + + return -cmp_int(a->level, b->level) ?: bkey_cmp(&a->key, &b->key); +} + +static void btree_lock_print_fn(const struct lockdep_map *map) +{ + const struct btree *b = container_of(map, struct btree, lock.dep_map); + + printk(KERN_CONT " l=%u %llu:%llu", b->level, + KEY_INODE(&b->key), KEY_OFFSET(&b->key)); +} +#endif + static struct btree *mca_bucket_alloc(struct cache_set *c, struct bkey *k, gfp_t gfp) { @@ -572,7 +593,7 @@ static struct btree *mca_bucket_alloc(struct cache_set *c, return NULL; init_rwsem(&b->lock); - lockdep_set_novalidate_class(&b->lock); + lock_set_cmp_fn(&b->lock, btree_lock_cmp_fn, btree_lock_print_fn); mutex_init(&b->write_lock); lockdep_set_novalidate_class(&b->write_lock); INIT_LIST_HEAD(&b->list); diff --git a/drivers/md/bcache/btree.h b/drivers/md/bcache/btree.h index 1b5fdbc..17b1d20 100644 --- a/drivers/md/bcache/btree.h +++ b/drivers/md/bcache/btree.h @@ -247,8 +247,8 @@ static inline void bch_btree_op_init(struct btree_op *op, int write_lock_level) static inline void rw_lock(bool w, struct btree *b, int level) { - w ? down_write_nested(&b->lock, level + 1) - : down_read_nested(&b->lock, level + 1); + w ? down_write(&b->lock) + : down_read(&b->lock); if (w) b->seq++; }