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; From patchwork Tue Apr 30 17:44:24 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: 13649810 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 79B32C4345F for ; Tue, 30 Apr 2024 17:44:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E580A6B00C0; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E075E6B00BF; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE2D86B00C2; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9C3B66B00BF for ; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 196C7A15B8 for ; Tue, 30 Apr 2024 17:44:48 +0000 (UTC) X-FDA: 82066923456.07.5D8EB84 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by imf04.hostedemail.com (Postfix) with ESMTP id CD8BC4000C for ; Tue, 30 Apr 2024 17:44:45 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cBjZiq7X; spf=pass (imf04.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.10 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1714499086; 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=Pih/+yY2ciakpRXfNfV/CIIuPIeOCltpAElFzV4y3Bg=; b=C/JoUuYL27kWjV9Nga/4GG3WK21FdMz+klCGLq5uwvBFHzQPV3s/G6rA4gb+P0gA0jTcKU CT12g9pUXmk5WfTXAK1M9lMg7XIJjmAkP9tss00wzPPK6C0JzRKo55cUh6vU9oQvOqFEx1 30FQ9qAS3qYPlq1DV7vMWaYmBafUGSo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cBjZiq7X; spf=pass (imf04.hostedemail.com: domain of vishal.l.verma@intel.com designates 198.175.65.10 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714499086; a=rsa-sha256; cv=none; b=4C61juTVE+Ab+GJYPGYy9Zma6fcVVOTz/TEY5DvrBHSrk5Khgyxz9pd0u9UET1mnhSH8J2 2KrlVipj1XKuYrDBM2/6D1YCzfD8kPkj/SFp2YGOo00pc/H5kUNQ0wS7c7YZT3uzQBiGkL aZy48a6OlvZOwdMayv6Ce089wdqrdAo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714499086; x=1746035086; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=T52oU7nq5CORc4zUmW3MiR7iyOzbCEAUapTKwbnnDtE=; b=cBjZiq7X78iCAlTCtP3+5zzwyuIsRExgrsYHV7YU/W8WE/FH0o6qDUMv CUjx0E4hWYwlTIXTgIEcbhkG/NNyovFZbZCCOgOZ6Z6CyVnBizQ5NHDAh z02G78XexL5oZE6/kq8b5pYuQszY5oVP7dl8VaNQdokcOd0pn1I6YXw7+ MYda8YRdcXknRzpjOtoFhg2sG3vA8ygWQO+C/A5eehhHH5v0llEZf7r27 Bl6ZFQdOyBoicRiylzRDU/9ucL0V6pmMg2GVYA0CWSyGxM9Ycv7MeYt4i W2KRQH+3m8/Rq5FbaLyVb2Hl+QL0+pOxzgAp6sYs4rmsOj70EpGg0zJ0r g==; X-CSE-ConnectionGUID: rGFS+za4TI2UDM0p9i8XKQ== X-CSE-MsgGUID: 9For+gHRTb656uSVVGYlog== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669836" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669836" 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: mAtDHbLVRkeXR30fmCFHxg== X-CSE-MsgGUID: liAd+UmlS8+j6gqf+bh/lw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="26534777" 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:24 -0600 Subject: [PATCH v3 2/4] dax/bus.c: fix locking for unregister_dax_dev / unregister_dax_mapping paths MIME-Version: 1.0 Message-Id: <20240430-vv-dax_abi_fixes-v3-2-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=3760; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=T52oU7nq5CORc4zUmW3MiR7iyOzbCEAUapTKwbnnDtE=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmGehxf90/d0nXems10qoBf6nS+bxeNLjG1dP1Rc0w4I ZLQVyrYUcrCIMbFICumyPJ3z0fGY3Lb83kCExxh5rAygQxh4OIUgIlozmFkOLHqhbMVN3/OfKaM yUJ3l3GLbshgnx3VKqeklKO6MZqFi+GfUd+7g/M8FsVor3m469bJ2YYu7+06zvy3FJl/6Ln69rP X+QE= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Queue-Id: CD8BC4000C X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bzfw6rmfbzj519haeeb1pwzrqq8hkdbo X-HE-Tag: 1714499085-422930 X-HE-Meta: U2FsdGVkX18IexJZYKWmTP5mYCYTIy2ViS2J/dpEkcIiuFRAmAUAdoMumZHQ+wSfmwEGfCueuo5QcWHRmRN0Zapp0pw8odhn8SwxxHcFMWiVHFFY3iScuGfdW2E/b1FelwkLMRmfEDTWQAVEZi95TfQuFaCfv/QIFyWTepbFQDLptKy3gKX4bgcjXTSfSV8XE4GXGxxQFWC0ZkiubZSaGc2RpH1LCkqtM+arph0qWRbSlZMXRzbJyNoCKmqvFiOKFuIsltekQ8jyO7vUHhtz1DMJsD6KZQRrQBqnE1Fa7aMUn2wPwWtHrUYdPYwa8F8tN+EQ3XQkvd8nn+nfa2rD8U9wyWFO/lGvHwydO1Ms7r6w+BdcxXxwygD/5DiKAyUbTJ4u9EtCMwzOYuV4/6QSaIXdiDYGYfnxYTlx58SzABn6RstCZN6lUwZ9u1CGGVKqsjcWI3icoelePSKBnTAignQXtQdPH/2Acd7ThoctS7ej9DrS7YbFijs7L8heFiIv/WJ/9h1KRvZh9oeu+pcCvXavjWjrtNNFXNqd4WOv/siFaxtsULwcqGXYGznlPrSzkSVmyfm+4QldcMV9zkNisSkhqr5B4d92B/3mwerBY5KdWwYoM9ofp9uQ98TDhZmMustkHVt+fVm+p1Prhe9ypQqdR3EIiXKTsLHrn+zOwgQSPiavsK6L8dl9XZzOCLPpZn55tJZWJ2+us7+Wgd7M8l4BuPAKFgQ6EvBaGz0DSsHalfHv1go4ixmVY3EXubj7ep6SnjmuVIxUZTtZH3X5/c5SgaD/rwIPd7mA/L6QWTYJaZgvEVhnsgKmIWGFeV6F1LCDfmb2S1brxU65gzGctGpyj3nJw3pQKR4Aj+fNtYrGe7BwZn/Ghp0F4YwwXEM7Bvb3/SQXug6Sjp6T4RyoFLewpD2THZWoeZYHt2RKYM8ZyccCdS8Yu+1M1GgjsoW6MFymqudao1tAy0Rahzw ngcfV4sz //5ylF4piXU0eYeHpf6xElievyJh316JtcdsxVAXcqgLRA5Q+kvcyjxvvze5c8ifJUMbBe3aCD7aLBe+hzc7khgEnczZzXBGsyLn3u5gV7cnIPs4BxPyx6BQtm+Rul9AcVk3lTOKadtZmz/6AOrsgPc5dRef2M3ORVJfn5JkiSFAmQb7mXPF2bToQ/URVethiXXQktr98iTzmHp6dlxWZ8ihRWWQR7ZpYYpULG/yp4iO8QSfbvfk9tk724Q== 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: Commit c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") aimed to undo device_lock() abuses for protecting changes to dax-driver internal data-structures like the dax_region resource tree to device-dax-instance range structures. However, the device_lock() was legitamately enforcing that devices to be deleted were not current actively attached to any driver nor assigned any capacity from the region. As a result of the device_lock restoration in delete_store(), the conditional locking in unregister_dev_dax() and unregister_dax_mapping() can be removed. Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Reported-by: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Vishal Verma --- drivers/dax/bus.c | 42 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 7924dd542a13..e2c7354ce328 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -465,26 +465,17 @@ static void free_dev_dax_ranges(struct dev_dax *dev_dax) trim_dev_dax_range(dev_dax); } -static void __unregister_dev_dax(void *dev) +static void unregister_dev_dax(void *dev) { struct dev_dax *dev_dax = to_dev_dax(dev); dev_dbg(dev, "%s\n", __func__); + down_write(&dax_region_rwsem); kill_dev_dax(dev_dax); device_del(dev); free_dev_dax_ranges(dev_dax); put_device(dev); -} - -static void unregister_dev_dax(void *dev) -{ - if (rwsem_is_locked(&dax_region_rwsem)) - return __unregister_dev_dax(dev); - - if (WARN_ON_ONCE(down_write_killable(&dax_region_rwsem) != 0)) - return; - __unregister_dev_dax(dev); up_write(&dax_region_rwsem); } @@ -560,15 +551,10 @@ static ssize_t delete_store(struct device *dev, struct device_attribute *attr, if (!victim) return -ENXIO; - rc = down_write_killable(&dax_region_rwsem); - if (rc) - return rc; - rc = down_write_killable(&dax_dev_rwsem); - if (rc) { - up_write(&dax_region_rwsem); - return rc; - } + device_lock(dev); + device_lock(victim); dev_dax = to_dev_dax(victim); + down_write(&dax_dev_rwsem); if (victim->driver || dev_dax_size(dev_dax)) rc = -EBUSY; else { @@ -589,11 +575,12 @@ static ssize_t delete_store(struct device *dev, struct device_attribute *attr, rc = -EBUSY; } up_write(&dax_dev_rwsem); + device_unlock(victim); /* won the race to invalidate the device, clean it up */ if (do_del) devm_release_action(dev, unregister_dev_dax, victim); - up_write(&dax_region_rwsem); + device_unlock(dev); put_device(victim); return rc; @@ -705,7 +692,7 @@ static void dax_mapping_release(struct device *dev) put_device(parent); } -static void __unregister_dax_mapping(void *data) +static void unregister_dax_mapping(void *data) { struct device *dev = data; struct dax_mapping *mapping = to_dax_mapping(dev); @@ -713,25 +700,12 @@ static void __unregister_dax_mapping(void *data) dev_dbg(dev, "%s\n", __func__); - lockdep_assert_held_write(&dax_region_rwsem); - dev_dax->ranges[mapping->range_id].mapping = NULL; mapping->range_id = -1; device_unregister(dev); } -static void unregister_dax_mapping(void *data) -{ - if (rwsem_is_locked(&dax_region_rwsem)) - return __unregister_dax_mapping(data); - - if (WARN_ON_ONCE(down_write_killable(&dax_region_rwsem) != 0)) - return; - __unregister_dax_mapping(data); - up_write(&dax_region_rwsem); -} - static struct dev_dax_range *get_dax_range(struct device *dev) { struct dax_mapping *mapping = to_dax_mapping(dev); From patchwork Tue Apr 30 17:44:25 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: 13649811 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 A7764C4345F for ; Tue, 30 Apr 2024 17:44:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 24FB26B00BF; Tue, 30 Apr 2024 13:44:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13E136B00C2; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6A186B00C3; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A272D6B00C0 for ; Tue, 30 Apr 2024 13:44:48 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 57C3F1A09BA for ; Tue, 30 Apr 2024 17:44:48 +0000 (UTC) X-FDA: 82066923456.06.882F555 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by imf09.hostedemail.com (Postfix) with ESMTP id 19430140005 for ; Tue, 30 Apr 2024 17:44:45 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=g9J420mu; 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=1714499086; 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=M0ZFjMlgL3Fqgat5FNQqzMdo4ab4pQjSmrLsOtI0Ba0=; b=EDiTs8EA8tPHLdLgpAKZsObsnCI8fqtozMMW7h2/E8dZmmZgYnBNkmIJz8siP57JHw2I92 1T3SqwjeQ5ZKK3IkYTo31IDVpPxSxXQ1PpqlC4kaf5weUNHTWcI7ltzpWjnCaI7DHqMLls 7FPdHVx7W1p33F54YHEPXjLxBXim9mg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714499086; a=rsa-sha256; cv=none; b=78COqnAMmeY5Ktlzb3jDfL//ZhbMVzKUt4+hEqJuW7lpzAqONSEYWbH6lz/5NP21wJcjOJ l4aClZN4lL2RNIDRTPE/uZ4yrD4JORAbvAjUtBcyho6yHsG6bVtpKLpuJLoya7PDOryvBR Xgxp/c5e1v/m1Hh/DxWcfJre0uVRZ88= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=g9J420mu; 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=1714499086; x=1746035086; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=NhTlptPmEedEHUiT46vqy1jTU5giIPfdgp2TteFj/UU=; b=g9J420mu+FtihXXQBbIpA+S0T9Gm8aHjVjcTpqP4x8gV4QkOphQQTSvY c5u51j5vhQHrlhK1SVz9R2lTwHFEtva6NEThd2OzeAyvUqQomJQPiJzmW 0Ne8BH+OBxDnIticxorb+tIVSQClFWVZSeIG5OsA+HmirxTMgR2wli5sm 3pRifsbRB+68jTgVzODDEWToEifIhCyNVkhQ/p6vpHPKo6uqXrihoRDK6 z2IFyT86QjjZSWzbPTv4AsyuPfE+z++BPgtXQ7cbT6ORRicNO2VjCVJKH ewjgcovgzRb/SiDhiSlX5bRfeJ6fAWJAhWspp9KcCQ/xN8a1ukjUeUmyN w==; X-CSE-ConnectionGUID: LqXgPYqeR8mj94Hau+rIpA== X-CSE-MsgGUID: F6ydAs5aSY2MoQdzjwQNCg== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669840" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669840" 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:42 -0700 X-CSE-ConnectionGUID: MTZbRtiIT46p1EZt8gC0Xw== X-CSE-MsgGUID: PtnL8bTtQJuz5mXOFvW8pQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="26534780" 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:42 -0700 From: Vishal Verma Date: Tue, 30 Apr 2024 11:44:25 -0600 Subject: [PATCH v3 3/4] dax/bus.c: Don't use down_write_killable for non-user processes MIME-Version: 1.0 Message-Id: <20240430-vv-dax_abi_fixes-v3-3-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=1045; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=NhTlptPmEedEHUiT46vqy1jTU5giIPfdgp2TteFj/UU=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmGehxcG/a8TGZ7GGendtTw8nyFaR2CS4KDrHMureQTe 8XOJx7RUcrCIMbFICumyPJ3z0fGY3Lb83kCExxh5rAygQxh4OIUgIl4tTEy/F+18KzNXK/pAbHM YZzhbhWfskIF/QLXnjxRPZ95RabIdob/yWsvbDY4MY9zwd3/egXFfE36dhuc1cQ9lx8WVVhUH3i FGwA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 19430140005 X-Stat-Signature: taeywsxkyqgqzc4qgzbe57rjdye9dnqq X-Rspam-User: X-HE-Tag: 1714499085-413214 X-HE-Meta: U2FsdGVkX193VtL1HruihO9Z6WKsehUN1IaNhvuF2gV/p0fPwNezZo3kPQVpYTt2vUB6GgjNftj2gjcbhRmFUxtHbRrPQF+tXswQEebzXAPTyMxy0FCEGyuscpnUuXF8nTYiroHKvPoHTnnNlLndMBh56fljqHdY/8JPG/JkXOXffYzqQJ+wuwGSVoQIi7IS3ImWxnFNO2C+oVa3kS3AEPjEmKDq8gRZDKLCBnbyYZSrTF21gY/miTktip5j3RGyikA8VDBv0FKBxyUxrMK4OYiryVwnYD7tPd1nvD18ZianVSz9FBL5vPYSe7pLxxdUD6RBOoTUF0UCZy8kKJLbl4D2l8b4maQV2n/XwY9E2CnbgkqbIylw8FBCdM2rh9hvT0KrW1gfKc/4Ujp9oxTcM7YvCjcph7QTUwgpwZuhshaAsVB5LMt3m+0OHcxqu5i6ey36/LTKUZizhQP/cB/F779FQzCVVQSjyOOD2WoF1iHsgOL0wEJ/i2rgvcttVd87DoVnpTZ5lBD0neYrgX6jfdDPbsd6RwTUbVvLpJkrqmF09ZDrP0au2PN99NiTuVh7CvLZS8fPp6glPGAbLPc6DkapBTyW50pekyXu9N3HBKdS7sOPNhZ3L+XdL/ezB1NAWld/LcJIgVINAqjXgxCqqegEfWHIM2hWOErFB8N8yhNhc39tfGG7Ch2/FP/rLzDvIZq8GY1pvBiEJT32aYwjH35dgLs6MMm2TZcRJ5/ottXEdg4VW65//lbY8synHvZ4YiHKa82SekJ0zGGF7FGPb7n12j6S5yyFFZHEPtDF1gJcZaHPb6GXR8/glCYDREumwBHa9r3mKGxazWY0MCnj0pJHI//69fWCrUBVgXzXumpLOWxCa5Xv2U/4QKWe5Hi20d/xZgudgqqfVf1nk33Zjc4TjRqMepzor9yXT6jFz9fQi+eswPf2wxo/1dGXKRihh/905cAKItzfGiFMSkc vdCrQd8o 8ARBxbVlkpdYWQ0jhzy7XabdJwr+0W3ljD5vzyQl/fNm1DYTLHmpKonfURr/4dxfxL7Zg8U50wk9K328GABsL27AXZZYXCYV//Eby6k5gy5mHwV/hBQinNQwzI6K62mzZFdynFwZr/k9D09THnoBrQbVc9WYakm5fDsOHmlLNOltyZMSmSYhnHSsP2RGS9ObnJka+uMrjLM0oxXJZ0s/NIK2aAKtaaf04FB37CbpdUYtCyJy6HkdHlDbNpQ== 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: Change an instance of down_write_killable() to a simple down_write() where there is no user process that might want to interrupt the operation. Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Reported-by: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Vishal Verma --- drivers/dax/bus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index e2c7354ce328..0011a6e6a8f2 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1540,12 +1540,8 @@ static struct dev_dax *__devm_create_dev_dax(struct dev_dax_data *data) struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) { struct dev_dax *dev_dax; - int rc; - - rc = down_write_killable(&dax_region_rwsem); - if (rc) - return ERR_PTR(rc); + down_write(&dax_region_rwsem); dev_dax = __devm_create_dev_dax(data); up_write(&dax_region_rwsem); From patchwork Tue Apr 30 17:44:26 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: 13649812 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 E5BC6C4345F for ; Tue, 30 Apr 2024 17:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 751816B00C1; Tue, 30 Apr 2024 13:44:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 701EF6B00C2; Tue, 30 Apr 2024 13:44:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2806B00C3; Tue, 30 Apr 2024 13:44:49 -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 334936B00C1 for ; Tue, 30 Apr 2024 13:44:49 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E111E1209A0 for ; Tue, 30 Apr 2024 17:44:48 +0000 (UTC) X-FDA: 82066923456.26.CA5E267 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by imf01.hostedemail.com (Postfix) with ESMTP id 9363B40011 for ; Tue, 30 Apr 2024 17:44:46 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WOYYwrIp; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.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=1714499086; 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=Y0ZOqA6la1t+7xiNXsenBQ+ezkmiJ5QEwJBTD6ZXZGQ=; b=PPVm1zfRyoc8YK2rUy0RNlGKql1ADj2EqymRMYMbNvL5Nn5JE+FFLF8joz/xUuL957sGEc SRXHojBAKLvWvRScFo7rNWOmrxx02Is/TcRnCEsBuk6LJCNHemqPqPz9P5giZylx9bSkgk 6bNMXxkRtWaF8sV5ZeV7/zguw1/lAno= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=WOYYwrIp; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf01.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1714499086; a=rsa-sha256; cv=none; b=meFeBxjUyeDStR97abNL41PY3e78VYc7b9lPtHA/jpWjpDgJEPCfXMmVsCaeco4vLCkZLa mzAgfOKjHjLgXoWpZ4NBw/1SbiYbZg9Bty2isHf+Ox/EQWjtBDyEdO/hfKKLj34lYnsZ5W fSVvWlCpbtx0ef06g2ppxb/XozUhRWI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714499086; x=1746035086; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=IuUcxmSQ8rmcL+XwprIf4jy7ccGbldFrluNcXl4Pl6A=; b=WOYYwrIpfLPRWs7bgLXxxUVj3CG0prUEQAY4H/OUi0iWV7ruJ6ui8G/+ GgHDyOyYAD1+6Vz30gSi1XTlZy0ELs6WEeQhUoh7pXQLfNCxOwwdBgh5l Aw9V6a4lG6X/cEoZmHt+5KC46JgFrDEr7vFvcL+M3cV/7d5UqIXQpBRTU FG6SGgpH7UI/U/Kx6OeheeRIPmYYQjVAU+WtDoo6M4sSkggwjyFiyxhjy 7Tot/iPYu+TvYFR8v0Pg0bQ2UZQqj/+3hxhwqn/HUtE7u4ggZcLtq4/xp qTLA9ji1lgu0FXnO3EQMwBZfwgAoeGCeI1gscK8dGw+60WhwplXpKgKCm A==; X-CSE-ConnectionGUID: 2WQZyp4FQFqsTb2vYwsQDQ== X-CSE-MsgGUID: R5x/1K3UT1yeHR5Yp/arzg== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669845" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669845" 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:42 -0700 X-CSE-ConnectionGUID: e1jOA7NYSFqVX4GdYq4k9g== X-CSE-MsgGUID: HKBzb4dvRh+9ecG232yJLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="26534783" 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:42 -0700 From: Vishal Verma Date: Tue, 30 Apr 2024 11:44:26 -0600 Subject: [PATCH v3 4/4] dax/bus.c: Use the right locking mode (read vs write) in size_show MIME-Version: 1.0 Message-Id: <20240430-vv-dax_abi_fixes-v3-4-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=1034; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=IuUcxmSQ8rmcL+XwprIf4jy7ccGbldFrluNcXl4Pl6A=; b=owGbwMvMwCXGf25diOft7jLG02pJDGmGehzPLNirDG5tiC/7LZaetnFTELtN95cHBgw7/ryc9 GKpxIVfHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZhI6GVGhmnLw5Inqtjdb654 fGP3vZdb37fY1maErJRK39AY7XEkwZDhN/vmEtsfceebpW6dcHSsXrDYbv+EV9fymARvlE+rM5b 9zAUA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Stat-Signature: gz7z796bi81qm6gibnin5uedaqt1umr8 X-Rspamd-Queue-Id: 9363B40011 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714499086-860388 X-HE-Meta: U2FsdGVkX18PAq87s5oJ0VQ7WqN+kNlT1zellXkcupjERFv8jAW7+eKEDPjOGfNfEfSwijj2grf5nNIy2N7oxIapfN4eHLf8h81UDAfmTVP/lJyIJ8vGrz5o/b0B+n3LrqtA3XIHSQ98ZFcMGBiuXiO24Rxyd3W9pEAsIG+1lqgu/YtnZb424mXKkdKz3n3ut9dxSq6b1tFdtojOji1jcvQENAdMT0oRKejTcrbStumRq3UW1fL43ydY2/CRbBSScvVfQd9M1ylQcOLvU89xw9iJTqemPfeyUMJf7qvgkcYBkOcHcHW5Y+RYZBxKR29Brra4sTaXshD4UZpCtzpZWChyCdG66qkLFjz3RSkAmjDscZXQtral6QDb1hQYSz9X3aj69aNBsoaz2uOJNxopnRtb4lpVlFnAB3aPQFG1vvYh9yoczZbQf4F62VYscGIiVoCd8cdA2VwQ27/RHxHFRizPE4Gz2XHlNI1+wcyDTDhTPCRD8DDXQ+AnLKrS3IgYwzvehKnGtHa0pgygPDuuSO9J0fnHV5AKG53jt2XXgT4LagTobBnzU+82UVimcsl4cAsPRil4XPievrQnNSwvq/vdZGZI+xfu8N/p8etKfPfwPuSZaLK2AhcrupiizN4dyhIAFEJKSy9sxgraiqUYMadIVIgbpOtlZ6oiYqNwDKd3bjApl+nn0D7h7w9GYbLbhIdH+RSyNTwkq1O0d8YuxYUcpBCvXtqATljAjhr5/G56vPcN/P5dB2tthmeVHoEne/3R7Jfibgfi9IotY+hCvGnQybIZ3TARwDF0vXQcqYwtRrRKc3fGEdN5W05yiN9QrX3lxXv7FsrVooUPYt32/DSZ7xY8Gx8+k0z0siW76AvHxvQBefamFyf4MoovggZN0yzYMXwM3lvoBSxleg+LeWI2fOxvzE0FO1zldrEXbDNILmkjYJhtGa/2ceyeeQeyAQ2jGrrFvB0hSNK5M51 vo6Z3Ogv HW/vKLIclY0OKHjoGiPGP6v62fihYE/r5efuxfCIB9g1xw8yQYmoUzEJNEBvQZ9eUPn7F8KtEUH2pORLeN/5CXqMogpb7BjBun/+VhZx3yOLm0O7xfv86Ts7rOm1bcc34oTtMggBAjQMMmi5O/xvBXoen1XD7MC8JwScIMibxKZw6m9OAl9pRMoNCJz4/1WNUEPzWJznGNZN/wW0lgf5XdY5zH4bl4zaR8To66C08dDVj+7jZQ79RR9XovDf/3LLJN0knGqj2ZWyfPn06XiH5lFZyBQ== 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 size_show(), the dax_dev_rwsem only needs a read lock, but was acquiring a write lock. Change it to down_read_interruptible() so it doesn't unnecessarily hold a write lock. Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Cc: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Vishal Verma --- drivers/dax/bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 0011a6e6a8f2..f24b67c64d5e 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -937,11 +937,11 @@ static ssize_t size_show(struct device *dev, unsigned long long size; int rc; - rc = down_write_killable(&dax_dev_rwsem); + rc = down_read_interruptible(&dax_dev_rwsem); if (rc) return rc; size = dev_dax_size(dev_dax); - up_write(&dax_dev_rwsem); + up_read(&dax_dev_rwsem); return sysfs_emit(buf, "%llu\n", size); }