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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sPT3HiWDMAlyqSBEguxY5is8C9BAN0pRMmmQwFQhLecvyUIcw43Q0xB4RylyQB6y7jXJDURGg4ll5FPeQZ50p6pUJ8+u7Rp6rwlLxXry/bnW91m5iLU3dnERC3njKBNj0aZz+RPUoUO/vBb7De35sWuJu1on+QPOjHR7U305j6IJb24USb6cfSGYV1Bjah8JOJPm8EdGg7mMCGTj6Ze/KvvHSA8QpggcKb0+05xKjKy9lfmebCcnZDzZEiTcDeSAMP0iY3UxgB6I4fHGhnKKXxekdnrzf 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