Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2203813lqa; Tue, 30 Apr 2024 10:44:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrmJoyZAp49yIKqPOcGiUlvvFUpUgb60vE/0AfMkK/Kt2//v1JWkEkU1JSE967bKLJImzCifHg4jCGBoR7yb4aPdSj1KoxZllp67hwsQ== X-Google-Smtp-Source: AGHT+IG4TtBxb7MiO6eAOJUHszAU6yXaOpMpOXlhRY3K29i1T77sBYR2x1ZoXYMsBLgeclVpmyAh X-Received: by 2002:ac8:5d49:0:b0:43a:ed56:6a42 with SMTP id g9-20020ac85d49000000b0043aed566a42mr3680515qtx.58.1714499097345; Tue, 30 Apr 2024 10:44:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714499097; cv=pass; d=google.com; s=arc-20160816; b=RS+PilX48shCgb5JY/09gHDoEwL4dPu2XJWJAsSomHmjCfcBgqiT1GB0FOOnFi/muh pYy/fxZscuDMyPMJIgqYCY47xQsRy4igLHA9gu1QsLXqHR5KHAggLypmq3mC/n8iu8dH wAmhlyOZ2CTwPIpENDX+ctdFZCxnT2meuK1UQNMJ6dJDyoXZmGSjDWepdvkNSoSxiEjX F/yGc0rtdq8zAr4onM1uuK3N7jMeybPG6oJugope71SVDLUW9G2RkH96zMzgI2aGylky 2aONTmaAo8T3aU7RnfUxbs15V1nCEnrYgfafBMXT9TTx3k0FZLW9jDx0dNs8Aa8kcWMA TShw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=z+ufZSUgDaSJzNfhrxP7wx2iTt5TMr/s3BFBQP+9cKY=; fh=ZUwGF2Xiq/7+seiEO5Dgh1kzjZ4PK63EuEROupdVH1s=; b=pMHfIcCosNcb4/Nn3cc0oPzc7n/EfhDYVJwi6+RlA6/PbehcZR7fc81wzx0pGgwZaI vbmuhbUU+HPBacGvgEdcrRRyzBYeRa1MUhn4N3d0nkKv96squrf3EI4X8sQY4cjq8kZU dyXA0e74U85MV5eVZl1hDHsAWgwh24WdE17BRA07BaPNBwODVoy0GXsO/vSu9fA1s0Cu obpy9LRFj0Gv7LxhSsCiDY/8Cr5I+stMCFRdM4TNIPxz28B9C04E1Bx23MXnx8Wc9htD PV7OnhRP7KMT3z0NZ6FLGuo3StML4OlEld7uBoTX+/fO+aNbrttnJs6/olMr8YZ5hW9H sV5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AeMrYl1N; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-164544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a19-20020a05622a02d300b0043af521359bsi4404038qtx.711.2024.04.30.10.44.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 10:44:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AeMrYl1N; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-164544-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164544-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D04621C22DB6 for ; Tue, 30 Apr 2024 17:44:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6742E180A85; Tue, 30 Apr 2024 17:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="AeMrYl1N" 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 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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; -- 2.44.0