From patchwork Thu Feb 15 14:46:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 201508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp450467dyb; Thu, 15 Feb 2024 06:51:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6LdY3Yv+ixeucd1zhRZkWUX5IfYm05/zMi5AGVuTBFQ5SWpS3fmNkP3fHEw6Q0fjA94QU0mUU07VWjF8z3NdOr3dxSQ== X-Google-Smtp-Source: AGHT+IHicU+tdSzyv9s9IQYOXq/xsCeGEGQ2jJ3iN87YqndNc1A9niAEKwfF4InEpkzpGEdVb4rY X-Received: by 2002:a05:6a00:2d27:b0:6e0:a858:fd74 with SMTP id fa39-20020a056a002d2700b006e0a858fd74mr2352575pfb.11.1708008683482; Thu, 15 Feb 2024 06:51:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708008683; cv=pass; d=google.com; s=arc-20160816; b=LTSl6iFI/PddeUNBmJNksEYzhp7ionPNRKG+CGG1/V1sGzaJE8LmWADjKLs1SCQFSW rN8ZDuxjdAk3IvK+jhAl5h5bEHcYWo65k6UxGAMHK4HKmf/13ww/v9IGoG/Ke65g7r9u UF+NeaTPXKeKaf3qkKOdG8A3ECEQMoN91P0wQdjMJbBGnrB7LueMhZ+P+zY4uxEqau/Q Q+G8ESDYfLfWFNiaFTk0raG3c6pzx5ya1s+6VBCYudkJIvLyPppJYcAfHXO0ScpD6pPV clCdNevlvqxsCFc+jsfh7p47aIF0Ta7vCORq8g8zpgbh7wVgVe72ZtIknjtiT7AuKKME n4fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=OG/CzkI43SfX6xCzBBAMjDKIpbYgr3KZ11AqPANjUKI=; fh=GNeA/QZ7zQFhInUXedGuirIufvqkBvsPFrVhzF77X9E=; b=UPFwha8vXRvz4g8MVsfLq7OVY1rfMb7GFF1/QZw2TqR88ysUcZoJSIt+ODqsE3ampj EHTMjX9vQ3ec1PqVAKSkqz5UO2IodFZX2oSrrSpTL2Etj87cjOj6eX2ptQpS8sh/ddyd 9Jf4pFP9GnYmVK3iPkUznVjYfZrrJyVPrxDjXLFT/DERjY5mG+WbUcQSnwhFe41JCEBG fqZANOjK8Ue4+n5TudGfGt+4zKwmwq/0xw5K3WYLRw/90XyvSyoybbhBGA2EDSHRJa16 Y19Hgsi5yO8LabKlv2j9Q9cctd5HWDnfnc2chW/AapcPsMJkb5AIluBiUSCAxUkqy62l yJkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=YtP1iOrG; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-67102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y23-20020aa78557000000b006e0ab969a87si1225144pfn.321.2024.02.15.06.51.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:51:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=YtP1iOrG; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-67102-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67102-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9E3DB289EC2 for ; Thu, 15 Feb 2024 14:50:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B3D1E135A50; Thu, 15 Feb 2024 14:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="YtP1iOrG" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4711B133285; Thu, 15 Feb 2024 14:46:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008405; cv=none; b=c5UKq5GocFYYNFKslQDaKwH3JHKQgtHsYJEa6RY466D2fkow2XOgssRwjj8KOPEnc1hx1vPG4pOoCiVDiC6hDnhh74PEMVrZ768Y4cfF6UxhBXUBm3V8Iv6tKFQTUi2fmrMh47V6QLxOjtb2wP7cJ/hzia9qA4o96mooizY9XWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008405; c=relaxed/simple; bh=+A5CzyStXl3uuRu7VAvAaofgyGw3Ro+0xr6rIKIjCf8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u+jBCYiGrGRGReNoIxsMl4445FHlthHFUjnFJLAhspg1potzoXSuz3OQoaWgARMpZ2dlZ6/mtDNq38G+YBGPPJ3ae6G8ppdWGbjDN86VPZ/wfeRGOoVqM7VqcxYYS10Bqe8Z5jBDCZjFpkJbWtYoxtMxMPhbfP+o8gat8hSGxc0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=YtP1iOrG; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708008401; bh=+A5CzyStXl3uuRu7VAvAaofgyGw3Ro+0xr6rIKIjCf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YtP1iOrGBZ2DFcfkMrFn0KrohYHueOZWWxnb1yMeBkD/1lvsW2xGteSYalPZKSM84 dPZuexmp1ywRE4ZTQOjFAgKyIAvz+xWNg3zjhDySnvi/5JJ+HqV6yNHbJnIgA2V+Cz LrEIdoTvdqClLxE1CDwMu7BvH4kU+HynYTL8FGvWqQVF+ZUtTFmBtps3Fll4hy5iYb VWfnhivvj+Lue04BRQYIzFUyJj/QJixaTtTpM98rtcdyFCecmfELtoqdx9qmJ4d3Cn Wpo8Zfth0EElxlDfWMpTqDJD6h2d2p2Z/MvkLxve0QsVGqva4CwWkicSMaV5TpJXl8 BS4uFSpfm9ZuQ== 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 4TbHvP59RfzZKm; Thu, 15 Feb 2024 09:46:41 -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 7/9] dax: Check for data cache aliasing at runtime Date: Thu, 15 Feb 2024 09:46:31 -0500 Message-Id: <20240215144633.96437-8-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> References: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790976913249945382 X-GMAIL-MSGID: 1790976913249945382 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