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: 13649819 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D66461527A4; Tue, 30 Apr 2024 17:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499084; cv=none; b=LkDOK1ldlo9vX2IS/QEpuwVG4zE817Pz/BOJekjH84R4A2l2xXzebcTMmNfThlKjFmhYFvU2MJrGoDirfWio6iciQJdATyCMyfYOFpADf9TmqRCXA3GlntRBowm7m/9n0WBUP56atVfhPYK2TuWbiD9kX7NfzJ1L3rdM6Hgp/t0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499084; c=relaxed/simple; bh=gio3jLLisOYiwSCHgts3s1OVVKVXVcSqgOny8/3ijS8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ao98sSkqvBar3a7M79Krq4nwzojUAvxzLy17Ivf3R5Vzq9XXILCCeXLGZhjONMX2wM1Jh4Un9JcsAVs+1h42eU+ez6r/dUzf+Ba/v+bhLTiNfL6QIFjfaxtfc14WfpcDOEReITjQJnHtXuu6lq21bMxBrlmVnEYX2gEQDp/d+z4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=AeMrYl1N; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AeMrYl1N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714499083; x=1746035083; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=gio3jLLisOYiwSCHgts3s1OVVKVXVcSqgOny8/3ijS8=; b=AeMrYl1NM56Svp3SF2rt0cDlnOVGLhmTttPukEx0wnxMa1bOBHKEj5cx GnR+cy5aXB65fQHs+A4KVcKYohtTw6XtB5W820iBZQ/UcFmviH9RDId/r 1VXEkCP0MgeNxK+gEW9yCJlWtelUoagUtOY3pnwGqfJ+cD/NataLRWhsN hnJU/PwWIAoBdU3Ex3ljMhyD93VOeYMEUZhfp8dRVy4w4z4Wko32T4AIT eaebjkT4H5YCB5mF4Vh9Asj0G0ayv8LmIqEJ3CetAE2OlueSPLXHpu4dX Bzy3TAjURHfQ1q2a4B8vlN+5dtWie6iBN2nCXFduRn8ND2NX8n6jjGNJ+ w==; X-CSE-ConnectionGUID: DG5DnNl/RJGtKV5QFWby0w== X-CSE-MsgGUID: AMBCpB0oQfKgUPSIpNtvIg== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669833" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669833" 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 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13649820 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F163180A70; Tue, 30 Apr 2024 17:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499085; cv=none; b=ml0DQ2c2RHgIBQZQL7dFXNTZ2QxDGFHFdV8KWUV9WDe2UwmIwywypwqCm3QYDq1hna0lfza2hTPm96Q3y0BmspkmKX0C5SsnZQscCVwf2gU52ZMwIG0Ja0vzz1UGi9HxewMafDW0Z4K04FB83hkdv8/b3L2tLSru0pcFVLW5k+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499085; c=relaxed/simple; bh=T52oU7nq5CORc4zUmW3MiR7iyOzbCEAUapTKwbnnDtE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZH+bOZXy/fSx43V8nrQ6a+/2TT2GG/bz2uUrwafZox31IPj7KJ+GXA6/yZQ1UGVW4bWddoA9dUuQRt44Oz9h/YmCsG7/eCzcjkhe5t6Z2UQhLyAiqKtM8hDsgZG6UTeCzeBXElTCUpWZfafIpvm5DorkGcy+7196TDLZ7k4STOE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=iZXzoPK+; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iZXzoPK+" 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=T52oU7nq5CORc4zUmW3MiR7iyOzbCEAUapTKwbnnDtE=; b=iZXzoPK+B9TEtKYFOCVLbzTPi4qTg/RwFnnPDeW7LEn1JGaPH2+cvUVS M6SFdaIERgDAOmBb1PogES0+C4Lq/o8O/pY3AHV0qY7LkHRsMNzAtEgn2 yrY0xMIl9TbkwnoZkYKWX0K4dghajPhQ4sepgxci9FjraWtCpHuifbT0M hEfxntsVyEurj+TsOt6/fRzuvbGtnsxiwEwH60xM0vzhx7Bm4wW7V/G34 pn6IOzR03xZkRKTzBuQfABRJvJvAUsiXyhLtZ+HXz2f32dF41Yk6G9sz6 6Z6Zcht9lZnWdmA743BDH8tY2q8n18NhOaYaPLzpd5N58eXNp+nuqzea5 g==; X-CSE-ConnectionGUID: XL3fs/hIR7iv2kEHVj7OGg== X-CSE-MsgGUID: /90zm1V5Ry+upKCQIYh0mA== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669837" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669837" 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 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13649822 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D88618133A; Tue, 30 Apr 2024 17:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499086; cv=none; b=Z3Hfi5ImXy0F+BN3PCsUM9ZNfN5+QNSShB2Ud0NhLt0XPWAd+BvPiny+cmfZG4e7tnrqHo7jEYiUZYx5jOHIU0Z9SAxnKfWsBaT9Aac5ZEuzvqIjrcFAHLdNn7cCkJBP0jRB2btAwQcWcUIJ5E1Mn7vYIu77tOfbsLR5VGwlKTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499086; c=relaxed/simple; bh=NhTlptPmEedEHUiT46vqy1jTU5giIPfdgp2TteFj/UU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HjrAfEb5F18yGvLEKcDfp0x+qIqxvi6M5SOgZ8FOKKcH6uCW+GyFD3PgsibyQTKF6ZnS5kz/5EHhawRx9rnbj/jbLFfOlLuQGYdt40OJEWtviDOvXH5WOJJrv+2oxs5ssM3pftYTlx34q4Y7WcF5255YNKuamUcFcVvmHUkKSeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ggqfmnTI; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ggqfmnTI" 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=NhTlptPmEedEHUiT46vqy1jTU5giIPfdgp2TteFj/UU=; b=ggqfmnTI6RzGiyCpqI9k5msSlrX6ul5iw2pJkLPEjg8BrNapP1dT6zeC HsfSJfeBvi5nzQa82qg8HJrCrk74sWG0csBwY0pkZW1x7WWIFpapm6+iV dhjmV0uEj4KmN1gz+nnwzBBnf55B6KOpxdIq0dnY4Tn79/DfAuJy/gzMA jBlcJkDiNCO7GKfCqwnMSgYBUxSjlvXvbN8/no9NyGeqUl6nVkpWaNPpH BDTtP/onhsWT7U0V3LUBw7BHWvwkjyOYR4C4YHnLpgOhO5LY9hYl87Ru7 l3iC1IihlseNnSEUCAiElZ1wGkk6VP0p7w9BEZqSQDcdtBVpxzB3EMQ1H Q==; X-CSE-ConnectionGUID: znT0yRx4RU2+t9DF9zfAfw== X-CSE-MsgGUID: 8ygP5gO9SzO32bhZJqX6GA== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669841" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669841" 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 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13649821 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E28E181319; Tue, 30 Apr 2024 17:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499086; cv=none; b=oUMa/tnT5GBQ3Xdx2AJXVFOYHrCwrd7VGNnM4rz/SevGU0hc3cqX9Oc4qbGRDHUJgCavJwdD9pLNkUWYYDpBfRCWs2oBQWhh+/QUpwh8ZHkCa6zgOxah4OWi0Ad/6VuV0XjabmKyB3uVj9ai8QPgdAbvc2deegllFYT/1bOWhtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714499086; c=relaxed/simple; bh=IuUcxmSQ8rmcL+XwprIf4jy7ccGbldFrluNcXl4Pl6A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uKu9Y5auj5y3QEGmHn0LsG6dP1w8F0jTSaccl4/Ntpr7T0MRALUrIiYuQ3ZUlTFBBeZYez7qLHoGrgCAslbWupbYgBEblv4/wqkJptJx3dPZqD1k+ZhTakC+KY9f9ieomg4ovfjmzJRArnxXW2Xhc3QRytEtYsnx41GdjNef6mk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SyMdzu1p; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SyMdzu1p" 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=IuUcxmSQ8rmcL+XwprIf4jy7ccGbldFrluNcXl4Pl6A=; b=SyMdzu1p5mIEHKUPS7+nJAvFr+pmTpHML9/xu3vr3f3K7d6GLVgq31IV vDH//PREcan3GXMaDfsx8cyuNlBxhoQ1vYH/9rrE7eNUg40X3La/QGrug AMKFJI5OJegilVr++I4lwY9z2AW9l9hdITtzGRZFRJ+iw2MPYseRX2RJQ YNZ+vT9897GziDfu+IsJP5G+gCfyKYoQvh6TiCrpYogPZVT4z5AKLvvkr bUnAKn2pTlwQeHRwUj+uuj7NsAE2HW6RNjxvX1Bb6jR8eLFa2jEofnxU5 J820DxptoeSkXdaOhHpL5F6SkctohM67hSi+9mC2SIe6g4lpVXtbTHf9g w==; X-CSE-ConnectionGUID: y9i6m2S8Qzuf9mKua7KzMg== X-CSE-MsgGUID: PxsbXivnQEexYxGcDE4lsg== X-IronPort-AV: E=McAfee;i="6600,9927,11060"; a="27669846" X-IronPort-AV: E=Sophos;i="6.07,242,1708416000"; d="scan'208";a="27669846" 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 Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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); }