From nobody Sun Feb 8 12:58:38 2026 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 E185E2D59FA for ; Wed, 17 Dec 2025 21:13:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766006030; cv=none; b=s/OzML2zla6DNuZ7vGycOpOjSs5CmQDxnjo2QpkTP6Tn15yOQwnxix/Bd3iGyRF+G4DDeTP01+mn7B3WonhY2JYD2NNGUgABg////GL54zkUh9FjG28mv1o3qlNANjcemnTRjhkovl3GhMQDJguIEX1bC4Wzg484X3alRAnJFQ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766006030; c=relaxed/simple; bh=H6Dnvdf9bmtdIjrm3kzMHDEtw/qB7Ge+CUXBEkKfJQ4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eatJZNrBTVZACYTnGcOIhY+vVll0isCY4VGKZHOtYqxRbfuFC+WVb+VB/YYrvUj4b1NNqKU/xzNxIg1/KTPFLB14kTR9pPO0mnbVu6ycikbeW/n4Fr8DRm6rNqUQsZ2FWKN4KX6RKkvWOXd+EZKSyfAmxo6poxsarOl7yycBX6o= 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=ZjUsuM3B; arc=none smtp.client-ip=209.85.210.46 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="ZjUsuM3B" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7caf5314847so2821749a34.0 for ; Wed, 17 Dec 2025 13:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766006028; x=1766610828; 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=WykdBCYT8yJh4sQTY3N188JsaYBSsyfv2BDjqpmbRM8=; b=ZjUsuM3BbnWCEV1r0mJOiH8IiuyV8itGy80DbJ2DvaVz9XpYqHnyM1Os5jhx7SQPT+ 74uV/PE0mILYb2H+7izwWvGAgpqHhF9HSmwtjpICIKA0FxlJs1GOzSxTCMw4q6hVbKnu 0h1gz5kc+Tx+PsFmhISimdbhRddvPupnkfzdRIqHxbK65nPPIFzg5ZjzpgpxaZn7Zi1+ Ddrx1iWrBRJIzTbi158EGCv335o8UjbbwAY3Jk0ffx4IS3nxXvYLxRsOQ01LPOJNOm9u 5nTxpcR4SdXc1LsIk822yGZBlMn8wt2UVvNRhOUGd63S/3f2jAmvQbzdIUHVsZLVGimp iexQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766006028; x=1766610828; 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=WykdBCYT8yJh4sQTY3N188JsaYBSsyfv2BDjqpmbRM8=; b=OP3monVbFxUg04aXD+fkC9StpBiog3x4lLIyLchsVXLOtuLXKDKs50s9OGQ2oohfiw haOencKB6k0lWa1pOHJotbjEiCsiRVIKVt0dU62XA1ECJaQjGOS0fjBDIGxSX4pg/a3r f3++MnlWuMC9DAlxdTAo4W8dMzK09tmr8cW+0ghlcNi7xWqG9IGz7OJnRPowv7m5sR8A 4B0TYv/n9g80rBoXYVBsrzi9jnzFQErURoxMES9ZkcKY/Lh3rvZlBj5yoKep2dgfz1DH NWJQ8+Q5WQevHhk5Ln+pK2/3J+uYtaIKscE94R/C7mFysEMwxnnm1IcvBX4A9tUocsoo XzrQ== X-Forwarded-Encrypted: i=1; AJvYcCUPPGzZVw2QYPa+/Kaqm+IRRPqcYOnYOuPpQwEwVitwSjFt9axFlUgz77S2HX4UtyH7G0P//Eb72otvRZA=@vger.kernel.org X-Gm-Message-State: AOJu0YyDvLZj94ZNDuxEC9uKIs74hZgaNfHDhP0eRvP5SvYr0wukGVil sYPK/3anPIC4WJ4PlodmK34lAp4Lyuf1JtKyj2DdH1mXe6OHvxUOxiQ4 X-Gm-Gg: AY/fxX4D7IbGORjV7cYnDm2dTHIAVR4tWrNLUyqlFwQbWQqfi/7+EIIZC7AHi0WOtYI 62ezfNbgNwIOjvcmzeObeiy5CF7L1RKlJ0kbioibZRIsd4jLd8DNiCsuIaRkB7IBn/kA9uhK6ci Ti1raTPHZtm/EWQB0QUSVbZb5QcLdk88SvDJUSSnKeAdiqFYY/4Mkz6+7ZuTG1WzAOPKq49iNeS Zm3/kBBj7175s5hEIKFX4BiQRwlCdN4PS3wIGB+aGtHq6vp/PtDm1dGmC46zMbcicJhrzgAw+48 G5/9Y4a/DOtpJNGpvkiq1vUTKsOvWrxF8KchX/J/xd8YiwPrH4t79haPBfYMGUdAQhKSkdQ/JxZ 3TC7T8iMP0BeM7U5QZ+MrZSsPA4hYDqj9LJHL3tFAq7Wy7Fjdj8dhV6zSHWMZuYHKGFPHSgtW3V zjKPbcrLaxZM/YNjsf3IkrcgP6vGu7hG8vcJvqJFke/lw= X-Google-Smtp-Source: AGHT+IEJ79LfZmTkRRoNE6whe1Hjdhe/lgdvw3Z/AFdcRJKL1VDs0J2lLY280PufpqnuhZpriR704A== X-Received: by 2002:a05:6830:254a:b0:7c6:9d7b:b033 with SMTP id 46e09a7af769-7cae8355339mr10935440a34.22.1766006027800; Wed, 17 Dec 2025 13:13:47 -0800 (PST) Received: from localhost.localdomain ([2603:8080:1500:3d89:a468:73ca:1f36:d52]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-3fa179f3a71sm354640fac.0.2025.12.17.13.13.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 17 Dec 2025 13:13:47 -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] mm/memremap: fix spurious large folio warning for FS-DAX Date: Wed, 17 Dec 2025 15:13:10 -0600 Message-ID: <20251217211310.98772-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. Signed-off-by: John Groves --- =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. =3D=3D=3D Proposed fix =3D=3D=3D mm/memremap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/memremap.c b/mm/memremap.c index 4c2e0d68eb27..af37c3b4e39b 100644 --- a/mm/memremap.c +++ b/mm/memremap.c @@ -428,7 +428,12 @@ void free_zone_device_folio(struct folio *folio) for (i =3D 0; i < nr; i++) __ClearPageAnonExclusive(folio_page(folio, i)); } else { - VM_WARN_ON_ONCE(folio_test_large(folio)); + /* + * FS_DAX legitimately uses large file-mapped folios for + * PMD mappings, so only warn for other device types. + */ + VM_WARN_ON_ONCE(pgmap->type !=3D MEMORY_DEVICE_FS_DAX && + folio_test_large(folio)); } =20 /* base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8 --=20 2.49.0