]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mm/rmap: sanity check that zeropages are not passed to RMAP
authorDavid Hildenbrand <david@redhat.com>
Wed, 22 May 2024 12:57:13 +0000 (14:57 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 02:29:56 +0000 (19:29 -0700)
Using insert_page() we might have previously ended up passing the zeropage
into rmap code.  Make sure that won't happen again.

Note that we won't check the huge zeropage for now, which might still end
up in RMAP code.

Link: https://lkml.kernel.org/r/20240522125713.775114-4-david@redhat.com
Signed-off-by: David Hildenbrand <david@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/rmap.h

index 7229b9baf20d87e6d5ebb710a6ee20f9e6c2ad80..5cb0d419a1d754c1312d6fa5a182003f324a5d4f 100644 (file)
@@ -200,6 +200,9 @@ static inline void __folio_rmap_sanity_checks(struct folio *folio,
        /* hugetlb folios are handled separately. */
        VM_WARN_ON_FOLIO(folio_test_hugetlb(folio), folio);
 
+       /* When (un)mapping zeropages, we should never touch ref+mapcount. */
+       VM_WARN_ON_FOLIO(is_zero_folio(folio), folio);
+
        /*
         * TODO: we get driver-allocated folios that have nothing to do with
         * the rmap using vm_insert_page(); therefore, we cannot assume that