From patchwork Wed Jan 31 16:25:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13539642 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 DF25BC47DB3 for ; Wed, 31 Jan 2024 16:25:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 750426B007B; Wed, 31 Jan 2024 11:25:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 725506B007D; Wed, 31 Jan 2024 11:25:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5ED578D0001; Wed, 31 Jan 2024 11:25:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4F9546B007B for ; Wed, 31 Jan 2024 11:25:51 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1EFB940C0C for ; Wed, 31 Jan 2024 16:25:51 +0000 (UTC) X-FDA: 81740132502.25.2DAE774 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf11.hostedemail.com (Postfix) with ESMTP id 584AE4001F for ; Wed, 31 Jan 2024 16:25:49 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=HmNK3iFb; spf=pass (imf11.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=1706718349; 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=vDMEIlaXV1JqzGpgoWw8dC9HGSvE1FDz17DTEfT2oiw=; b=WkYy7Ruh7+0lPnyFWqdE/0i/w4ChYHc/u8U2cosAcPMMdR9zfBx8qkwFyw4gSV+qF87nvv epaNnl4uKVw9zwE55r/imGCgU+d9tpsHBC7u8R0TBo/jv/Pl2zy6Zd4jESlP7d7Zy0giEH sOrnqRBRQJkRLGFCPvP7HAGw4apC/qU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706718349; a=rsa-sha256; cv=none; b=1J3vlCVhO8sNVxgKjGrY8tsXhBfbFZAzcvKUOTxPGVAZ/7WTnvyzdqN+sIpIjUNGJu3mgq dZcvblWzC2uxNoL9tImvIR5Zu7saBr1jCPUh6FW43oSjD9og14yOwA6pj/z2jXfd1umwQv vlodDMxxCu07ay8+L2X1ex/Plgaemuw= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=HmNK3iFb; spf=pass (imf11.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=1706718348; bh=SE0hCaz/UCatOaT7XYyPZfO37Tgvrd//zPyFSuYAShc=; h=From:To:Cc:Subject:Date:From; b=HmNK3iFbnhZ9uL2TsXya0QhLbmSWEGjkJSAhi50JkcA/esMo4ok2j9htp8X63zx+3 YqkVXrI1HPbrOhhdVDzMjoU+x/vBXioLiikodDuerLU8hYerKMjK12GpnZQQKx2dIK L9/PQ8Ow7DDL5mpxEYgJZq+9R7nXjAh7zCI1d4HlgcTr6mO03xXFUXvz9fKWcXsq/H Au5igpoBzSDtsK4XyEvvoxS1HvP8w4HZ7JFdZf1sGkav8IhtCEyTWvzuI/PRST8W6V XFJgrOB403KnY8sPWsjROZeDcwm1lpJ+JTVC3WCsx4ZsRpmSIuwLbvlGzuawNM7eqP b9cb01C+1Y2jQ== 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 4TQ6pg5GkFzVnw; Wed, 31 Jan 2024 11:25:47 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arch@vger.kernel.org, Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev, linux-fsdevel@vger.kernel.org, dm-devel@lists.linux.dev Subject: [RFC PATCH v3 0/4] Introduce cpu_dcache_is_aliasing() to fix DAX regression Date: Wed, 31 Jan 2024 11:25:29 -0500 Message-Id: <20240131162533.247710-1-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 584AE4001F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 564r6qo51rwgempw48roejwmt1zmn3cr X-HE-Tag: 1706718349-162594 X-HE-Meta: U2FsdGVkX18si4yBaCwLvnjCfVXnqecLtR8jOG/RBhjXj3dbBHr6N0ytMuJ7w/b/UR7qBWoNyn0qLnekGlFo+HtHnBsfxVyGglYKajGtH4Y8/1hcGE4q3/MRxGVKUOm1O/K6NbDVje8IsRaoKbqhA/Jxxo3ChMu/px497RfnMxhAt3AmqG4fOF1tLIMUjvOuOFPkd924C46PpxJ8GNfRDRrq5Y3fnAjmfEOxH5vkROewjFMGckxvlacmx/FD3VFxrE9fTqlSRP5jmcgFB4wf/jnUj1UHpPcN1ilyN86gXSz3Ac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HitlpUQADE4RN4+ILiZFUuMOur8nu+2eYWFcgrWwl0GpeFzVUFYsLstc+hmVEHjXQZWQgc3myy/UrXzthZYfuRlrZUfv2zq7FETBbMSOAprFlARtp/3fWLhB7+GnwHD1reQuOO84pqL8t0h7kSJLOhTTXItMhGhAdm1JUcAuqk8R1dUnALvO0leiO90x8dfg8FRD6MZg== 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 v5.13 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. Feedback is welcome, Thanks, Mathieu 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: linux-mm@kvack.org Cc: linux-arch@vger.kernel.org Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-cxl@vger.kernel.org Cc: nvdimm@lists.linux.dev Cc: linux-fsdevel@vger.kernel.org Cc: dm-devel@lists.linux.dev Mathieu Desnoyers (4): dm: Treat alloc_dax 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 | 5 +++++ drivers/md/dm.c | 10 +++++----- fs/Kconfig | 1 - include/linux/cacheinfo.h | 6 ++++++ mm/Kconfig | 6 ++++++ 25 files changed, 122 insertions(+), 6 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