From patchwork Tue Apr 30 17:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 13649809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00DA5C10F16 for ; Tue, 30 Apr 2024 17:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99B216B00BD; Tue, 30 Apr 2024 13:44:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94AB96B00BE; Tue, 30 Apr 2024 13:44:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EAD66B00BF; Tue, 30 Apr 2024 13:44:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 62BAD6B00BD for ; Tue, 30 Apr 2024 13:44:46 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 102EC140A98 for ; Tue, 30 Apr 2024 17:44:46 +0000 (UTC) X-FDA: 82066923372.21.D466EC3 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by imf09.hostedemail.com (Postfix) with ESMTP id AB78814002C for ; Tue, 30 Apr 2024 17:44:43 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SVKm7Uu6; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf09.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.10 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714499083; h=from:from:sender: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:dkim-signature; bh=z+ufZSUgDaSJzNfhrxP7wx2iTt5TMr/s3BFBQP+9cKY=; b=D4oS7zK7nhfcsW0c9frL6ncgSZ2WSTf8+2nArhrxaoQRzSU7Ozu5m7p6LaI0lYIuer1CHf KCawo2RXx80omFPk+dLDkw1HG8lQh4LgORVteSKYToTs9r6WIqnHi0RZqnjWNAn/nStxsI lbr3FaPr5Ywkr1wUwfqoxZ6t8VzwDCY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714499083; a=rsa-sha256; cv=none; b=rrGfIJhe2Z5lSsiBTznmVCDQgJWZVkbnAmEyJBIIt3OPLrTRzSJeUNR2FastUg2a9OO4ID 5EIT8sOKIX/V0O3NM7tHidY2awWOLOQx3L3z7JKmc3hJITKmSRywdnoH4RjtTDqGmHa/uV STUjOD/7dCHm3XIC+bxejXX6ZaQj43Q= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SVKm7Uu6; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf09.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.10 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714499084; x=1746035084; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=gio3jLLisOYiwSCHgts3s1OVVKVXVcSqgOny8/3ijS8=; b=SVKm7Uu6QevmK6SKQC6Kl/n/kE81Cb3VTVJwHFnXcCqk9ADQiKP9gpp3 zIoQ+qDn83O2pQxqMDH0PphgxLnimcxrA3Z7ASXWuf2ts+KAMUQD96Olw y3Af40GJOO44zitsOzvec1thTlKpWDhR4/MMiu/ucL2deh+78bldqazWX 0MUY9BMahYjqjTS44WjpMOBE1cjhfQAYRgSrldAHfb6z9RyHWG0mRRhoN h8mTvmvOwteSiLQpuKkq+fRdUysnCZ7+qRXeKWSVVQ9sBloC9lAyA2Lhr TJ9/7bhAYvBB9ZKRid23Jp9zmyvC3sw0NMJPKlSOVo+8BexgZ5dlg6xJG A==; X-CSE-ConnectionGUID: iTnnoKPeQ0ijr1c3aL12dw== X-CSE-MsgGUID: qRC8fBTQT2aVeFfHkbvrHg== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669832" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669832" Received: from fmviesa007.fm.intel.com ([10.60.135.147]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2024 10:44:41 -0700 X-CSE-ConnectionGUID: vUHJ8AZ/ROSdvFB65Gqnzg== X-CSE-MsgGUID: 3yH+c089QruBFvwvGrcGMA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="26534774" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.82.45]) by fmviesa007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Apr 2024 10:44:41 -0700 From: Vishal Verma Date: Tue, 30 Apr 2024 11:44:23 -0600 Subject: [PATCH v3 1/4] dax/bus.c: replace WARN_ON_ONCE() with lockdep asserts MIME-Version: 1.0 Message-Id: <20240430-vv-dax_abi_fixes-v3-1-e3dcd755774c@intel.com> References: <20240430-vv-dax_abi_fixes-v3-0-e3dcd755774c@intel.com> In-Reply-To: <20240430-vv-dax_abi_fixes-v3-0-e3dcd755774c@intel.com> To: Dan Williams , Dave Jiang , Alison Schofield , Andrew Morton Cc: linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, Vishal Verma X-Mailer: b4 0.14-dev-5ce50 X-Developer-Signature: v=1; a=openpgp-sha256; l=3512; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=gio3jLLisOYiwSCHgts3s1OVVKVXVcSqgOny8/3ijS8=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmGehy/X3i2bl5UXHXK9oJR6df6WDNr/ogFV+0jdzSKn Dv5W4ito5SFQYyLQVZMkeXvno+Mx+S25/MEJjjCzGFlAhnCwMUpABM5c5bhf27l+tfGXX8Yrwkp mor1nb0wtbx2WkdNe9UlkWtu66O2XWJkOGLO9bQoViY29766nXvdvIxXs6+KyS/8NDW1qfTjh2u aPAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: AB78814002C X-Stat-Signature: rp8jaatqyjcq5oruwzbhiujhgtnjsecd X-Rspam-User: X-HE-Tag: 1714499083-259599 X-HE-Meta: U2FsdGVkX1/op1cJ4vOwjzo2M++6bE9GW9TkHBN0TfMA8zxjqspLw8uHdYHxrdwtsqf8FNkckfvpEKjL1tw/i5rZ6GqKbm2eOiIAROGFsSiOJ9d88aC1LXij0NWQQvwchMkO0n/tZHzL5N4fiyokQLfxDsibV9r8yardOkVCwYcn1rBuiVt1nlRnmpBRg+GR5E789pV3JpTd8eJAkV4hosgyMYHECutHdQaaUtf2LSBniI2LKSPK47sWnITNsu+ctO2zmnyz9PTtLVfyms5hRFMMpO4NmLveTImAt8f62+kOLzjgde0B0ARN5aITT4YgRn8dIdfkpk/BqKvffo18kEKdP4kGjyolV8296g1VG/zX+eaE2dtvo0RzNDGbeKy4Daxzydb7KiqQXc0wEEgRTN9X5TB/xmevYfAPpy7ifQv8Nkc5bvD7AiKkoLJzApZKFT8jOXnMmdLMfXqQTOh+B9HC/dKrRQsNNsW5hn3UVqAGDhjha3QkJZA4Q2buLe0MsmLzqAfRE5tUMMJTginE3PPir8tqfigdmE08Sdzve1nTd/J8GvC4Epdezj28BgFxQ1V5JWeaJDX3ZFY6w2abn/nI5zpP+3pz3/zSCwTFJZA1NV3TYt7Vm5DrZMBgMtgM74WUg7NJm49aj0PBFQxhT3htmaE1ZXhnz0cQCqCj9JXaJU03kEnDxh536mZ7uHIbRVqMiBaaoBtC/+pGGlyR+X/yUw5bt1dhRsBNUtciglIUIZ3XoQtKs/zmQv2uhaPMCpNXgsjNZD082HSNybchxDOM2VEp/QmhOuA5c66D0zIrLal+DOeFAUHR1WELvIazVXakqZvjUGCg0P2rHiw0JnciNbBtras54/Xrcw6RF/6aeGi+BwDM9dOVWnH81wquhJ6zh8kfyrFSitdb2krnEVphyTiACRDD1PGYlbkS6HFUVDVbNSaBTFBUEXtbgVeq83IeE7z5ReTnU7iwxbJ R25bE1iI XGuknSXO6bUgjGQyABdLZXRWvSIWHocvmjai6pBZ+g2A0TFp1WCX41aWLorUS5iFCAuaeKz2Ie4vUH33MDn58Srd4TZJvRXQAuGlMcLLGpj6tm7u/xgJ0cdX2nhTBi1BBIxp/yqAtjGOl70Z1lPtvavuargR5w2cGwp/NjV7xkaI1/CIFuUSWB+IJNPfQ9q72UqR3W1O7KD7kgMvKYnfqV0SbnjnUTGJRZFQeg7DhKkI+pNtilTzvTYcQENHq8SLaelFsgT9meMbK90B6WjJcwWh/hbhOHCOKBPbleWGVgXzOp9LXmt5Dzyc0iHu1AwAJL1r7X8Cf1rY/QL4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In [1], Dan points out that all of the WARN_ON_ONCE() usage in the referenced patch should be replaced with lockdep_assert_held, or lockdep_held_assert_write(). Replace these as appropriate. Link: https://lore.kernel.org/r/65f0b5ef41817_aa222941a@dwillia2-mobl3.amr.corp.intel.com.notmuch [1] Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Cc: Andrew Morton Reported-by: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Vishal Verma --- drivers/dax/bus.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 797e1ebff299..7924dd542a13 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -192,7 +192,7 @@ static u64 dev_dax_size(struct dev_dax *dev_dax) u64 size = 0; int i; - WARN_ON_ONCE(!rwsem_is_locked(&dax_dev_rwsem)); + lockdep_assert_held(&dax_dev_rwsem); for (i = 0; i < dev_dax->nr_range; i++) size += range_len(&dev_dax->ranges[i].range); @@ -302,7 +302,7 @@ static unsigned long long dax_region_avail_size(struct dax_region *dax_region) resource_size_t size = resource_size(&dax_region->res); struct resource *res; - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held(&dax_region_rwsem); for_each_dax_region_resource(dax_region, res) size -= resource_size(res); @@ -447,7 +447,7 @@ static void trim_dev_dax_range(struct dev_dax *dev_dax) struct range *range = &dev_dax->ranges[i].range; struct dax_region *dax_region = dev_dax->region; - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held_write(&dax_region_rwsem); dev_dbg(&dev_dax->dev, "delete range[%d]: %#llx:%#llx\n", i, (unsigned long long)range->start, (unsigned long long)range->end); @@ -507,7 +507,7 @@ static int __free_dev_dax_id(struct dev_dax *dev_dax) struct dax_region *dax_region; int rc = dev_dax->id; - WARN_ON_ONCE(!rwsem_is_locked(&dax_dev_rwsem)); + lockdep_assert_held_write(&dax_dev_rwsem); if (!dev_dax->dyn_id || dev_dax->id < 0) return -1; @@ -713,7 +713,7 @@ static void __unregister_dax_mapping(void *data) dev_dbg(dev, "%s\n", __func__); - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held_write(&dax_region_rwsem); dev_dax->ranges[mapping->range_id].mapping = NULL; mapping->range_id = -1; @@ -830,7 +830,7 @@ static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id) struct device *dev; int rc; - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held_write(&dax_region_rwsem); if (dev_WARN_ONCE(&dev_dax->dev, !dax_region->dev->driver, "region disabled\n")) @@ -876,7 +876,7 @@ static int alloc_dev_dax_range(struct dev_dax *dev_dax, u64 start, struct resource *alloc; int i, rc; - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held_write(&dax_region_rwsem); /* handle the seed alloc special case */ if (!size) { @@ -935,7 +935,7 @@ static int adjust_dev_dax_range(struct dev_dax *dev_dax, struct resource *res, r struct device *dev = &dev_dax->dev; int rc; - WARN_ON_ONCE(!rwsem_is_locked(&dax_region_rwsem)); + lockdep_assert_held_write(&dax_region_rwsem); if (dev_WARN_ONCE(dev, !size, "deletion is handled by dev_dax_shrink\n")) return -EINVAL;