From patchwork Mon Feb 12 16:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553518 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 1D71BC4829C for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A58B26B0081; Mon, 12 Feb 2024 11:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BCAC6B0083; Mon, 12 Feb 2024 11:31:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 836CA6B0087; Mon, 12 Feb 2024 11:31:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 706726B0083 for ; Mon, 12 Feb 2024 11:31:06 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 33AC4A19FA for ; Mon, 12 Feb 2024 16:31:06 +0000 (UTC) X-FDA: 81783691332.28.BA8E8A3 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf24.hostedemail.com (Postfix) with ESMTP id A6E7A18002E for ; Mon, 12 Feb 2024 16:31:04 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=EkF+I8nC; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755464; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QQA/ij2WbJgdSDvBywiLol7C1tjSsVdtqkl4hy1jRqY=; b=WGCjKWDpJDTL62lpwZV6QsAz7LpePJiUWkW+pNJALkB+Riuj7Tz4nM4sK2Q+Kk8t1Mnn5N zZ2SO6yB+bv0Cgv716SBNcuZNfi/Us7Oik1GNXwY6HEGxri02jDEjkZcdPDEPthLnVRM8r ojOT8L/yaW+4c8mkR6e1lb1JOuqVY9E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=EkF+I8nC; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755464; a=rsa-sha256; cv=none; b=dTysWzoIpnVc3iCQ9Qk9OzpJgFD9wJj05DTmtMsEsNvAC5WxLMBPFuH6Z0Fhl4ooU5btj9 MXBKylLf800eFEVTwiPv04DtXZTWAKKNzfetSrSk/xyJRh7QATUgeq3IIaqpIANBb+pkCZ ttZgeVltjCrGA7cjkR1XcJB7E+7oGvU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755463; bh=q/9jEJfnqEQkc3MaRhsxgrh4+o9HVwSNE5hPfxrTXB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EkF+I8nCzGXwgsjLIO9z5hrj4YLXkG1Gy+qBhoGBPBzwMSQ2ngaByzqZ8MwMu7uYR HVuW3uAHo7KnmvGrg8FW5d8BZO/OcZAetn3pHPCIKXU3OWKZQrd1Gq04mjZpxP50jP v2sxs0xOImWi8VD0bUUiy+VYH/NlIQft+vc+QCvBV0VT3G9XLCd+o0JpXhqhRW8rT6 HOmpfq2rS2ZnfBh8TL+swhmVq8Py5ZEKkF6SvmeGs+vHNFDGloUyRXskUrpYkosMzK D8W0MOk5fYJK6ialW8Gs/5HZdIgZbPC1bGBNdK+vbFrB6x2RODeex/oO2dOq6vh+67 oMJWvt2aRlatw== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMC3L1TzXvQ; Mon, 12 Feb 2024 11:31:03 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org Subject: [PATCH v5 1/8] dax: alloc_dax() return ERR_PTR(-EOPNOTSUPP) for CONFIG_DAX=n Date: Mon, 12 Feb 2024 11:30:54 -0500 Message-Id: <20240212163101.19614-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A6E7A18002E X-Stat-Signature: 4sprunsbrhxy45oyuo7e1mgphyrczpc1 X-Rspam-User: X-HE-Tag: 1707755464-642236 X-HE-Meta: U2FsdGVkX1+SrGV9bGpaafg8sI43VDI4EcTRmPCOm4yYG1NPTcWtajpXZkyrXcnlagCnDVA2Ryi5cbhIq+cY3NzurEeGUQ96NprlwJ/FEg6i7V5eT79zS5ByKbZLGPMGiZScW7HDNbguO6r+yPGhySWcFeM6mTShjCPloYc1iLrQQco2rde2ji84CqbARcC341ardCJE+dF0rN3SRdeQa8k6RKZEX5VRRSwvgAHNYw9bWlp0QNvJYKLhgbyZdqOF5U1imogS3mExxNAuXPTmvYRTDFaZPEO06MLdCKamtFdVDlQcLJjbvnFvuJijnClIKe+qEwhJzxZ3cxTMmmm1ZCiqjv3NnI25eg6L7IuWPXa7Jd9FQNV/jMfD0wZdm59tt5/ZsajhZS25arEk9ew/MdWXdJ+b13cjWxzo8bp+Dex0jAg5i6X2rfu48LIGgWQ77oQ1Mam7oozCnXFla/feQp+nexozq8t838eKu24Q51RKdsr7jSxPxL251469biDo9WPsDMY3HMtrSk4qViaA1WH8lSAl+oThZEOfQaJLDwMT9/R0rgyi45+ZOpysY1yAn0UGGxboasjjxxIS64BK74vQyaYMMqPQd4o2a+aUlSv/B1cWBTW8VEDBEgo5GJtU5uoGGRCzYMvbRWjfhQSKeXEqsi9VW4rU/Llg0Bo3J+Pg+ptkUNlbLuum3mQ89Eqys3okp1AH2B6QOjQs9r2SP0srCBoftXtUtqRGKEbvA7qpbc3WQ+9u3wb/Ni18uBC9MZ0anoUkkiaZXZJ1JRjguNKzhawReYZK3M0NP7b6CtreFFlam8EQy/+6vseQY7vFeG9CWJ+jAQteXJRsCLcfa1XIPuAeS2vI0d0Mgri0fJwGkPrC1XqwekAAL2Bi8EDtsOiADh2+nYjRanmhgAW0AKk/fKmg9nI6oHTl75B/n+M5aDGhMMxxKicSSJRB3oI7DiSfQTAEU7wEKVlNkvM UNlN9Zvw aY8i0w7R4993zI6Y= 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 the return value from NULL to PTR_ERR(-EOPNOTSUPP) for CONFIG_DAX=n to be consistent with the fact that CONFIG_DAX=y never returns NULL. This is done in preparation for using cpu_dcache_is_aliasing() in a following change which will properly support architectures which detect data cache aliasing at runtime. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/dax/super.c | 5 +++++ include/linux/dax.h | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 0da9232ea175..205b888d45bf 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -319,6 +319,11 @@ EXPORT_SYMBOL_GPL(dax_alive); * that any fault handlers or operations that might have seen * dax_alive(), have completed. Any operations that start after * synchronize_srcu() has run will abort upon seeing !dax_alive(). + * + * Note, because alloc_dax() returns an ERR_PTR() on error, callers + * typically store its result into a local variable in order to check + * the result. Therefore, care must be taken to populate the struct + * device dax_dev field make sure the dax_dev is not leaked. */ void kill_dax(struct dax_device *dax_dev) { diff --git a/include/linux/dax.h b/include/linux/dax.h index b463502b16e1..df2d52b8a245 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -86,11 +86,7 @@ static inline void *dax_holder(struct dax_device *dax_dev) static inline struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) { - /* - * Callers should check IS_ENABLED(CONFIG_DAX) to know if this - * NULL is an error or expected. - */ - return NULL; + return ERR_PTR(-EOPNOTSUPP); } static inline void put_dax(struct dax_device *dax_dev) { From patchwork Mon Feb 12 16:30:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553520 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 A9FA8C4829E for ; Mon, 12 Feb 2024 16:31:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C2246B0085; Mon, 12 Feb 2024 11:31:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AC666B0087; Mon, 12 Feb 2024 11:31:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 725986B0088; Mon, 12 Feb 2024 11:31:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 522946B0085 for ; Mon, 12 Feb 2024 11:31:07 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 13D1E1A0928 for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) X-FDA: 81783691374.10.F728D92 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf27.hostedemail.com (Postfix) with ESMTP id 0DF3A40009 for ; Mon, 12 Feb 2024 16:31:04 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=oRgHB71P; spf=pass (imf27.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755465; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=B4ilFMr2eFF794YdWWw0DjFvkMffunaWzt7kSkCawqA=; b=f73sTCvD/O10ruqRw+M7Gcl7WWuzmwYz2nIOvZygP2OBEjjtneq0eGPUSdeuPuJgHu+lov qV8FkHzxUWuZUGjqlA9Urc4yJckOArX9ebV2aJ++uW8aAwS9IsDdJ9iTv5u0YeAtwWr68b e03P/yV1YVfhdXy6s2hNa+QGsAsYu74= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755465; a=rsa-sha256; cv=none; b=cPRphjnSvE1L6ZTT/EiAdXiSs+0eMyAc+zXR1DoURUGdMYzlk8JrsqmdSIy1pviK4pa77U Ago/2IdMEx4MplCZM9IN6X/PFpZvnjgvwNBsth2sxwtDsJO9bNvPFK+6n2FuxGIX6JFTq2 l1qBzzBEhRoSsqtVVMbke+MQ1VOJjtA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=oRgHB71P; spf=pass (imf27.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755464; bh=ecUyvilxXmAuEa6CVYKrKIA8K8l2tVUUJHjpsI0Te00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oRgHB71P8SmaCX/tCeZteHX4/MQWsvX38WZLcuAntTjvfEvdxOg7QpPKiM9bQVwyf RsV+U02IEvhJ2YU1a0i36eAEEMIT4JK3BXnzDIqYi2uVGBkSzRpHZVyizYFBrY4wrv yQGWxe/GORBjLpbRChTfuyQZT32Quy4z7G01Z6CTjmK/33sZZz3v44j7hdbznfWTe8 3ZNCtjU8laXZNvJdYxHxQew/vONsjZs/fE1EWjjpmAVIBe4o0HLQ3ouDp0PAKNC/NR leOkRceGOfzokWkAdLU3lPjBl1kaJFjwlYsLTfacQdKe8jagU6YZWvacZYOmSf3Dvt SMemhEKFzt3sA== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMC6SRczYQx; Mon, 12 Feb 2024 11:31:03 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v5 2/8] nvdimm/pmem: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Mon, 12 Feb 2024 11:30:55 -0500 Message-Id: <20240212163101.19614-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0DF3A40009 X-Rspam-User: X-Stat-Signature: hssbtobe7b3sj1o89pmiron5ehg7hjx9 X-Rspamd-Server: rspam03 X-HE-Tag: 1707755464-19675 X-HE-Meta: U2FsdGVkX1/3h8atUnd5FTgna+lU6ZVrdLavKHz9WTaUgASJS7GMnnqRBLOYx6EzDBuySAyEgv7IMtxrKk8lEbdlNoND3quJfG4R0BMnj2WW9/Mm/+rq0WC1nJ8Grh6DUiRrloiBrbbWIw4Q1XUydjwbWuq385JM8IbFQfpW7nHIwvEFlX30GLYERvT+tLZlpCQPOQ5W+QGn5WQQNynl3w5Of82KlrtRX1FM8mm4vJL3HGVMYJhXlI6c6MVR5IOm9ZUN6Ww3uD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NFG1KKDC6GyH8BKYOmpYQ2wUlh2s1vAlZ8Y6UClvaEyfyayz3PEdUOf+aOr0dqqR4dD/KQZ9A3ag+l/iPa4kvEDr6Z9k5Yr7dfwlrqhzf2sDbNRlpoHpLwX4QQUK7cPzoACodc0lA434FVW70EwhiRdsJcxgzmnyV6otoQI5wvDv1IAPQkswWLy3z1W1vFHVLrcV3At7MAhrY3i2V33Wc5YMshe2Od5VDDsI4HNCG7cU6XG96N3rfUifLFeN8UpKO7s89Tb64QfywIRSlf0wgoEF4Yi8pCRJNsbuNk= 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 preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of nvdimm/pmem pmem_attach_disk() to treat alloc_dax() -EOPNOTSUPP failure as non-fatal. [ Based on commit "nvdimm/pmem: Fix leak on dax_add_host() failure". ] Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/nvdimm/pmem.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9fe358090720..e9898457a7bd 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -560,17 +560,19 @@ static int pmem_attach_disk(struct device *dev, dax_dev = alloc_dax(pmem, &pmem_dax_ops); if (IS_ERR(dax_dev)) { rc = PTR_ERR(dax_dev); - goto out; + if (rc != -EOPNOTSUPP) + goto out; + } else { + set_dax_nocache(dax_dev); + set_dax_nomc(dax_dev); + if (is_nvdimm_sync(nd_region)) + set_dax_synchronous(dax_dev); + pmem->dax_dev = dax_dev; + rc = dax_add_host(dax_dev, disk); + if (rc) + goto out_cleanup_dax; + dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); } - set_dax_nocache(dax_dev); - set_dax_nomc(dax_dev); - if (is_nvdimm_sync(nd_region)) - set_dax_synchronous(dax_dev); - pmem->dax_dev = dax_dev; - rc = dax_add_host(dax_dev, disk); - if (rc) - goto out_cleanup_dax; - dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); rc = device_add_disk(dev, disk, pmem_attribute_groups); if (rc) goto out_remove_host; From patchwork Mon Feb 12 16:30:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553522 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 71F2EC4829C for ; Mon, 12 Feb 2024 16:31:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 28DEA6B0087; Mon, 12 Feb 2024 11:31:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FD416B008C; Mon, 12 Feb 2024 11:31:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E2A836B0089; Mon, 12 Feb 2024 11:31:07 -0500 (EST) 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 ABD356B008A for ; Mon, 12 Feb 2024 11:31:07 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8F8AE12096C for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) X-FDA: 81783691374.04.A8DA91A Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf02.hostedemail.com (Postfix) with ESMTP id C2E5D80034 for ; Mon, 12 Feb 2024 16:31:05 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=VTKykfQI; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf02.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755465; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=99RRntZfkjnZKNO4IHwslOkSnOz+slrjRxiaktTh4zQ=; b=YstIAn2CpJS/ruZ7QSom9yXqF3UtcnGYztlkIiDgRYNngfkpoe/95TlPDXhrFWJHRpDYrd jt6uOkH4fgoVF2oFvjARdYsHoAB6knEVOyNAkINb53ozeR7/2Eh6h6ItM+aOhxXsb93orb 0FQVKMBqUNMae1rxJRSF7rolSt86onc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=VTKykfQI; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf02.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755465; a=rsa-sha256; cv=none; b=d48ZPcyHEkCAfpUygqUfOItQJ542j0aCDbxUf29ecUkq36jnreLRXNT6y98ftRZkZ5gwOV sK0wk5LtWlediBTgMqQGTgqAiYJBagDV1i6tsQ01twM+yNpr+ztKlir+NlXt4J5lQPYLzf AK2jkp/8N/QVB55RkfAKSpIxT9p/BWE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755464; bh=CbAyr+xbx+4Y3FlaBdF7mHOoD3AcNitxApGii8uR9rc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTKykfQIFeg7MsgPwyNK/d6uzEToAQ8FlD6SGX+bGDjm61vIw37jcpX3CfF8gVZCC oJfrLVqcmHnyN8EYEAo12aQFH0jE3PqvtX9puwfbJ8Dy7S9hiSIDtRAdBQB8Y02bGh 1unKHeombD7OmhYiMUdmNLEAww5/+i91PM0mB7JcWV7MY5rVP/J9sD9da10k4HhwLt HWHwDADStQviiCfDbETS9uwAi9jnPHveF7qMZ55QfbukSsZwklpu8abwXhSF825/4m QjgFOnuVbF+GUg1Z8zB+c5h3k9WoZBREVS/p9dlZAwel8/0/um+lsrPfzh92XZ8bA/ DZw3KbUi2kHOw== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMD2VHMzYQy; Mon, 12 Feb 2024 11:31:04 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v5 3/8] dm: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Mon, 12 Feb 2024 11:30:56 -0500 Message-Id: <20240212163101.19614-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C2E5D80034 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 6jguzbytctuzryp49kkwn5xnqpywe3r7 X-HE-Tag: 1707755465-406415 X-HE-Meta: U2FsdGVkX1+4b+2doyWjdlJTkz6dQT2eOXXU3UdEZz3/t1Cwzqcds1CkRKq7MyO2/ieLGbc6etXCrw6TAuxEHHaFljq5vzpMNVpNbKWFyZbMAqqJAWP15dPowkKcSFGcvfY9ZbPgPvaNQwgV8+4ASekP8TppOjVezuKudd8pilcWU23yaJIBJri6OKvghh5ny4tVBrx35/5lY1C0zGFI2mNRZcmD5rzZZLqU43byjam1hSdjwJtoM1JJBH+1FclykLxKR8dWLd9bk5cO6Ur0UU4IVfyqLzYyDZxauJacRRqir4XIu1N8hNjcxYuJVfPPD/V3+NzVrLN4EwU4K0cJ9D6B4UwDeqEGdhRrE0VVNF8xYQGGyXQBd9n6RcBkVvM56pXmNvU8i9YU/OlmN+Y3Xv5s4y8Q9T389BuLf0gwDBHAUB2Iy8rikYvua/xfZSqDD9W96rVtl8DqZRFAMsheCniNn1pLisS8GWMwOfoDNQAlnw4NLV3p0QfhwQcKHZjlpAfc0LjXGTMrVZ3ZiPpz5FJShd3Rno/qPwT4f9qlDkqnTWuDuJkaCSRrMRwkCdQvd2KONa/hxVb91THZqr/R8ErlY/r8GxeM1MT1uuHN+NXTuD+z4bMmnSkImu4jWGoOtre3aoYlwzaWu76HXdSGxVmiNUMr0kbhS9ZxeZQpGDIJlx7Z7f6UroM2CwNpfdOuASx9PbDxGeDI9DuCVVJ63KHVeg94cNnOorAho+VmeoT9HpKac+frJs7ZUX+siFg27jp11/01l7c30G1ds+qfLkV8mPYGm6pshU8df861p4wR3qZNVeUsjd9Rc1Leaggt8s+4jr8lh7IKDlWep44lwWjJE41/CdYDMSazgPMHWc8mhP0x85eFOp6UMe+ta0olFyxXpVpBKqKWib6CP8jXVsq1bKIBOijwHChrcRZzA9wIM6lQiFzS4PT213eYWREgeKql/iRmCzzIbLhgHLq lea9lHiN LWMngFb2kilNwNxqgg75aJfatnMWcDqb0sVZPIPprrcv7UiFumrhjQJyMcz46pZBKkO1ft8t3w2MYTnE81aOIvQ7gzgGD2E9Lp52lPKhraTfwS5rB3wJ5+byGB5EAMFcoWFUyDHQ3f1GtroxVl3au4W/lPHYnWpSoLz2tNP2C84VSKXfy1z85m+YJ8etyl4jbMszximgFMSrY7a2xoI4OAVLtL6cks9lanmmlCgYFBB0bj7Z0ZWmFUNHM0nT2KVvfV8xMG2vChGttOEyds6BgHjF98ErP+A7SSaa7ww/3WpeByEv8IwnoygLyi6ybPcwQJXd93zTw+67e2UgfC0cabqMM63mqR2g0KAxvHHC93eZ9WmeqtH9XrhjEr0irWhP4QPeEWS4uxpoK/TKZODgswG8NNP0sXg5ZoHewftw0gZUONSuPfkkkB0oiN8MgcOVnpfx0AbXMXYBEeC2k/zjF5NhGjhMd95pmioYB9TCJcs7UIfIPU5oSmrqMgW1qTSrJLvzW4vDyuda5Gtpz93ysmC4chTNR2BBHs+Sn1/tki6wlyiqHYWi6GrC/VKPvDpMATDN++/kRa9K7QQ8O959OFPAwmAPBd4u282Vy38fgylRMqy1vk5/tVbd1VkIkFDYxIg/gLEZGnoxFHi8= 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 preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of dm alloc_dev() to treat alloc_dax() -EOPNOTSUPP failure as non-fatal. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Suggested-by: Dan Williams Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/md/dm.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 23c32cd1f1d8..acdc00bc05be 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2054,6 +2054,7 @@ static void cleanup_mapped_device(struct mapped_device *md) static struct mapped_device *alloc_dev(int minor) { int r, numa_node_id = dm_get_numa_node(); + struct dax_device *dax_dev; struct mapped_device *md; void *old_md; @@ -2122,15 +2123,15 @@ static struct mapped_device *alloc_dev(int minor) md->disk->private_data = md; sprintf(md->disk->disk_name, "dm-%d", minor); - if (IS_ENABLED(CONFIG_FS_DAX)) { - md->dax_dev = alloc_dax(md, &dm_dax_ops); - if (IS_ERR(md->dax_dev)) { - md->dax_dev = NULL; + dax_dev = alloc_dax(md, &dm_dax_ops); + if (IS_ERR(dax_dev)) { + if (PTR_ERR(dax_dev) != -EOPNOTSUPP) goto bad; - } - set_dax_nocache(md->dax_dev); - set_dax_nomc(md->dax_dev); - if (dax_add_host(md->dax_dev, md->disk)) + } else { + set_dax_nocache(dax_dev); + set_dax_nomc(dax_dev); + md->dax_dev = dax_dev; + if (dax_add_host(dax_dev, md->disk)) goto bad; } From patchwork Mon Feb 12 16:30:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553521 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 989CCC4829C for ; Mon, 12 Feb 2024 16:31:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3D196B0088; Mon, 12 Feb 2024 11:31:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E9EBE6B0087; Mon, 12 Feb 2024 11:31:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C35ED6B008C; Mon, 12 Feb 2024 11:31:07 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9D5106B0088 for ; Mon, 12 Feb 2024 11:31:07 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 79DC812092E for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) X-FDA: 81783691374.11.0D93242 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf22.hostedemail.com (Postfix) with ESMTP id D7047C0011 for ; Mon, 12 Feb 2024 16:31:05 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=Zyy41IcN; spf=pass (imf22.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755465; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gKli+dHZYbYl5NcIKVupWlrpR3NX93t10pIkv+yAmpY=; b=tt9hwKu1VCMifGZzAdt8i+dgJ/Tph6UdX2AsO25plbB5MkrkNUG3UNPDvoBf2SjP+XqcWq NqxKGQ+RxRR6Tq5WIQc381e7j5+Ps+Jkt4XsYnLdPwYjLgIAkjVuRLR7hLOAxdoEZ8c8NU 3RZqDZnJPCIWzz7E34MA5iljwMvEwaE= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=Zyy41IcN; spf=pass (imf22.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755465; a=rsa-sha256; cv=none; b=uqMvasVRi2x/UiKq2E8osq05/WhvOFUy2vIPXvnlwE9bvwKpXy69jKgaciP5mB9Ergvo0t gs7ZJZjLfqdlCn8uWr0iWrqwr0TiH6rXdhz+lirqc8P2qLzIVnM5tO44rWw780ycL3bMUC TwXusKIi4rg47AKAKlbVri1HYlqLsr4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755465; bh=I3VS2JL5QdpOumZEunORNSa20I7SphHpfPnc7uZLU3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zyy41IcNoqtQbIMqRtQkRf04RF8pHGrvLxtkDunUMa3xLSO7TDS/UTVZLcYlA50F0 W1hr+wGMM+ODEVJNO4I89b0Uom5QMH6vetzyPPSevwF0jTDeRAeWyJFGpQqGwx0eWr +nL5vdHpKPv75vPDGb9eGpvPBmp11fTrfr31D6F9z1Z+eosGAw+BFPLxftCWsSy0LT voSfnVGo10xz/kQWoJRH8ILXBsiTAZ/oyHYutOC88YWMjNsXImVaA1M+mXDKeE+dOh zs2AqPHYZ0nsKgPKHRTMA2OXeYdoYlGm8PVTtqi7NNaA7c2CWs7eXGRGoX+ksIqy5D uaViYgjXjXozQ== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMD5XlbzYCW; Mon, 12 Feb 2024 11:31:04 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v5 4/8] dcssblk: Handle alloc_dax() -EOPNOTSUPP failure Date: Mon, 12 Feb 2024 11:30:57 -0500 Message-Id: <20240212163101.19614-5-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: D7047C0011 X-Rspam-User: X-Stat-Signature: q68fak4o39q837i77a7zstjkm18wx9xs X-Rspamd-Server: rspam01 X-HE-Tag: 1707755465-827346 X-HE-Meta: U2FsdGVkX1+NWO+Q30S/nEhpMXr980KxPMINDNYtf5vf1phCq6CrXL7oYnHWEUlVXpmd1jjSqKQ4d3GC7Leun/kARQe9YXVnMH836CcWNMP9E6rC1EC6mW8t76/lj9ATBJRqh6ZV4Jv/RMkP5iRLh4fMek7ayEyvt9R1YzojZBgxRWWsFP9e757nhxVms1FDEXnLelixm0GY3mrVLeWPaQqUzDVftE8DZJAffFpBWZ09uZ7RkyHQnYMScIZOmpp+96FaGnLtpAG8aJ/rwMH8Kqz1qZ0ftqQ1bk4HartWHQpp41a9W6HPLsgGJnSGmCHk5sm790D110p/vZNiPups74BUOi+S3UJpAfiIarazv1HBYPr33PVlwFnESjqbm22TZSJruYanZVw6yBdW1/xsDZ3OZQs2FlNy8Wh3bua/ULtX+GMt6vTwVCmdeyxKnRL8e3WPBMA511xotcgqEjDOaG49/n+NJRJjUXG3VctE7dAqBufxQGYZNNtXSPGqaom8Yws47+1JfZ7Cku+B+zkma5X1qeDwZ7Igo6IElh+23WSnbottqSrvSk808FYlqk7ju4ygIiHdveskiMgkq+O/4BA2fCw3KWSrwUiUlJX4Zpfj17EcvMyp+WxM9TMNpIYaXZnz3TEU6JMOd/MRmMgXoMwPkLMw49lgcE/K+2YR086TseNuTb7sMQn8zGMHoXI9HSX38PW2gRYSMFMO5BPmpnn1JcOP5lXPMpwGOJpv9EiP5nOHL/Sa60w7t+d4oVLJ5A9S1VW7+xse4cI/yGViCXLpXSFRZc3VKJH/xMIdCap9luWC8QnGWIKIcQxm6i6edxA3Bae5cN3ymdGZsSrrcqSzhCTY8SWgZwJ5xiJPHBZH1JERlJKryE1WRzmrFErHQfKNnRAuEAIPbWqtPvKiXRCFeOTeNCnYEoH5XASZTeRXMugj8xdeGhFHXtMKmO44fiQ5qbKR6qsvLVQpub7 FRZ7lYIf gHPYilVck07OjZgw= 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 preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of dcssblk dcssblk_add_store() to handle alloc_dax() -EOPNOTSUPP failures. Considering that s390 is not a data cache aliasing architecture, and considering that DCSSBLK selects DAX, a return value of -EOPNOTSUPP from alloc_dax() should make dcssblk_add_store() fail. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev Cc: linux-s390@vger.kernel.org Acked-by: Heiko Carstens --- drivers/s390/block/dcssblk.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 4b7ecd4fd431..f363c1d51d9a 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -549,6 +549,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char int rc, i, j, num_of_segments; struct dcssblk_dev_info *dev_info; struct segment_info *seg_info, *temp; + struct dax_device *dax_dev; char *local_buf; unsigned long seg_byte_size; @@ -677,13 +678,13 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char if (rc) goto put_dev; - dev_info->dax_dev = alloc_dax(dev_info, &dcssblk_dax_ops); - if (IS_ERR(dev_info->dax_dev)) { - rc = PTR_ERR(dev_info->dax_dev); - dev_info->dax_dev = NULL; + dax_dev = alloc_dax(dev_info, &dcssblk_dax_ops); + if (IS_ERR(dax_dev)) { + rc = PTR_ERR(dax_dev); goto put_dev; } - set_dax_synchronous(dev_info->dax_dev); + set_dax_synchronous(dax_dev); + dev_info->dax_dev = dax_dev; rc = dax_add_host(dev_info->dax_dev, dev_info->gd); if (rc) goto out_dax; From patchwork Mon Feb 12 16:30:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553523 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 51E5EC4829C for ; Mon, 12 Feb 2024 16:31:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6EE36B0089; Mon, 12 Feb 2024 11:31:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AF5C86B008A; Mon, 12 Feb 2024 11:31:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 920C66B008C; Mon, 12 Feb 2024 11:31:08 -0500 (EST) 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 74D166B0089 for ; Mon, 12 Feb 2024 11:31:08 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 296E280A94 for ; Mon, 12 Feb 2024 16:31:08 +0000 (UTC) X-FDA: 81783691416.28.131DC04 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf07.hostedemail.com (Postfix) with ESMTP id 7082440006 for ; Mon, 12 Feb 2024 16:31:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b="B/pnnO95"; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf07.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755466; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LrfbZ9w6kDnIojd6eWFMBZSElaByAfgavWve+3WLmSw=; b=GO/NYbTKcNojnG/ktdDvu0bB34w9PJTcjC1XgrHKyfXlOAuBeMLtt1TLNiTiGi+BdTj/6a fS8IwYAUQOgyAjbtAqlLWp8hEbzRQCv6hcdP5AYh+UrLZwqUN5QcRRiZ60g4MA+yv8tISh 2EdDAYlUjrCgIpeypL7Kt6jvA7IR0fE= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b="B/pnnO95"; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf07.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755466; a=rsa-sha256; cv=none; b=Q9COp2QhQqPzu+2iuavR90QszUpg8mNkekwv+uHXgIDd1IVOY79U+IK0pQEOssNU2h2NEi xwvFMcj2PNvMjMV4UlumIQi0Jzh6HMePZGXlAbM4FTn+BdPBYh/81IpUcHeAIrIt/QxpFb XzCRRqjk/a+AV87L0xYk6fJzeLUGAhU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755465; bh=/grdS8Lpv8iOI39Sws5KokxIBSxOa0HOFRuTqUntpHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/pnnO95L1htB3hWWCF4AF8YB2ZjXV07XWuDFRuNTVg9v/lCje1jgMnLoFbNO/rkr l83/diGRpiByxq3cGzsx1L01iER9LPjT73JHfiI9hLUTgB8++idtYRY1VGF0vKZYbG MQXDKfayzT9Nb7t2SUnoFVE3ci4tnEMHm2bcA57ycTxSieBqyrz3tpFzi8TjsMfGxQ O3lr2cR3pWBPK4+6Eb+d/efb8ER8prBbyRRucJ5UkXiULs6b6sshscN9zB/HkWGm8a cEJbx86f7+QkM3fNR2e1Whfi3EPzdnGG8qLQaVs6kZD7GvN1u9pfj5r7L/QWqQp25H k9nmoHUHNr+kw== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMF1V3MzXxh; Mon, 12 Feb 2024 11:31:05 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [PATCH v5 5/8] virtio: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Mon, 12 Feb 2024 11:30:58 -0500 Message-Id: <20240212163101.19614-6-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7082440006 X-Stat-Signature: of8nqkgjaxbcaxn3em6u9qkwpkx9zy3x X-HE-Tag: 1707755466-714840 X-HE-Meta: U2FsdGVkX1+4wf4dW9HHA315gG+u/uAaSNknK6QFQcrPfGCaVUKvGsxkCb3DvxkyZhVuy1biUX7IJjTle7zimmPccW9olFcl+4+3S6RFTAcWrkT2rHbJ23dMgi9BR385LLXrhbXp1IhSNGavcJ1v5wXsQ4fYgQ/YiVRXj/GmVaj7Ae5xL+YlX3J7YVNQMneqFLfVxVIi9eqmsPBEQ7TfpSP3PPbTIGlu8a5cbjqIPUlhYz97QswCRSvWV1UKIi6emPzMc7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cnT5L+Zyf1MOUdEyHCzJb0Pqeq4zx71nSIF87odnDgV/ZnjaIs9t25LzSksUIrC4/PT4/uTp8D5Fi2ULxixugQYD4EKJ2sS2ZKp8gPVXnzbZs0sWolQUwCwGe3o+7a3PbnYMIe8WXXe1xHiFxQoTvpcIyW3bjOcncBZIVMD2MtkIg0spuaqcpnvzDzC4kuHua6C9u8UrquwIf93AC/mVXc0b55epsqSd8rnO3N6o9DNLiOWxRMAOyJmd0IXSrjXwIsm6c+rAP3ZqBS+bmIMAxMwb+V2wRnqW3WPdxGgA/O4JKv1Pk= 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 preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of virtio virtio_fs_setup_dax() to treat alloc_dax() -EOPNOTSUPP failure as non-fatal. Co-developed-by: Dan Williams Signed-off-by: Dan Williams Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev Reviewed-by: Lukas Wunner --- fs/fuse/virtio_fs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c index 5f1be1da92ce..f9acd9972af2 100644 --- a/fs/fuse/virtio_fs.c +++ b/fs/fuse/virtio_fs.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "fuse_i.h" @@ -795,8 +796,11 @@ static void virtio_fs_cleanup_dax(void *data) put_dax(dax_dev); } +DEFINE_FREE(cleanup_dax, struct dax_dev *, if (!IS_ERR(_T)) virtio_fs_cleanup_dax(_T)) + static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) { + struct dax_device *dax_dev __free(cleanup_dax) = ERR_PTR(-EOPNOTSUPP); struct virtio_shm_region cache_reg; struct dev_pagemap *pgmap; bool have_cache; @@ -804,6 +808,12 @@ static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) if (!IS_ENABLED(CONFIG_FUSE_DAX)) return 0; + dax_dev = alloc_dax(fs, &virtio_fs_dax_ops); + if (IS_ERR(dax_dev)) { + int rc = PTR_ERR(dax_dev); + return rc == -EOPNOTSUPP ? 0 : rc; + } + /* Get cache region */ have_cache = virtio_get_shm_region(vdev, &cache_reg, (u8)VIRTIO_FS_SHMCAP_ID_CACHE); @@ -849,10 +859,7 @@ static int virtio_fs_setup_dax(struct virtio_device *vdev, struct virtio_fs *fs) dev_dbg(&vdev->dev, "%s: window kaddr 0x%px phys_addr 0x%llx len 0x%llx\n", __func__, fs->window_kaddr, cache_reg.addr, cache_reg.len); - fs->dax_dev = alloc_dax(fs, &virtio_fs_dax_ops); - if (IS_ERR(fs->dax_dev)) - return PTR_ERR(fs->dax_dev); - + fs->dax_dev = no_free_ptr(dax_dev); return devm_add_action_or_reset(&vdev->dev, virtio_fs_cleanup_dax, fs->dax_dev); } From patchwork Mon Feb 12 16:30:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553524 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 BC6D5C4829C for ; Mon, 12 Feb 2024 16:31:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37F0E6B0096; Mon, 12 Feb 2024 11:31:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2442D6B0092; Mon, 12 Feb 2024 11:31:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 020236B0095; Mon, 12 Feb 2024 11:31:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D954C6B0092 for ; Mon, 12 Feb 2024 11:31:08 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 616EA80AA2 for ; Mon, 12 Feb 2024 16:31:08 +0000 (UTC) X-FDA: 81783691416.21.F448570 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf16.hostedemail.com (Postfix) with ESMTP id 8C5E218002A for ; Mon, 12 Feb 2024 16:31:06 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=rLOcpJh7; spf=pass (imf16.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755466; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OG/CzkI43SfX6xCzBBAMjDKIpbYgr3KZ11AqPANjUKI=; b=wE7NsvOjM/tF1c1d+U3cFvNLa7ZvkjQ9tdBq/wcukUaIp6dz/c9y3pScwA8CFI+9viZYhZ N5mbDAavm8Qt4ZxnXXeabyHqCIzsc31oNuvkOtBwelpOdKu/Oe0ehLJDTBM7iCGHlpEwsf yn8JyV/7B/uSxufy/kobnJWLQLkbdK8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755466; a=rsa-sha256; cv=none; b=nssTb8Nk+rjnifflroWr3D/o5AkK6A8ro7TJYYqnpZkXoQFV3m0TOidy7cBSQs6GVhOfCV d3h52lzObc3UXKeXfiGVV6x7AUDcxl1O8H8owaPTv4ZIBZ7Rqy//pEss4h4V1m6m1/5dzg 235lZzFSnGw/jeeuNs8chFiWhE0iK9w= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=rLOcpJh7; spf=pass (imf16.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755465; bh=+A5CzyStXl3uuRu7VAvAaofgyGw3Ro+0xr6rIKIjCf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLOcpJh7qO/ASHL139V8+yktYx350C1jag4/LXONT+oeciyPsY0S50AUxfn3outtW Xh6+rxFJ7PCvp1YZlzt3BkSPCuy7Bzv7ejY4+/GHqRIOzksRYekJ9021rmJ4tVOjlT fMzOrfv/DbKctqYPZc8HVJvCJICQiPvWcN7e2vXwINCfGELVEiIyugZesxu+iW5Szf 3YEzUrTP618zRw7omUXvFIeRYFvR3G2ZHanEbH0zYyAJNulpT/DpzbMYujk6pIp2hA pbbw9eZ9T0ROi7H5Up3L3SfWUYNKb1H9Pv899QDt9fF+O4PCRiNUmfYQZfbwf2fEac DHgPxu75pgj5w== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMF4gNTzYCX; Mon, 12 Feb 2024 11:31:05 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org Subject: [PATCH v5 6/8] dax: Check for data cache aliasing at runtime Date: Mon, 12 Feb 2024 11:30:59 -0500 Message-Id: <20240212163101.19614-7-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8C5E218002A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 3ohb1nfteh8js7f9nijnt89tx1rdphb7 X-HE-Tag: 1707755466-989300 X-HE-Meta: U2FsdGVkX19TSIUwfdnDrbreV/Wh+MtYG4IbVXJEvqyNb7w+noMOkZszjn+IFj0JMROxk82q6GmwNQvEm8PIelZ0eRya/33OcYmY2FYInlwpZF93vy5ydUXWcgTOKO07c04yltZHn+mM/SgVspdphJjvVsDDw611REFD3XdArLRaHf9p9Wx4e24SAoybxWkJQ7lf/FB/ag1SLY/6Hk0pPMGPgwIT51ntVgIDRbR0h+lkKOG+4DYR5cML+TmRvW169agnE0LOpZhA4Gkr6CxeDBH6JiwOn17VRVEQe57hbzh2MdgPjSVyoBjaY+DMx0Exgd0+31uTrCICFyqpjTdwSnqntP/x7n97mCwPMF6CTuM+Ff1n07y0Kdqv+pO78qeaRaMm8Xr+kNINi89SI4NWBv1zeCngSUDPpsaStyjFErDJzBdYrBtUqhvxSCjBSFD97ofqtXPUKGh5RGjmR/BTZRqR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4fHGhnKKXxekdnrzf 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: Replace the following fs/Kconfig:FS_DAX dependency: depends on !(ARM || MIPS || SPARC) By a runtime check within alloc_dax(). This runtime check returns ERR_PTR(-EOPNOTSUPP) if the @ops parameter is non-NULL (which means the kernel is using an aliased mapping) on an architecture which has data cache aliasing. Change the return value from NULL to PTR_ERR(-EOPNOTSUPP) for CONFIG_DAX=n for consistency. This is done in preparation for using cpu_dcache_is_aliasing() in a following change which will properly support architectures which detect data cache aliasing at runtime. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/dax/super.c | 10 ++++++++++ fs/Kconfig | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 205b888d45bf..ce5bffa86bba 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -450,6 +450,16 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) dev_t devt; int minor; + /* + * Unavailable on architectures with virtually aliased data caches, + * except for device-dax (NULL operations pointer), which does + * not use aliased mappings from the kernel. + */ + if (ops && (IS_ENABLED(CONFIG_ARM) || + IS_ENABLED(CONFIG_MIPS) || + IS_ENABLED(CONFIG_SPARC))) + return ERR_PTR(-EOPNOTSUPP); + if (WARN_ON_ONCE(ops && !ops->zero_page_range)) return ERR_PTR(-EINVAL); diff --git a/fs/Kconfig b/fs/Kconfig index 42837617a55b..e5efdb3b276b 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -56,7 +56,6 @@ endif # BLOCK config FS_DAX bool "File system based Direct Access (DAX) support" depends on MMU - depends on !(ARM || MIPS || SPARC) depends on ZONE_DEVICE || FS_DAX_LIMITED select FS_IOMAP select DAX From patchwork Mon Feb 12 16:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553525 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 44FDBC4829E for ; Mon, 12 Feb 2024 16:31:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66CA76B0092; Mon, 12 Feb 2024 11:31:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A16B6B008A; Mon, 12 Feb 2024 11:31:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 15F266B0093; Mon, 12 Feb 2024 11:31:09 -0500 (EST) 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 E46A96B008A for ; Mon, 12 Feb 2024 11:31:08 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id ACAAFA15C3 for ; Mon, 12 Feb 2024 16:31:08 +0000 (UTC) X-FDA: 81783691416.17.1431426 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf10.hostedemail.com (Postfix) with ESMTP id 1E1AEC0003 for ; Mon, 12 Feb 2024 16:31:06 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=AGwaJVA6; spf=pass (imf10.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755467; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b3aliyJPOObhqkmOR4T6hnfMq2lmmTNJLVfgfu2Sl68=; b=b8VwjlgAfGkaBc3d5M/NzyVi8nn4e7rbZeVmmPNThXgt8vycYeL0w1qHD0Q1kiIex95DGj 8fjvDs+uOAIo42USHQgz1MPaZ3697NYdrO4eP7IXMBzFkUz19QOFABXN7lYTclPlbgIzqW SoN1q5Fq7eaQxxLN2gJI/tA5Wmlvsjo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755467; a=rsa-sha256; cv=none; b=mvu6M3vz/n7lsfxQBtZcoZPuMwkjGATqEyBADIKEaXusxA/yHZN/c/ElW6fmDhkCXXySGl Oc/k8yyZQkAsM6NrcOhUaxX+H816L6zvlAFPA2ABAgL7ooSY9YpNDyTtKmsilVjwa5OFyE KH+HuzXYIVAX0UH/Uc9S0+uvNjZGoDg= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=AGwaJVA6; spf=pass (imf10.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com; dmarc=pass (policy=none) header.from=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755466; bh=yhcYPD4d/Sk8n4rn3QR3NdUtoL+Ae4/2ZbOPQLO15Yg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AGwaJVA6UVwwnGpAeIhHWKkqoHYAcoZGBGDDIaRQYb5Wyg5UFUyCZzZ/sSoAlcBCV oO9Wh0Gtv80D/czyQHqQ1gD10WXzlqH3Iftl3ELcc9m5XrVg6/3oT8WG189amDaNeH VP5nd/tmZmWS/vlCRxdtSHi4N2M282R+wnVSrE9+N5m9ah7mzrCxkGQ0M64TCBr2bp J0JGKHMwqtkljM41njmdaem6k3RfZWvLdHXvQIQkBZKdKqiZilV60G/R2lHc62eDXC v1yXba5SyVNyYh2b60ZMaf3QQ6O1JagcuhTmgoHtKHy8p9RwmCqcp+lgNGvp86nTTF P4muRigDsl7dA== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMG0QsczYFY; Mon, 12 Feb 2024 11:31:06 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org Subject: [PATCH v5 7/8] Introduce cpu_dcache_is_aliasing() across all architectures Date: Mon, 12 Feb 2024 11:31:00 -0500 Message-Id: <20240212163101.19614-8-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1E1AEC0003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: pbyn4ryso85a53km1wtb9adzuntn88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6ctgoA496xItv4nVA6ZCGATxqXqdTDxe1CqKdEB8rYE3oIfAfc8MG9g6GuhjB6sNvm8FzYw2p8zAMTaw4yvU7ie7UwzNSor6FhBXf3jgNVSPwgsNaeebcaakB/T49LeiZnFTeCdPu3P9pQNR6BppNrGDNF+yW7zaw2ubXjR7gDb+AnfCsNrde3l5AhUfnzbvmzIabY1RyRe2WHg3wfXyGPmWFjonInyFJ5VaOG+/TfM0I40PINtvj0RgJDG9w5pIL5Od/3ytSCr/9Q1AaGfSRUSxQqcgkFJmyBbZhYc+PvGqGA0bvGX/aR69QxzVfuNpdp+rFHbND7gb1flch2HHZ9n0IcmLAIcZk3+7kxe5HhDj2LfnQteUbDt8c/aMWzSx0sQZdJnTyWXaSyMdTM2H46oAI7AidtwGz1gESDibHUiigW+yy+WNzz8zKgARMw2F67TqwUPrw/daF9qCvlXovpp22LrpF4vKTgy0kedECPXo5NSzqj5ABAwmUDstjQ07a2FannUUJ6PR//m/9wXAw2bzBD2LHAXCRkXYP9x5MXIbGWURPjTIik14+DWNRZl5Flvprn108/yfrGZdT+jHvoewYw1Zdr4njen3sZBf4ryhkMBICzN8S62P7fim215/ebqI2HZX8gLb0LVrrICkVVOqri3DeRUXvTgY5xcj/tLnIqtG5mCMvmXQ8XmcOGFlk+sGeW5xGygjtneZDelOWPwOw5JP6PeeSCFOqe9cJ764tjl 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: Introduce a generic way to query whether the data cache is virtually aliased on all architectures. Its purpose is to ensure that subsystems which are incompatible with virtually aliased data caches (e.g. FS_DAX) can reliably query this. For data cache aliasing, there are three scenarios dependending on the architecture. Here is a breakdown based on my understanding: A) The data cache is always aliasing: * arc * csky * m68k (note: shared memory mappings are incoherent ? SHMLBA is missing there.) * sh * parisc B) The data cache aliasing is statically known or depends on querying CPU state at runtime: * arm (cache_is_vivt() || cache_is_vipt_aliasing()) * mips (cpu_has_dc_aliases) * nios2 (NIOS2_DCACHE_SIZE > PAGE_SIZE) * sparc32 (vac_cache_size > PAGE_SIZE) * sparc64 (L1DCACHE_SIZE > PAGE_SIZE) * xtensa (DCACHE_WAY_SIZE > PAGE_SIZE) C) The data cache is never aliasing: * alpha * arm64 (aarch64) * hexagon * loongarch (but with incoherent write buffers, which are disabled since commit d23b7795 ("LoongArch: Change SHMLBA from SZ_64K to PAGE_SIZE")) * microblaze * openrisc * powerpc * riscv * s390 * um * x86 Require architectures in A) and B) to select ARCH_HAS_CPU_CACHE_ALIASING and implement "cpu_dcache_is_aliasing()". Architectures in C) don't select ARCH_HAS_CPU_CACHE_ALIASING, and thus cpu_dcache_is_aliasing() simply evaluates to "false". Note that this leaves "cpu_icache_is_aliasing()" to be implemented as future work. This would be useful to gate features like XIP on architectures which have aliasing CPU dcache-icache but not CPU dcache-dcache. Use "cpu_dcache" and "cpu_cache" rather than just "dcache" and "cache" to clarify that we really mean "CPU data cache" and "CPU cache" to eliminate any possible confusion with VFS "dentry cache" and "page cache". Link: https://lore.kernel.org/lkml/20030910210416.GA24258@mail.jlokier.co.uk/ Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- arch/arc/Kconfig | 1 + arch/arc/include/asm/cachetype.h | 9 +++++++++ arch/arm/Kconfig | 1 + arch/arm/include/asm/cachetype.h | 2 ++ arch/csky/Kconfig | 1 + arch/csky/include/asm/cachetype.h | 9 +++++++++ arch/m68k/Kconfig | 1 + arch/m68k/include/asm/cachetype.h | 9 +++++++++ arch/mips/Kconfig | 1 + arch/mips/include/asm/cachetype.h | 9 +++++++++ arch/nios2/Kconfig | 1 + arch/nios2/include/asm/cachetype.h | 10 ++++++++++ arch/parisc/Kconfig | 1 + arch/parisc/include/asm/cachetype.h | 9 +++++++++ arch/sh/Kconfig | 1 + arch/sh/include/asm/cachetype.h | 9 +++++++++ arch/sparc/Kconfig | 1 + arch/sparc/include/asm/cachetype.h | 14 ++++++++++++++ arch/xtensa/Kconfig | 1 + arch/xtensa/include/asm/cachetype.h | 10 ++++++++++ include/linux/cacheinfo.h | 6 ++++++ mm/Kconfig | 6 ++++++ 22 files changed, 112 insertions(+) create mode 100644 arch/arc/include/asm/cachetype.h create mode 100644 arch/csky/include/asm/cachetype.h create mode 100644 arch/m68k/include/asm/cachetype.h create mode 100644 arch/mips/include/asm/cachetype.h create mode 100644 arch/nios2/include/asm/cachetype.h create mode 100644 arch/parisc/include/asm/cachetype.h create mode 100644 arch/sh/include/asm/cachetype.h create mode 100644 arch/sparc/include/asm/cachetype.h create mode 100644 arch/xtensa/include/asm/cachetype.h diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 1b0483c51cc1..7d294a3242a4 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -6,6 +6,7 @@ config ARC def_bool y select ARC_TIMERS + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_CACHE_LINE_SIZE select ARCH_HAS_DEBUG_VM_PGTABLE select ARCH_HAS_DMA_PREP_COHERENT diff --git a/arch/arc/include/asm/cachetype.h b/arch/arc/include/asm/cachetype.h new file mode 100644 index 000000000000..05fc7ed59712 --- /dev/null +++ b/arch/arc/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_ARC_CACHETYPE_H +#define __ASM_ARC_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() true + +#endif diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index f8567e95f98b..cd13b1788973 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -5,6 +5,7 @@ config ARM select ARCH_32BIT_OFF_T select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE if HAVE_KRETPROBES && FRAME_POINTER && !ARM_UNWIND select ARCH_HAS_BINFMT_FLAT + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_CPU_FINALIZE_INIT if MMU select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VIRTUAL if MMU diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h index e8c30430be33..b9dbe1d4c8fe 100644 --- a/arch/arm/include/asm/cachetype.h +++ b/arch/arm/include/asm/cachetype.h @@ -20,6 +20,8 @@ extern unsigned int cacheid; #define icache_is_vipt_aliasing() cacheid_is(CACHEID_VIPT_I_ALIASING) #define icache_is_pipt() cacheid_is(CACHEID_PIPT) +#define cpu_dcache_is_aliasing() (cache_is_vivt() || cache_is_vipt_aliasing()) + /* * __LINUX_ARM_ARCH__ is the minimum supported CPU architecture * Mask out support which will never be present on newer CPUs. diff --git a/arch/csky/Kconfig b/arch/csky/Kconfig index cf2a6fd7dff8..8a91eccf76dc 100644 --- a/arch/csky/Kconfig +++ b/arch/csky/Kconfig @@ -2,6 +2,7 @@ config CSKY def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_SYNC_DMA_FOR_CPU diff --git a/arch/csky/include/asm/cachetype.h b/arch/csky/include/asm/cachetype.h new file mode 100644 index 000000000000..98cbe3af662f --- /dev/null +++ b/arch/csky/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_CSKY_CACHETYPE_H +#define __ASM_CSKY_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() true + +#endif diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 4b3e93cac723..a9c3e3de0c6d 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -3,6 +3,7 @@ config M68K bool default y select ARCH_32BIT_OFF_T + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_BINFMT_FLAT select ARCH_HAS_CPU_FINALIZE_INIT if MMU select ARCH_HAS_CURRENT_STACK_POINTER diff --git a/arch/m68k/include/asm/cachetype.h b/arch/m68k/include/asm/cachetype.h new file mode 100644 index 000000000000..7fad5d9ab8fe --- /dev/null +++ b/arch/m68k/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_M68K_CACHETYPE_H +#define __ASM_M68K_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() true + +#endif diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 797ae590ebdb..ab1c8bd96666 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -4,6 +4,7 @@ config MIPS default y select ARCH_32BIT_OFF_T if !64BIT select ARCH_BINFMT_ELF_STATE if MIPS_FP_SUPPORT + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_CPU_FINALIZE_INIT select ARCH_HAS_CURRENT_STACK_POINTER if !CC_IS_CLANG || CLANG_VERSION >= 140000 select ARCH_HAS_DEBUG_VIRTUAL if !64BIT diff --git a/arch/mips/include/asm/cachetype.h b/arch/mips/include/asm/cachetype.h new file mode 100644 index 000000000000..9f4ba2fe1155 --- /dev/null +++ b/arch/mips/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_MIPS_CACHETYPE_H +#define __ASM_MIPS_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() cpu_has_dc_aliases + +#endif diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig index d54464021a61..760fb541ecd2 100644 --- a/arch/nios2/Kconfig +++ b/arch/nios2/Kconfig @@ -2,6 +2,7 @@ config NIOS2 def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE diff --git a/arch/nios2/include/asm/cachetype.h b/arch/nios2/include/asm/cachetype.h new file mode 100644 index 000000000000..eb9c416b8a1c --- /dev/null +++ b/arch/nios2/include/asm/cachetype.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_NIOS2_CACHETYPE_H +#define __ASM_NIOS2_CACHETYPE_H + +#include +#include + +#define cpu_dcache_is_aliasing() (NIOS2_DCACHE_SIZE > PAGE_SIZE) + +#endif diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index d14ccc948a29..0f25c227f74b 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -8,6 +8,7 @@ config PARISC select HAVE_FUNCTION_GRAPH_TRACER select HAVE_SYSCALL_TRACEPOINTS select ARCH_WANT_FRAME_POINTERS + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_DMA_ALLOC if PA11 select ARCH_HAS_ELF_RANDOMIZE select ARCH_HAS_STRICT_KERNEL_RWX diff --git a/arch/parisc/include/asm/cachetype.h b/arch/parisc/include/asm/cachetype.h new file mode 100644 index 000000000000..e0868a1d3c47 --- /dev/null +++ b/arch/parisc/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_PARISC_CACHETYPE_H +#define __ASM_PARISC_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() true + +#endif diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index 7500521b2b98..2ad3e29f0ebe 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -2,6 +2,7 @@ config SUPERH def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_ENABLE_MEMORY_HOTPLUG if SPARSEMEM && MMU select ARCH_ENABLE_MEMORY_HOTREMOVE if SPARSEMEM && MMU select ARCH_HAVE_NMI_SAFE_CMPXCHG if (GUSA_RB || CPU_SH4A) diff --git a/arch/sh/include/asm/cachetype.h b/arch/sh/include/asm/cachetype.h new file mode 100644 index 000000000000..a5fffe536068 --- /dev/null +++ b/arch/sh/include/asm/cachetype.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_SH_CACHETYPE_H +#define __ASM_SH_CACHETYPE_H + +#include + +#define cpu_dcache_is_aliasing() true + +#endif diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 49849790e66d..5ba627da15d7 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -13,6 +13,7 @@ config 64BIT config SPARC bool default y + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI select ARCH_MIGHT_HAVE_PC_SERIO select DMA_OPS diff --git a/arch/sparc/include/asm/cachetype.h b/arch/sparc/include/asm/cachetype.h new file mode 100644 index 000000000000..caf1c0045892 --- /dev/null +++ b/arch/sparc/include/asm/cachetype.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_SPARC_CACHETYPE_H +#define __ASM_SPARC_CACHETYPE_H + +#include + +#ifdef CONFIG_SPARC32 +extern int vac_cache_size; +#define cpu_dcache_is_aliasing() (vac_cache_size > PAGE_SIZE) +#else +#define cpu_dcache_is_aliasing() (L1DCACHE_SIZE > PAGE_SIZE) +#endif + +#endif diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 7d792077e5fd..2dfde54d1a84 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -2,6 +2,7 @@ config XTENSA def_bool y select ARCH_32BIT_OFF_T + select ARCH_HAS_CPU_CACHE_ALIASING select ARCH_HAS_BINFMT_FLAT if !MMU select ARCH_HAS_CURRENT_STACK_POINTER select ARCH_HAS_DEBUG_VM_PGTABLE diff --git a/arch/xtensa/include/asm/cachetype.h b/arch/xtensa/include/asm/cachetype.h new file mode 100644 index 000000000000..51bd49e2a1c5 --- /dev/null +++ b/arch/xtensa/include/asm/cachetype.h @@ -0,0 +1,10 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_XTENSA_CACHETYPE_H +#define __ASM_XTENSA_CACHETYPE_H + +#include +#include + +#define cpu_dcache_is_aliasing() (DCACHE_WAY_SIZE > PAGE_SIZE) + +#endif diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h index d504eb4b49ab..2cb15fe4fe12 100644 --- a/include/linux/cacheinfo.h +++ b/include/linux/cacheinfo.h @@ -138,4 +138,10 @@ static inline int get_cpu_cacheinfo_id(int cpu, int level) #define use_arch_cache_info() (false) #endif +#ifndef CONFIG_ARCH_HAS_CPU_CACHE_ALIASING +#define cpu_dcache_is_aliasing() false +#else +#include +#endif + #endif /* _LINUX_CACHEINFO_H */ diff --git a/mm/Kconfig b/mm/Kconfig index 57cd378c73d6..db09c9ad15c9 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -1016,6 +1016,12 @@ config IDLE_PAGE_TRACKING See Documentation/admin-guide/mm/idle_page_tracking.rst for more details. +# Architectures which implement cpu_dcache_is_aliasing() to query +# whether the data caches are aliased (VIVT or VIPT with dcache +# aliasing) need to select this. +config ARCH_HAS_CPU_CACHE_ALIASING + bool + config ARCH_HAS_CACHE_LINE_SIZE bool From patchwork Mon Feb 12 16:31:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553526 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 76DADC4829C for ; Mon, 12 Feb 2024 16:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE1EA6B008A; Mon, 12 Feb 2024 11:31:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B6A716B0093; Mon, 12 Feb 2024 11:31:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99D096B0095; Mon, 12 Feb 2024 11:31:09 -0500 (EST) 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 64E026B0093 for ; Mon, 12 Feb 2024 11:31:09 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3619D160ADF for ; Mon, 12 Feb 2024 16:31:09 +0000 (UTC) X-FDA: 81783691458.16.D073B50 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf04.hostedemail.com (Postfix) with ESMTP id 7181040024 for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=LZvaBdNs; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf04.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1707755467; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UPDJkdwf3N1VcCYbcUnUgFJY3X3oR+UFxWlZudqMVIo=; b=lehfEnoRuiC4gSS4E+Ev/kEKFN4iJGWdQnsB/6oH01tbGxTksqwk9MT0pICFlazTBIb/em sWRKLI6AEJZ+im3SoW3m12Qo5nbm4cJK2XmpDX+l7/ljUlvb7PF8+t8yKmAsDADVk8amtm Xdu7+MORrHVU7LPWaOb/UxpMf8/Mb+k= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=LZvaBdNs; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf04.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707755467; a=rsa-sha256; cv=none; b=Gw2HdFavTGREDEcfMtRXdhOcp1a5ifUWZRqOF0cVJ7+YOtYtrhu8fKsXrw/EehQJeG8tL4 UBTBwLse5qtoPmXvzUX814q7B5pU0+fkbW8KIbtLOO+O2fvjwRipSg9QaKGj1k5l4q5h8b q340VISBULt+IOwfaiSnq9vDAfYcKWY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755466; bh=5LHEXykJS2jSVE2sCzHC5a4cdCFsRj5a/HPr77qf3tA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LZvaBdNsLGQIy+aXABay82sJ+rFu8g6aaxGiW9uZpN66wS+NuUa7/G4W8gITWGkpa c1867KsbQxo2upSD+YIPCfUlDoy+ZG15o0o8gSLcOMEAKGWPn4/raakjLJgZ3QmgQl dI/PQmPe4eKxi8t0eZ/GmWxeVm048ci7sExiS4Ecjb68SKCeD0b3y7maiMIye3wJ45 DGGcrFkvDB/kNDA8WnFjK3mwIrvjK66KtDZL/O72RsTS0jcPJStuMuyH5yBjbq3tTG J7m2qben0XtmlSJAe4Yq0LSiYgiDICl058dbEz5NMMLhFPozAslNYp17M9pnVILYBE OPYVUdNaYbjGA== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TYVMG3My8zYFZ; Mon, 12 Feb 2024 11:31:06 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org Subject: [PATCH v5 8/8] dax: Fix incorrect list of data cache aliasing architectures Date: Mon, 12 Feb 2024 11:31:01 -0500 Message-Id: <20240212163101.19614-9-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: b4on6nzemwt8d1kx53hjnzw1f13imxya X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7181040024 X-HE-Tag: 1707755467-685142 X-HE-Meta: U2FsdGVkX1+XxnH+QZ6awkgklZAKavAMSx2msFjWUW/MF/eF6tTryazEzUS5xOrSC27RwdzpuS4+E1xVWRwmOwnwh/3I181q1kkErY7Ggc4dedKCS4sh5RMMDMXbslpUx8wSQU8qCSpNa4ZF7pA951LmF8kiEADnwynWvwj+GiPAQZffTKoBZETc+QJOLeQ1qIy8wXHJnFN+Hmcc+EsyzTfF+FMJxTSpuGtqPDfZTPOeGqerTM0NXieY0VW11QF9JoXUsPJaisqlfpNqBXpCI6KveIyEyZrthFiXCl5vEVCVSFy8AVUVWDW6O/k0GWosdiDu9uMTyqkj4Adra1PHdu1UosTheJwzfPsw3i/27I6+ldXVwRui45H17TnoLxFKsEMeVbBk0eJ7uk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Bv1wSYpUw7bnhRHtxNbZxj23i4EBSZmUcOszdj53Jo1Xk7VOJmZ4/pAu/iZAnawRkPQdNq9up9LHJYjr0VY/nLHVIg+3+gsyJi8B1HWLwc 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 d92576f1167c ("dax: does not work correctly with virtual aliasing caches") prevents DAX from building on architectures with virtually aliased dcache with: depends on !(ARM || MIPS || SPARC) This check is too broad (e.g. recent ARMv7 don't have virtually aliased dcaches), and also misses many other architectures with virtually aliased data cache. This is a regression introduced in the v4.0 Linux kernel where the dax mount option is removed for 32-bit ARMv7 boards which have no data cache aliasing, and therefore should work fine with FS_DAX. This was turned into the following check in alloc_dax() by a preparatory change: if (ops && (IS_ENABLED(CONFIG_ARM) || IS_ENABLED(CONFIG_MIPS) || IS_ENABLED(CONFIG_SPARC))) return NULL; Use cpu_dcache_is_aliasing() instead to figure out whether the environment has aliasing data caches. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/dax/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index ce5bffa86bba..a21a7c262382 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "dax-private.h" /** @@ -455,9 +456,7 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) * except for device-dax (NULL operations pointer), which does * not use aliased mappings from the kernel. */ - if (ops && (IS_ENABLED(CONFIG_ARM) || - IS_ENABLED(CONFIG_MIPS) || - IS_ENABLED(CONFIG_SPARC))) + if (ops && cpu_dcache_is_aliasing()) return ERR_PTR(-EOPNOTSUPP); if (WARN_ON_ONCE(ops && !ops->zero_page_range))