From nobody Sat Feb 7 21:15:58 2026 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C49B31A23A0 for ; Fri, 19 Dec 2025 12:37:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766147848; cv=none; b=BGEYm2cNzdI6iaOBQFlCB6SwCLyw/i21QWo48sQR36g8cOYKzEBg6UotNIANqqVf4jBzcpOxQLEGdCAbqplMR/TOsPXYtG4HqMSBuy5Bf0UGZKndJr+eaf5SrZBm6mZmiO04GpgiDnQo/1i1KIvs1prEQhxe6nAd/rJn5tcT8Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766147848; c=relaxed/simple; bh=/KO9zUvcW4Dg8BOmM2ZDfaFSNvhLzW8vK8xe00YlUgg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=aTc3kpj7iRov81zo4fxQ2NoPhhAJMn4tzQ7SWyS3Gzfr4t0CUdFfBOkcU9hnZ9gOdWbtWo29Eq3pZ+5PoprVgikg6qSZttTR2aygr4JPvt9S78LeZ5RL+HEPI6ZI86sboEX1uh8L4TmuslIETlvm5XXxOYXDGjAePQ58RVjdZUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=H4+ytKGK; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=Groves.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H4+ytKGK" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7c78d30649aso1039375a34.2 for ; Fri, 19 Dec 2025 04:37:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766147842; x=1766752642; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=IcHUaTFrmXuihljZ9NPOpOfzWyP2bzk3HiTs5aJT8Q8=; b=H4+ytKGKrZl5ieedBgH3OEWHdiLUDJTBLJ6up2s0wvV+akqhLMWA7t+St6X19O3PiF 7AkxXkvq8OaptIQS2hh5L4CzyXLBurbiqXCTYtsyUSJoukrfX6/ujtHxwLpUhi3F7SAB rxsZl/lPoizwrOWV+fsTp0jt2cD2F/tFyUaB3TesssVG206e06qoIQdHtsU5SUYQZ1nV JB+JOOp0NwOBtHM4K/Rkw/KIJFb0H4gphB9TPUAfPsUHDEWI7FsWpXefFRp+dxbb51EO rRQEXrD24Xe0BNT2JMNv93nyaWesBykjEIdwstnpFdAMghWYMW4fDQTDN+K1CCTDhJBR +6Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766147842; x=1766752642; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IcHUaTFrmXuihljZ9NPOpOfzWyP2bzk3HiTs5aJT8Q8=; b=mYFTXJZleRr6RSUK+b1rM2dMHZrFcszykT1gEA3WMPHHnG3OYXJihBUlH4Vk63jKIt kDAv5Sdo/k13EZP13HZpZIipSNiYwOS6WZEcf7krHSS1c/e2H9USAe9Aj8Z0Q136WUrY w73fqJlqAb8qcruyL8ISeY5RBL8GGy3kDc+Ql7MUmrn1Rx56QECu1SpiZNUyIW00ZrOE 49Kc5/3I5UvBQm+RCqY//BtNgIaIJf61C4Z66uG6WlBBUip+JbA7K/nxt18mBQ4x2RO5 HgVME2pbSnEM6DNytS6qjD4PH3XSHVPH6ZBvr6IBviKwQXWWdQESPxBF2rIuiyNGJXFm fcIA== X-Forwarded-Encrypted: i=1; AJvYcCXlvWxnaei7mhkwrYVk0fAuzWUXofGeCsc3QzI9BdzlA/x8+6iNfPno5RJLkq4vWfXnpkFEEVG5ge3yOXA=@vger.kernel.org X-Gm-Message-State: AOJu0Yw8AfTXysVhRfAg9Sq+/WVTBtDuDZRxPBgdZG4mYzrU7O02eYBB ygOO4FrKzQr9g2cBuJy+SplhQwq32HEachK9y7FSQh8uMIqGxnteChp3 X-Gm-Gg: AY/fxX4DFTiTFPNiPEbSsWw7GCzT/I7aVQHl3em7+fSTN3NzNIgHVZX/E1pFE/w6U2M dPwyfnIRyVlbCPIWldeSm1D4L06UKoYRSGfmtbtBV8ZjVMTk6v5NZcxD2JoPN96lJK4/s62pJW9 BvlRL50GNdDXOtn09H1enTN+xYAhlU76u6tKP7b+x1HJQ3bfZwRJkVGWsNq4vmmY074XmKblTJW SuTUiSWTtpBpHV8lgcA0Wmv5Q6skcMgPxb9wpWHNbP3lCZKwaL07VijTrW3GuJdCsFgwFwtZdes M6/W2oQxvLCWY1LPsT78POEY02jLVKAVE3cUwOfj/mHOaLyX+lmi/P9A++l+t4KQ+Zd07nleG/A sVm67k+Oxn78ltPnoZdySF+2LtaFyHBrvnZeiBrfyciM2vmAqswhg7dLYOuVZUgt0JBJl8KAKBD 1iK6JPEwJNJeeEmS5vAKNdrLTYSQ8LIyYNzKHW3iyTDG6E X-Google-Smtp-Source: AGHT+IEgOA0/a6B77dCuTQnCdZXbZikCeOm1NYByQGossxUkCBmPTXJQBtJah4Ps9oYiD64ephxmcQ== X-Received: by 2002:a05:6830:25d4:b0:7c7:591a:7e91 with SMTP id 46e09a7af769-7cc668a4bd5mr1727231a34.7.1766147842443; Fri, 19 Dec 2025 04:37:22 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:7cbc:db2c:ec63:19af]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7cc667ebe98sm1571289a34.21.2025.12.19.04.37.21 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Dec 2025 04:37:21 -0800 (PST) Sender: John Groves From: John Groves X-Google-Original-From: John Groves To: David Hildenbrand , Oscar Salvador , Andrew Morton Cc: John Groves , John Groves , "Darrick J . Wong" , Dan Williams , Gregory Price , Balbir Singh , Alistair Popple , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, Aravind Ramesh , Ajay Joshi , John Groves Subject: [PATCH V2] mm/memremap: fix spurious large folio warning for FS-DAX Date: Fri, 19 Dec 2025 06:37:17 -0600 Message-ID: <20251219123717.39330-1-john@groves.net> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: John Groves This patch addresses a warning that I discovered while working on famfs, which is an fs-dax file system that virtually always does PMD faults (next famfs patch series coming after the holidays). However, XFS also does PMD faults in fs-dax mode, and it also triggers the warning. It takes some effort to get XFS to do a PMD fault, but instructions to reproduce it are below. The VM_WARN_ON_ONCE(folio_test_large(folio)) check in free_zone_device_folio() incorrectly triggers for MEMORY_DEVICE_FS_DAX when PMD (2MB) mappings are used. FS-DAX legitimately creates large file-backed folios when handling PMD faults. This is a core feature of FS-DAX that provides significant performance benefits by mapping 2MB regions directly to persistent memory. When these mappings are unmapped, the large folios are freed through free_zone_device_folio(), which triggers the spurious warning. The warning was introduced by commit that added support for large zone device private folios. However, that commit did not account for FS-DAX file-backed folios, which have always supported large (PMD-sized) mappings. The check distinguishes between anonymous folios (which clear AnonExclusive flags for each sub-page) and file-backed folios. For file-backed folios, it assumes large folios are unexpected - but this assumption is incorrect for FS-DAX. The fix is to exempt MEMORY_DEVICE_FS_DAX from the large folio warning, allowing FS-DAX to continue using PMD mappings without triggering false warnings. Fixes: d245f9b4ab80 ("mm/zone_device: support large zone device private fol= ios") Signed-off-by: John Groves Acked-by: David Hildenbrand (Red Hat) Reviewed-by: Dan Williams Tested-by: Alison Schofield --- Change since V1: Deleted the warning altogether, rather than exempting fs-dax. =3D=3D=3D How to reproduce =3D=3D=3D A reproducer is available at: git clone https://github.com/jagalactic/dax-pmd-test.git cd xfs-dax-test make sudo make test This will set up XFS on pmem with 2MB stripe alignment and run a test that triggers the warning. Alternatively, follow the manual steps below. Prerequisites: - Linux kernel with FS-DAX support and CONFIG_DEBUG_VM=3Dy - A pmem device (real or emulated) - An fsdax namespace configured via ndctl as /dev/pmem0 Manual steps: 1. Create an fsdax namespace (if not already present): # ndctl create-namespace -m fsdax -e namespace0.0 2. Create XFS with 2MB stripe alignment: # mkfs.xfs -f -d su=3D2m,sw=3D1 /dev/pmem0 # mount -o dax /dev/pmem0 /mnt/pmem 3. Compile and run the reproducer: # gcc -Wall -O2 -o dax_pmd_test dax_pmd_test.c # ./dax_pmd_test /mnt/pmem/testfile 4. Check dmesg for the warning: WARNING: mm/memremap.c:431 at free_zone_device_folio+0x.../0x... Note: The 2MB stripe alignment (-d su=3D2m,sw=3D1) is critical. XFS normally allocates blocks at arbitrary offsets, causing PMD faults to fall back to PTE faults. The stripe alignment forces 2MB-aligned allocations, allowing PMD faults to succeed and exposing this bug. mm/memremap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/memremap.c b/mm/memremap.c index 4c2e0d68eb27..63c6ab4fdf08 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -427,8 +427,6 @@ void free_zone_device_folio(struct folio *folio) if (folio_test_anon(folio)) { for (i =3D 0; i < nr; i++) __ClearPageAnonExclusive(folio_page(folio, i)); - } else { - VM_WARN_ON_ONCE(folio_test_large(folio)); } =20 /* base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 --=20 2.49.0