From: David Hildenbrand <david@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vincent Donnefort <vdonnefort@google.com>,
Dan Williams <dan.j.williams@intel.com>
Subject: [PATCH v1 2/2] mm/rmap: sanity check that zeropages are not passed to RMAP
Date: Tue, 30 Apr 2024 22:40:44 +0200 [thread overview]
Message-ID: <20240430204044.52755-3-david@redhat.com> (raw)
In-Reply-To: <20240430204044.52755-1-david@redhat.com>
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.
Signed-off-by: David Hildenbrand <david@redhat.com>
---
include/linux/rmap.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 7229b9baf20d8..5cb0d419a1d75 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -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
--
2.44.0
prev parent reply other threads:[~2024-04-30 20:41 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 20:40 [PATCH v1 0/2] mm/memory: cleanly support zeropage in vm_insert_page*(), vm_map_pages*() and vmf_insert_mixed() David Hildenbrand
2024-04-30 20:40 ` [PATCH v1 1/2] " David Hildenbrand
2024-05-17 15:07 ` Vincent Donnefort
2024-05-21 8:25 ` David Hildenbrand
2024-05-21 9:06 ` Vincent Donnefort
2024-05-21 9:18 ` David Hildenbrand
2024-05-21 10:10 ` Vincent Donnefort
2024-04-30 20:40 ` David Hildenbrand [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240430204044.52755-3-david@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=vdonnefort@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).