From patchwork Fri Feb 2 21:00:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13543402 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 3462AC4828E for ; Fri, 2 Feb 2024 21:00:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8F866B0085; Fri, 2 Feb 2024 16:00:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A51436B0087; Fri, 2 Feb 2024 16:00:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CA8D6B0089; Fri, 2 Feb 2024 16:00:31 -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 759A56B0085 for ; Fri, 2 Feb 2024 16:00:31 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 158B8A018B for ; Fri, 2 Feb 2024 21:00:31 +0000 (UTC) X-FDA: 81748082262.12.C061232 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf05.hostedemail.com (Postfix) with ESMTP id 01A7C10002B for ; Fri, 2 Feb 2024 21:00:27 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=xjzjRcKH; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf05.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=1706907629; 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=Xb3erqMWSlU/uH22k2GyEoN6ppCyyVr+MTT7Aq5Ittc=; b=M7vwBbiTgJ7JjQjp06NfQ+WX4bxRBPqNFtxR/CGk11tBbJE7/C/CN5U5lN/M72vz43AkgQ IcFNzA/PXxQyoGkMjQSz3ScrfqsX+iTVae7Q7/CpCMiuVCZEMhe00WRwvFhYoLogA8qbGn erSMn5e5bw6lxucKIBw4hPlTjrsoxpA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=xjzjRcKH; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf05.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=1706907629; a=rsa-sha256; cv=none; b=ZaV62lNVHb5SWbS4+iWJO+K+TWXxtBR1cbncZZS/SwQJYHkP3GhrIjb3ME1oAmgC9dJNZ+ gXcP3vrdnv/0SWFBRz2spZROZgWQjQQsmC2ZjqALupOrl9CAXLgE01Y+NYfiNzTty4r+lQ xehciDGmjQ01koZDtGgo8nLIzageo4U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1706907626; bh=7Ochv10fF/HDECdDCBhY5k3B/jWscDOgrt50maoZBSM=; h=From:To:Cc:Subject:Date:From; b=xjzjRcKHc51L5uKfgoLW2u8kKhQcQ2vVNWK/MJWjdE614MR4/YJkA1CwTEe73bbQQ B9HyfCDUh7U0ymCixBQN8EiJgzkpW6+kLC9IvSas607tEiAr6kadxi+bJn5RUzSABk nWHeEMWr/PgG+1BneAGKshZDLvngXgGNtmQ6U1dg9VAFgDpd/MAq57ojIIddXMTqyj B6Zo1w7TxPuHLYzrtCkp62x4HF5uLit0wQ/pQraJaWYxXOvP89GmSYmoePEO47U+zj C6bZ1Xg/IaMryfb+SACk6Vlr4te2Eu6M6BU4Oph1tlIewmiv0Nre/GFkq9H57Fehoq A1W/ENWhVIuAA== 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 4TRSpf4VlxzX6l; Fri, 2 Feb 2024 16:00:26 -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: [RFC PATCH v4 00/12] Introduce cpu_dcache_is_aliasing() to fix DAX regression Date: Fri, 2 Feb 2024 16:00:07 -0500 Message-Id: <20240202210019.88022-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 01A7C10002B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: owektqsqkpq3imje4dzze43rdgw7huh1 X-HE-Tag: 1706907627-690234 X-HE-Meta: U2FsdGVkX1+BwviFjlzR8PMTpqVIMAI4AaocG9LEahDZ8FP8QX4657F0els4D4ajKjtzCg+D8eUe5gcYby48ToK13Bycya/u8w96vBeUpUKx+dnPRhPnOEpx9hsUvjuL6pYNT9rrQKptE5qdCqnuCAEr/Cdsjo92I0+endopX42DKH/3QrJ3oF8KlB5oBrpeQe4/i16xYcPnL4VRq6f7NOmjitbJgmkDmrgUWfUH6sIRCaofVBJhB9TeuU2bCNSkavYwP1hvzxTOjAUtgdZYwdFczO7J3ft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1XAhG0lgrSMeWoydN9F5DD4x39NEo7K2tVt6W1lokbr1IV2vQ0M8U5WR979SBKycwNdjlJntZraRMsA5n+tZb2GycOwZhPtXUJkta9dOAZeGm7IfUds4BS6GFO1CmtntJBSmHw6eN3mjdLmyQXejECufyNfudycPX/8lTMpawR8bhohICJ9MHpm/w== 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") It used to work fine before: I have customers using DAX over pmem on ARMv7, but this regression will likely prevent them from upgrading their kernel. 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. Thanks, Mathieu 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 (12): nvdimm/pmem: Fix leak on dax_add_host() failure 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 nvdimm/pmem: Cleanup alloc_dax() error handling dm: Cleanup alloc_dax() error handling dcssblk: Cleanup alloc_dax() error handling virtio: Cleanup alloc_dax() error handling 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 | 23 ++++++++++++----------- drivers/s390/block/dcssblk.c | 11 ++++++----- fs/Kconfig | 1 - fs/fuse/virtio_fs.c | 15 +++++++++++---- include/linux/cacheinfo.h | 6 ++++++ include/linux/dax.h | 6 +----- mm/Kconfig | 6 ++++++ 29 files changed, 165 insertions(+), 34 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