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;