From: Matthew Wilcox <willy@infradead.org>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Should vmap() work on pages or folios?
Date: Thu, 2 Nov 2023 12:56:15 +0000 [thread overview]
Message-ID: <ZUOcb1YwUEDT/r3K@casper.infradead.org> (raw)
For various reasons, I started looking at converting vm_struct.pages
to be vm_struct.folios. But vmap() has me wondering because it
contains:
if (flags & VM_MAP_PUT_PAGES) {
area->pages = pages;
area->nr_pages = count;
}
In principle, then, we could call vmap() with an array of pages that
includes tail pages. However, I think if we do that today, things
will go badly wrong. You see, despite the name of the flag, we don't
actually call put_page(). Instead, we call __free_page() which calls
__free_pages(page, 0), which calls put_page_testzero(). Since tail
pages have a refcount of 0, it'll hit the VM_BUG_ON_PAGE().
From this, I can conclude nobody does this today. But people might be
calling vmap() with tail pages and VM_MAP_PUT_PAGES _not_ set. And
it's not necessarily a stupid thing to want to stitch together some
tail pages (from different folios) into a virtually contiguous block.
I thibk the primary usecase is order-0 allocations being stuck together
into a virtually contiguous block, but I haven't audited every caller
of vmap.
So what's our intent here? Should we fix vmap() to actually work with
tail pages? Should we require vmap() to only work on order-0 pages?
reply other threads:[~2023-11-02 12:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=ZUOcb1YwUEDT/r3K@casper.infradead.org \
--to=willy@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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).