From patchwork Tue Apr 16 21:46:16 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: 13632638 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 AFC29C4345F for ; Tue, 16 Apr 2024 21:47:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D6256B008A; Tue, 16 Apr 2024 17:47:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 285876B008C; Tue, 16 Apr 2024 17:47:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B06F6B0092; Tue, 16 Apr 2024 17:47:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E16DB6B008A for ; Tue, 16 Apr 2024 17:47:02 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 79B40A0C77 for ; Tue, 16 Apr 2024 21:47:02 +0000 (UTC) X-FDA: 82016730684.16.D3789D8 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf05.hostedemail.com (Postfix) with ESMTP id 551AB100016 for ; Tue, 16 Apr 2024 21:47:00 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=S22jd9kt; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304020; 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=VSimFfYff7ui5chh1o5ciM2eZiFgN9QgqdTZkHo3m0A=; b=p8HcC2ToAOUbbsQg8TUMr6lNQpu2TlI55ELXVzPQtPcnNrjmQMOCAfZ6axXEl5jrxqkr+x pwBWlDCj39kCJqITWq6ZNzAJvYrFbxGoeeC9Bly8wZODnFM+vaLD6wA/KbShRvR8N762aO uLj3hBB9t4TrRoH7zu+VIrr35GWzYYY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=S22jd9kt; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713304020; a=rsa-sha256; cv=none; b=DVAdDmK+35UlcfSkmaxFePDMVYsKmbERDSSiVIBWsustYwo77zoIFNTKrPhnvzIQgeKD0S yngEWt3k2IiwW2jc60ec90dKPOklYT+MmuDBkuTupBe8b+PUBqOQDTUmgBiDggie44IAKl gBVdvSdPkT7wwAAB+r4DXlsYImOfIpc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713304021; x=1744840021; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=cKf+2RkB+2QLuB9jgK5gvYtPl3rZ0edQYbTd4CT+lq4=; b=S22jd9ktrmk2YkAZNWhDbVN9aW5Mu9YyqDcJelSBdHo8aEY8HlfHlx2y YDw1LIVd033vQirD+Qde9RT4JgAYTAEtIDwodd6pzDHOA/BJDzBH53+hd 8Nn9Qe02frUo8Ny4MBDlhzJgxbTrI00uIERTQrFfa0l7g3mTc8C8bJ+DL tSpmIyvnSUraxZu/iUnE/AbtGcp085PQ13JDxA1kNXXBBYHOSQmtPQazC JchaOFaozGmRXcukY48vL3W9i6Jorr3GUF/ATYesjRFmy8TTProCNsPFD Uqps0SOubH39gYbrZmvWrcFX99nDaLxV2ZT8NqZDuR9DEYoytSf/vyYyg g==; X-CSE-ConnectionGUID: G01OxKp9TemRaztNQiWKqQ== X-CSE-MsgGUID: s4NLwgR8RkCoXKPYTvtsvA== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="12553092" X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="12553092" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:41 -0700 X-CSE-ConnectionGUID: QApnvFuHQCmKzbH2uOJDEA== X-CSE-MsgGUID: APj7IGkwQLOA0O8WTSF2jQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="22464242" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.14.216]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:40 -0700 From: Vishal Verma Date: Tue, 16 Apr 2024 15:46:16 -0600 Subject: [PATCH v2 1/4] dax/bus.c: replace WARN_ON_ONCE() with lockdep asserts MIME-Version: 1.0 Message-Id: <20240416-vv-dax_abi_fixes-v2-1-d5f0c8ec162e@intel.com> References: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@intel.com> In-Reply-To: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@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=3458; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=cKf+2RkB+2QLuB9jgK5gvYtPl3rZ0edQYbTd4CT+lq4=; b=owGbwMvMwCXGf25diOft7jLG02pJDGlyH/fn3XilbZkpLv6fZRMXX6Bpf9DXFwYKu24abmFZl JL098fDjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEzEL4yRYd+e2R/T2593hk19 VRNk4DFHQ0379uY/Wx8qSGcasP/53Mfwz2hPuo7rq2o3+5iLHxe/WSbz1f39SplKrSDjxc9+mk+ /zwIA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 551AB100016 X-Rspam-User: X-Stat-Signature: oxpbunmm3zgu4ehbkp9gmk1xqk8q3xoy X-HE-Tag: 1713304020-621330 X-HE-Meta: U2FsdGVkX1+CFt7+ciANHTVlRkhPQ5UQURXoYk/9TOsprdibJE01gBnDzOjbcpaRkQ+wNheMgyfqEgXNXhR1LPlemkvyMQPrQ46ULbT2MrZXDWVT1ZsTrtXg8+mV26ZKvju6rGlnHi1ofmWoKyaGyMT4PU6yYIEj7c6GCzEdOcby/URCnywGOYVVDnSrSMcRlK1s5qPUjv2tKeM1sQX/iR74bqd52JouUM+G6ixnLs4y5fAFsaFeYawSRfC1136gfWSsDZ+b8vCMJ96JFqW355c0fjvkmkHjxFPxirLO2WYWR5Tlq0h/Sy7a+iKBHKs41fdVdp0XBaQERNrMWrUVX+hV55V+tsj9GBuIrvGDZMGqbCEHJkIUuKCJgk/xRnvEqNPDOdbXaChyWM9uXJtA7MxzjTIKLWaTJvOmnS421CCPQ8q1sdY/B0epgab/u1rFqCgxf0eNRydzd6c1nP7XoU8zFH6Wu8GEHcR7l7ew93KKDRnO63IPLRCAxRqGTJSed6Bnz2bE3m69EpwltYE4uSeq6WS6uEQSwa09NJIQBrH5GZR8+0IvkQuhhFnJUyFtochitYVarxHB9Imd3hVVs0tL+y0v4b74Zl12tqS7FGZ3UN2eUbYMSKsjmbYKnpkx2kmNWVHtUmJ9ys90Dm3otihYEsukMC1C1XGHDhqF7nlnRzaeu119VdwZ9R2JZbL27ANEokbsjmcQnLHAJ/3bvcVvlbeWyy/86P9ptS/bFi/egnKIF2x3L26jzXnuukC749Jah9CjVQYdLczB0EatsnKmen6jlHm7p7zW1uUGg7W/SKau0wGketeI/i3cXuSokCQKlDLCnjdCP5nUE75WJmPF9PgCcLsCsOFcBSbdlHjeSSAkzrQQZ5FadHnza5yVuh0bBtGJDlc= 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 Signed-off-by: Vishal Verma Reviewed-by: Dan Williams --- 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 16 21:46:17 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: 13632639 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 3EB14C04FFF for ; Tue, 16 Apr 2024 21:47:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D5396B008C; Tue, 16 Apr 2024 17:47:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 285AE6B0092; Tue, 16 Apr 2024 17:47:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08B6A6B0093; Tue, 16 Apr 2024 17:47:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DC8F76B008C for ; Tue, 16 Apr 2024 17:47:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9EE3AC0C24 for ; Tue, 16 Apr 2024 21:47:03 +0000 (UTC) X-FDA: 82016730726.13.EAEE243 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf26.hostedemail.com (Postfix) with ESMTP id 4DEAC14000F for ; Tue, 16 Apr 2024 21:47:01 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=aa178YiR; spf=pass (imf26.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304021; 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=5bIlhNbCWUZ5UEXKZpd71dt1V1B2UPIX0e90f4skPyo=; b=V/6awx0AIK2FqNwGWyuALGw5slKnKkklBEUfh/iVlVi04fgLoq3smD9ORmqCalWZU9MhLl wV7NwkaaO4Sck56Osm+0qpjgDKu0DGlg5ht3jrU+K02MhkeYETF3QVOaPhQ42uJEHIS6kX cVMNNiwBbQ4xbmUSuOIZl+XM3tx4QtA= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=aa178YiR; spf=pass (imf26.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304021; a=rsa-sha256; cv=none; b=GgasyRohKFno6tKIogVjc1GqghIetuocRk2fh/bQ1Vp+lOKrdsLbfx+6GfvxNTI9B1Mapg Z7MVV/TGITfMhSunu4RghZhm7FpsotnuUTYeDeTY/uDlFmcJ7Hbl9gn+iy10jc38UnA/tU Y2XsunVX9AU4ZlIQYxlb03n58AwUJ+s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713304022; x=1744840022; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=6NKueYWbYilwLzm6MjvNGh3MReMQfTip+ZRQnpWHoXo=; b=aa178YiRDshRL0O8B1bq9o6UuzJb+zZZ1XXFLnwMBK8MQyItNyEaSxaa wN5fNVe5f4KxmLQzX8tY2m8kEwVYcTW4RC0HpxsIBNRRxuHfb6e5rKHwK HwTMzyVGBndSq+m04eEYgh273OjWRgbFOUY8A6zN+7G4bO8SDaE9a3IDn DBnhSj+NRmaRv6lMV0YNEvDsOR7zDQcvAZMmWf46KKMJJO3wc6soXsF/H +Hv+M8zUR167oX1b3QO7+Weet5ncHuGk32h+pN7f6KfWlOiYhZdbdsGwU WWlliQovaBZ/oqe/A3axALTQdHqhKiS2lmvxdxOWx99zQicVpbhIL3hI8 g==; X-CSE-ConnectionGUID: iW+pt86NREaKJHu/EVYQXg== X-CSE-MsgGUID: xTZ+Kl5aT2KA05P3njKMxw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="12553097" X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="12553097" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:41 -0700 X-CSE-ConnectionGUID: LGzV/oikTnWcdEcJ9oelEA== X-CSE-MsgGUID: /IHr+JCsTxqXKXpgmhSDhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="22464247" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.14.216]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:41 -0700 From: Vishal Verma Date: Tue, 16 Apr 2024 15:46:17 -0600 Subject: [PATCH v2 2/4] dax/bus.c: fix locking for unregister_dax_dev / unregister_dax_mapping paths MIME-Version: 1.0 Message-Id: <20240416-vv-dax_abi_fixes-v2-2-d5f0c8ec162e@intel.com> References: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@intel.com> In-Reply-To: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@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=3520; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=6NKueYWbYilwLzm6MjvNGh3MReMQfTip+ZRQnpWHoXo=; b=owGbwMvMwCXGf25diOft7jLG02pJDGlyH/enyV98tmMC+0yHnLWTp0uWbraz8j0qZn/esdHYy npx0zWzjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEzEbCMjQ8PDvw4XrybZf125 7XfaN/P1v1b6h32zlnnH4MHleGTHmVkM/7TzZp0N61T7+uvK3aknHi353rLU68rbOyWTCucncRQ uvskJAA== X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Stat-Signature: ja9reui46y7kie3xcboesnakj6g31czf X-Rspamd-Queue-Id: 4DEAC14000F X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713304021-33579 X-HE-Meta: U2FsdGVkX19Iwplhm+VGEajj9g/uir13ukypUwzT2J3m1VHg1o5ZixfZZlE64qL8Wux3DsDAoi87Y/Wtf4hPDH4zcvMgsiwqAnfvhUmeLOtIGDDISwMynQxHRXIzYTWIf+CC667U5MfYuhnp8U/RGHCEHKa0TYqmmIlCAfmaBFoZ7BALorTEYjvLrAc1/8c6rzE1Uf5sokCeSOiDu/bL/I6s59jfKm8JGSlTTLLmszAGR2aFxjqieLBrFkiayOOll0OwS3TtO8OHXZ5YK9w/ue5ils5Se2lB/qjGCctiq7R5+W9OOL1QaLj2X1yZgkJXhHtGb/tWxZzcBz1ILuIU9514Jds2RkIN97b8CIgFqKOYnijXExBY4RK7vovJJ/mOBACAeNKM8GHJNZj37f0NXSiPb9qSKkOJBaR6tmCb2R4V2mHoYki2by9wC6vyl4qbncfMIq7yWIOtNfrPONyk2ov/w0difDOa+d0/ygk2iF8t1ZfLBngGP6zbnFXTxRr9qWYiwNKPz2E0X3dkHnwIIlgrpcOgurlXKaNZDcAfhz4GdSF/I8l8QGl8qr03tmfyoAKpgg5muO8tGOiNp/nofcSTLf78WG4jAfpTBAyxe15HF/hK0jbZJoprA2JxEaFSPWU05t/Bkdrek5IeNDTYkG1y820KlzjnM20DgdLbqH8yvF3scp0d0sC7KNjoeiyFeRvptoxkMOV0nxE3YSMyvWXWXIyjsAY48jjZteu6ssp/Jj0anqN2F0n75BO/3fLwFNF2EW1Iq24Lp2FYL38NvlsQPO5Sp6AYmhIvnDJ6OwhWlL/EYtqHg9zkQCLgKMOR1EImaEjaArfED188WkoV38GstIQGIMcp/cKhTaMA3bSLHyBaB+37VVfa01caRnzHqOkt0GlUBKV8JZziNE1Mge2G8kKUO++7ixjEn7jm6lwwiXXL4qqhcDAsobmuv7hrbr8EcwqRGecrFWL1ypa NFZ8AT5r Q8jngtuvXDc5M1XPv0ig3LoJypKfIRHzArPCeiuLdP4SP16YUwhpafvOr/0d1HdSUZFaYTzp1n6kaTKSZSTQVnocJSr04zwX+kaYn0vC3xeMUiwce0mzmjYMN8HQ7D2zjHasFEPJj3mUFe8nJ7esGxVOw/U1GkW4wC4MgnUgajOvoo0qVewLUbMmRr/cqBfbburdMgHPADFKqSzcigdHlSD+cZQ== 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") was a bit overzealous in eliminating device_lock() usage, and ended up removing a couple of lock acquisitions which were needed, and as a result, fix some of the conditional locking missteps that the above commit introduced in unregister_dax_dev() and unregister_dax_mapping(). Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Reported-by: Dan Williams Signed-off-by: Vishal Verma --- drivers/dax/bus.c | 44 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 7924dd542a13..4e04b228b080 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,12 @@ 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); + rc = down_write_killable(&dax_dev_rwsem); + if (rc) + return rc; if (victim->driver || dev_dax_size(dev_dax)) rc = -EBUSY; else { @@ -589,11 +577,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 +694,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 +702,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 16 21:46:18 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: 13632641 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 E94CDC04FFF for ; Tue, 16 Apr 2024 21:47:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F4556B0093; Tue, 16 Apr 2024 17:47:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A7056B0095; Tue, 16 Apr 2024 17:47:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 482106B0098; Tue, 16 Apr 2024 17:47:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 2539B6B0093 for ; Tue, 16 Apr 2024 17:47:06 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ED5FC1C11B2 for ; Tue, 16 Apr 2024 21:47:05 +0000 (UTC) X-FDA: 82016730810.02.FC483CE Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf26.hostedemail.com (Postfix) with ESMTP id AB49C140005 for ; Tue, 16 Apr 2024 21:47:03 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DkB6687o; spf=pass (imf26.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304023; 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=1Zf16kCX02g95RkQSXOcTNEoREnqvyXOonTJtx7G0/4=; b=buE9bEk1PYzGCiPxlB+XNfxZR9Tu6j4D25pzsiMKKAbzR8A+K9M3bVm+ndEph3Jg9GiS4r Pq6vk3csrLpujbafjcgIxq7l89i4LkEWoE/WnTqe/EG3jTGWnDaU451JkfSyjFxYr4QtmL hEO/d6PoxPuykMZYx0LYl9+XTll7bpE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=DkB6687o; spf=pass (imf26.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304023; a=rsa-sha256; cv=none; b=Yy0uGhSdEjvEXXFE8c0+ZqemcvcHzPtP6DCqsVJXIDeOM564ChhGK8xcr9KSw6laoCRUZu evFWm4YflYbK5AdnGu342DSaFpGNE1zje69Lgronk4FOvmAwVMWQ1J6UQp65+uYGRYEmEQ ws3xcL+y31m+slqYLE3Lb4OjG1zc4xk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713304024; x=1744840024; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=AYcLtBXwGHJ1lHYc9yCNHOV9e648ufAKYQk7scG7Fsg=; b=DkB6687odJD0KWMtnO9Iv633nAqEzR/Gkl2aK9t+/KYDjIcmXn3DQ5W2 FwSd44h3KNIRVAKRyZhTvz9fxoJiNWLFZwJFgnskcKcnFRw5KxDVChqt2 jbpm2lDkjXIWaqqZ6XK214opAdI7m1D5xJYVWg8ySkeey01prRuPaG//F WPVx1oLdu5vAE2GKrYsg7HHyY7UE7Oa0a9bxhN42JT3GiomiJYJ5gEKLS 3fmkeE6QEAF0Pn67ljDdorlpVXw/md1Nlo+YwQYKUJ86i426WL+NUhbg6 Mc7V8kB3CU8wi2NK2B6PBSbOVUCS1ZmxzfH3IiRVw/ewkUH5oKddDgx1L Q==; X-CSE-ConnectionGUID: lbUjSsMUS7GFklrR2UBaFw== X-CSE-MsgGUID: DZZ1dCnMR6qgJaxkyZ9Pog== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="12553102" X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="12553102" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:42 -0700 X-CSE-ConnectionGUID: s1a4Z6cJRL2V22y5xiFIww== X-CSE-MsgGUID: bK9wP8dUQouG4fYcXSLgKA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="22464251" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.14.216]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:41 -0700 From: Vishal Verma Date: Tue, 16 Apr 2024 15:46:18 -0600 Subject: [PATCH v2 3/4] dax/bus.c: Don't use down_write_killable for non-user processes MIME-Version: 1.0 Message-Id: <20240416-vv-dax_abi_fixes-v2-3-d5f0c8ec162e@intel.com> References: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@intel.com> In-Reply-To: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@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=991; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=AYcLtBXwGHJ1lHYc9yCNHOV9e648ufAKYQk7scG7Fsg=; b=owGbwMvMwCXGf25diOft7jLG02pJDGlyH/eznQ6+pWqQlbF2O3P16ZOcZuv1fx+ODZZUelDJr T5/u3xDRykLgxgXg6yYIsvfPR8Zj8ltz+cJTHCEmcPKBDKEgYtTACYyhZfhfx5nV2XyapeCRXr5 C7ouPGUP+yo0baK3lMaESw9ZzerP/Gdk6De6+NvljPkOrsdnpKX2fTJhWy/MpXC20st3X/aDqPl hLAA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Stat-Signature: nck1it4wz3mj7rwjpeoohf4iei4qi8mc X-Rspamd-Queue-Id: AB49C140005 X-Rspamd-Server: rspam10 X-Rspam-User: X-HE-Tag: 1713304023-253495 X-HE-Meta: U2FsdGVkX1/8OkcEQptFLZxjgx34hE4nFgmRd2fHVIe2dfZ7TnNxtFfWMpWa9pMBH3wE3myn3mvikVsGfy3hONkbc+6TYh89CjWAJPOkmZkTxDDWWvZ4j2bJYoI8KQYaWg+IRnXM4NG+qU+O4wngsx3qKeO26b23o7n3qOJ0kpySx6srAtkNpmSe/NbIvVFdvcmJwRpYPxmslmY+bPZ0juwyoCxUV/zc0Y4IEJmPmSCK3ZD452L7w2bsxiI8Pv/YqpORYr41Jphg3+z57fSom2DAyqrQpiijQAg8b03P/JVdOmyOJ59ZQQEdhMq+ghcRbqFPzdNk+ziFSB9o2Flj+2I9/4D/Y18NE66b/7ye1UCxppmwdpEHTEYq0UZYuTvmc2xTcIymV5/UwNleaSG2Soz4YPPCcaNrNhcVcJRIDpcYeWS3NfQvm4qjn/aTymoaBVXwSD/7Prpx+suOALRXilafBvDulOi2DPx/r6FkKVbdvMVvYS214TUqkrOODa2RUDGGts7M2Fqhyg5YESwh/wmMJjXKWPy7KUPZVFkBprxvdLE8BSbc21KwIW9OEPtPzXDDbAHeP11X/iLw6Qa2ce9IOeKBz7YXLAeuvhEdZeCE7v1P8FlW8fby8xxe16EU7N6NnC9y5WT8vMJz7AzwVlmlz05JabSHLwV5CiYTAhkIWvtivCF5W+Z8omv14jXMWshjim3C30XcDG7e9E3g5o/PnnilUln4WnysRe44Xyp33UINgqJUvdbV71/3evFStkTrsUSEpZ8249EKNQFXiP8XqRrJV8SmEILOnXM2S+IQQuQUYVTmZsPMzzMPl7S8a7ieBeKaUPE5x2JsztX8ML71bT1j8pSmZJY7WWwfnHDEM8eM+skgW6ZFlDaa5OQIW0KcseDRSlnE+H0gZygnizNJck43iRafIdvnZ3SAHQxMU+h1XRIRGi9gWE3oj3YVjNB4rfew2BHYL9LXqxh NY7fzPQo 9xH+5AngCfwRC3Xp54NTydxKncEJ0zl82E7Vgd0Tmsh+zEitx35pRuW/1XVr6wxj6s2JHhjaOYxARSE+E8EdiQY53Y//DPSBGGR0qKp1h7UrvJ7C2fyrEHeLImhYb7+QSYZAQeVjQHTsMyk7Zsxlur58q2TN/7IGIoJYsZZmmK3V3RRIJXf2Wr7+WMbo75O/FFFeJh7Xy5UPrK3yyrAAMjqyygA== 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 Signed-off-by: Vishal Verma Reviewed-by: Dan Williams --- 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 4e04b228b080..db183eb5ce3a 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -1542,12 +1542,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 16 21:46:19 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: 13632640 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 8515CC4345F for ; Tue, 16 Apr 2024 21:47:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5477B6B0092; Tue, 16 Apr 2024 17:47:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D3946B0093; Tue, 16 Apr 2024 17:47:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34AE16B0095; Tue, 16 Apr 2024 17:47:05 -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 141C16B0092 for ; Tue, 16 Apr 2024 17:47:05 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id CFB2AC0BC9 for ; Tue, 16 Apr 2024 21:47:04 +0000 (UTC) X-FDA: 82016730768.22.74B7B9E Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf05.hostedemail.com (Postfix) with ESMTP id A03A4100014 for ; Tue, 16 Apr 2024 21:47:02 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lx2b5sxJ; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 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=1713304022; 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=oUXoh00F3prGsPL55kVpznt7G2PietYpg7kG2hb4B/w=; b=Fss/UawzDNkisMa/6zpE0i83lzT/gLhWgo7RkbuPxWgDPhzJ4RFovIlw2ky8XfSv+T/4f8 Omek9RVksz4qfNLr+fD/MsUESZ8jBmUhDA4xj6CdlRUPYmnCvxO3N/BV++1f3KGJGGq9sg qnDj6+nMt8bZL+fNk/LU6sWuuVsjwuo= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=lx2b5sxJ; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf05.hostedemail.com: domain of vishal.l.verma@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=vishal.l.verma@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713304022; a=rsa-sha256; cv=none; b=tcqo/aMCNjwW1vp8/AxGEFZngXFN0MdPeGCC40iHPpfrPYdSAz2n1pj79/0TwbUHdEjaj9 TzTUxQZ/6fQJgQCKd8s/9rNfF3WVAGej/ArqmbPnmhCbtkfJGKV35GATTkiORafDSxoVwy aE+0OzdTlMT/YqImHNgqiYObFCFaoUg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713304023; x=1744840023; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=psiSCf8lZOYgQBeohr4J/sdl0OC+/xsZnCHQ3I57Cyc=; b=lx2b5sxJiVAi0FtUF1rMC5qy2AKsntQGWz/gpQduNu56+fq2dh8GsnvD zzu+xmPLnlQevxw1MJr8r/KYl/I1+eTRsH/GgzIkFX2go4vk6DsL2WvVE 6dmj5UFozHVbIaiOrpLxgzZxBgLlU0T4bIZqjCfn6NZ7zvGxZhMTvrhV+ CMK7ClXuTqXTAYtRYSz5SlMpevx2VbbI73IUQuetYu72jpi5iB61v7UPl 0A4AslwzibEIn1DNwtIrCk/9MRA9AnHvgyuIGidix7Gqg6J0GirHpghJ0 lY5/IpI67yt5nkf4M4u9QEbBLrVf2nVkz5P0IATQRNy3e3vIXOjh1LWCR g==; X-CSE-ConnectionGUID: aMsHdPzrRMCAR5oqZpd2iA== X-CSE-MsgGUID: 2f2JB9knR4+PuWlVIDwpDw== X-IronPort-AV: E=McAfee;i="6600,9927,11046"; a="12553106" X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="12553106" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:42 -0700 X-CSE-ConnectionGUID: 07RsA2yoRfu9UMmVybWr+A== X-CSE-MsgGUID: YivqiNc6SxGhJL2ATRp77A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,207,1708416000"; d="scan'208";a="22464263" Received: from vverma7-desk1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.14.216]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2024 14:46:42 -0700 From: Vishal Verma Date: Tue, 16 Apr 2024 15:46:19 -0600 Subject: [PATCH v2 4/4] dax/bus.c: Use the right locking mode (read vs write) in size_show MIME-Version: 1.0 Message-Id: <20240416-vv-dax_abi_fixes-v2-4-d5f0c8ec162e@intel.com> References: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@intel.com> In-Reply-To: <20240416-vv-dax_abi_fixes-v2-0-d5f0c8ec162e@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=980; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=psiSCf8lZOYgQBeohr4J/sdl0OC+/xsZnCHQ3I57Cyc=; b=owGbwMvMwCXGf25diOft7jLG02pJDGlyH/cz7pX0cJ375bC3otT2ot7lH8M3hFf7VJ0Qrb998 9M9TcEDHaUsDGJcDLJiiix/93xkPCa3PZ8nMMERZg4rE8gQBi5OAZiI/DuGP3zLNh9X/5/4Jm55 1eN3wkqiEVnBof/1RB6m3fG4t2fZKhuG/wlvHFblPBLLiJ75/QdXs/WBmVsZJzb/j1u505jhodO NTF4A X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A03A4100014 X-Rspam-User: X-Stat-Signature: iidfbfjwzyyn4uxxdji1fft77bjhjdk5 X-HE-Tag: 1713304022-857814 X-HE-Meta: U2FsdGVkX19/qnBw3HyjV1OgiNnqx6f8/LaKg1LN0faEw4+M3KTSImpKnylyOzk11bp30ENrlAk6QFVgvA+LQaMVuRuXWLvaqjwPVypttDfVqiVR/4g0eU9JtbPsqcHBj2/b0H8CPf/UNJjn7Pza94ojtsnxCtomsAYwYphxlueDoZl1LsEVAhShBek1q/Zgd6swpWZAsKV7tuDTBRdIxA/I903tm+kyqLG6RAaXsjKdS4A0lYzY+gHUOpmPpqTWHCBLKKPtWMWI79O01qB2r7mgnHpbN6eu5KXn6Vfw52wO+s1n67kNZajzZLVYo/ZWxBStqNQfs0mpYxdvb890k+XRJubVk0moFetzAoUBhiyaaD+thnILskpQu6rOn914pIIvPcoMNALhMjvtq4NtsKnDDl+RBHRMIN1pyUB+YzdaNRCnbsfodNXRogTVo6KSOpqxJzP+32MTEqLqKPuTBO6DtQddlLQZvLZg0byBqCsH660aT0pOdiXAs5pxNfik1e9mtbawoz1/JFewBnRb2M1K6T5pCLJjeIiiw9xzW0HRH+v/Scv46LEEQi5uSs2uDJ+NaRWrQbtr5ZEMoCqR5EXybFTXViLqrRU6j5zPs4nzyq4DlxHL29qQhniO1yQIeTCCS55dUyfxK52IOFa2SS6KebFZZ6/kHNW/2BbONvR1EiMhstJLsOHtOIWDoNzoUuBKlEp70egoOH3p4WRy9Gzkp6iX7Y23/tc43mXXiL8RxtZ7Rr7zx3xIyY89NjzloExHxfGyiEfmNWZNtGUixbymn2i7IzopB/VZzsaHTYluHRmpdmRnnRWr/s+cltVoTo7FhXdghgLVYT/r8cDUmONPg/xarzboRhYPCwOtRw6HKXFPG5df+ZOQcv3Aq33lHlxI8FyHoUs= 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. Cc: Dan Williams Fixes: c05ae9d85b47 ("dax/bus.c: replace driver-core lock usage by a local rwsem") Signed-off-by: Vishal Verma Reviewed-by: Dan Williams --- 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 db183eb5ce3a..66095e60a279 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -939,11 +939,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); }