From patchwork Thu Feb 15 14:46:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13558530 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 A02DDC48BC4 for ; Thu, 15 Feb 2024 14:46:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CB308D000E; Thu, 15 Feb 2024 09:46:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1550C8D0001; Thu, 15 Feb 2024 09:46:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01BB98D000E; Thu, 15 Feb 2024 09:46:41 -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 E289B8D0001 for ; Thu, 15 Feb 2024 09:46:41 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 99F541209CF for ; Thu, 15 Feb 2024 14:46:41 +0000 (UTC) X-FDA: 81794314602.20.BDE4275 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf12.hostedemail.com (Postfix) with ESMTP id 30CFF40019 for ; Thu, 15 Feb 2024 14:46:40 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=rJZq31HQ; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf12.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=1708008400; 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:references:dkim-signature; bh=NRyDxxUK7htZuXBg4D2HfgqFHdoLszPFN7YE3ESVjCQ=; b=JBIAzWAZaEHdxE5RkBkZb1IX7G4ccd/KiCVpDAMvASiLelJylfyVvH/P0RAElgOfaHaP/P hJrQorm7yIsviaYu+1LGIY3ps9bT/RSEuRWYPqnfU+kwb3r/k9eS/3yCVyjit83VBex+rE kbEGZbOeJjDcJHYKrD8Tca2JtibWYnw= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=rJZq31HQ; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf12.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=1708008400; a=rsa-sha256; cv=none; b=ro8xSq75bVuuE+MmyTiZZTaFYfOqc3VNbLpzdVwc1l5KmtdFoZgKW/Kj5R92QTZM7eBj/A e6wmwbxsc/q9XTxPQTf4/j1ULmHA8V7X2ugMk0dDEZFC5D48xPuXRdE/of9LjYpxvjgH35 4JbDOsrmx3cZSj3xU/+itjJR7iRO4AE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708008399; bh=uO/a16VysXWo1w2+bfHaMs5Vbc5IRLwd9tG3amhoOoc=; h=From:To:Cc:Subject:Date:From; b=rJZq31HQ6E9MSIwZieDHjqM5aMeRR4fnCM4GGX5QWavUJQDO6RcqRTXTcM6aqk0/N F2Iz+PHw4DmB5AGTUaiGtbTABC9Pxh0A/mK0zhmdlcIiu1C5TVIbLzz8e96bZR0fTv gGtn9tzlPljPnURlXOtVjCgGl2j1oiW+6dcBkJVHaKpGGHkFU99uhymAZWuvF95B/W BRR0WU//KLCg5CFvG9UPwW+onLIuWhuUWPzcCRN9ELwvoW/ReoCGrzJfc6Qf9niGvo oqga+V4lIhwSVlLTeWIpII7Ge6ECtKLt0m4SWLPsqSmepQQLNwmJTHncSEnf9HFxd9 KSHgaxpty5EqA== 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 4TbHvL69X4zZKk; Thu, 15 Feb 2024 09:46:38 -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 v6 0/9] Introduce cpu_dcache_is_aliasing() to fix DAX regression Date: Thu, 15 Feb 2024 09:46:24 -0500 Message-Id: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 30CFF40019 X-Stat-Signature: c1sd3smr9hweuhyer5awa5usjtq5kkpf X-Rspam-User: X-HE-Tag: 1708008400-482692 X-HE-Meta: U2FsdGVkX1/rNaFM9svTpulDsX8NqqU2yH72FrcPff5EflMSYNez78zh9WvVos8F5yjZ7N5N8JKtfExtf4bRUu/f6JH4YOwK5/lJrUD3oZ/TGYzWnMfCAiZHPsSKG1iv8C+AQoJXANRasV2smT8CK9G5WCKYVR2cXIRDtJXl/z7XbhNlU31WRh8bQuFGFI5bH3mWMXsm+vkojYeI+YXbNZ8q3aKTXqyaa7BI9J+rULiaCZrYGGU7QCh+v+MeEWzsR24QBU+JVN/8+TtC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frjYz7GGNqwaxKJ1JOs85skD7SzCOI6AnIXwXVGfp/lfdpgEGIRMS8T4iOHUfDB3wtRqGqXICfz1I1FdrHU9Fvunj9pMYTdMaO8iyUsKQc4yXzmgezdYgMFudpgSLtCmnbjG9OqbLpkXMYKDrBI6ekxwK2g5ixhc97mTOhjbQOArczem7vgbvlh2iT6HkEZMCaDVAUc4MEl3KURLCsaA== 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: This commit introduced in v4.0 prevents building FS_DAX on 32-bit ARM, even on ARMv7 which does not have virtually aliased data caches: commit d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Even though it used to work fine before. The root of the issue here is the fact that DAX was never designed to handle virtually aliasing data caches (VIVT and VIPT with aliasing data cache). It touches the pages through their linear mapping, which is not consistent with the userspace mappings with virtually aliasing data caches. This patch series introduces cpu_dcache_is_aliasing() with the new Kconfig option ARCH_HAS_CPU_CACHE_ALIASING and implements it for all architectures. The implementation of cpu_dcache_is_aliasing() is either evaluated to a constant at compile-time or a runtime check, which is what is needed on ARM. With this we can basically narrow down the list of architectures which are unsupported by DAX to those which are really affected. Testing done so far: - Compile allyesconfig on x86-64, - Compile allyesconfig on x86-64, with FS_DAX=n. - Compile allyesconfig on x86-64, with DAX=n. - Boot test after modifying alloc_dax() to force returning -EOPNOTSUPP even on x86-64, thus simulating the behavior expected on an architecture with data cache aliasing. There are many more axes to test however. I would welcome Tested-by for: - affected architectures, - affected drivers, - affected filesytems. [ Based on commit "nvdimm/pmem: Fix leak on dax_add_host() failure". ] Thanks, Mathieu Changes since v5: - Add empty static inline set_dax_nocache() and set_dax_nomc() for CONFIG_DAX=n. - Update "Fixes" tag for "dax: alloc_dax() return ERR_PTR(-EOPNOTSUPP) for CONFIG_DAX=n". - Check IS_ERR_OR_NULL() before calling virtio_fs_cleanup_dax() within virtio_fs_setup_dax(). Changes since v4: - Move the change which makes alloc_dax() return ERR_PTR(-EOPNOTSUPP) when CONFIG_DAX=n earlier in the series, - Fold driver cleanup patches into their respective per-driver changes. - Move "nvdimm/pmem: Fix leak on dax_add_host() failure" outside of this series. Changes since v3: - Fix a leak on dax_add_host() failure in nvdimm/pmem. - Split the series into a bissectable sequence of changes. - Ensure that device-dax use-cases still works on data cache aliasing architectures. Changes since v2: - Move DAX supported runtime check to alloc_dax(), - Modify DM to handle alloc_dax() error as non-fatal, - Remove all filesystem modifications, since the check is now done by alloc_dax(), - rename "dcache" and "cache" to "cpu dcache" and "cpu cache" to eliminate confusion with VFS terminology. Changes since v1: - The order of the series was completely changed based on the feedback received on v1, - cache_is_aliasing() is renamed to dcache_is_aliasing(), - ARCH_HAS_CACHE_ALIASING_DYNAMIC is gone, - dcache_is_aliasing() vs ARCH_HAS_CACHE_ALIASING relationship is simplified, - the dax_is_supported() check was moved to its rightful place in all filesystems. Cc: Andrew Morton Cc: Linus Torvalds Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox 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 Mathieu Desnoyers (9): dax: add empty static inline for CONFIG_DAX=n dax: alloc_dax() return ERR_PTR(-EOPNOTSUPP) for CONFIG_DAX=n nvdimm/pmem: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal dm: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal dcssblk: Handle alloc_dax() -EOPNOTSUPP failure virtio: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal dax: Check for data cache aliasing at runtime Introduce cpu_dcache_is_aliasing() across all architectures dax: Fix incorrect list of data cache aliasing architectures 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 ++++++++++ drivers/dax/super.c | 14 ++++++++++++++ drivers/md/dm.c | 17 +++++++++-------- drivers/nvdimm/pmem.c | 22 ++++++++++++---------- drivers/s390/block/dcssblk.c | 11 ++++++----- fs/Kconfig | 1 - fs/fuse/virtio_fs.c | 15 +++++++++++---- include/linux/cacheinfo.h | 6 ++++++ include/linux/dax.h | 17 +++++++++-------- mm/Kconfig | 6 ++++++ 29 files changed, 173 insertions(+), 36 deletions(-) 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