From: Matthew Wilcox <willy@infradead.org>
To: David Hildenbrand <david@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org
Subject: Re: [PATCH] mm: Always initialise folio->_deferred_list
Date: Tue, 12 Mar 2024 15:38:35 +0000 [thread overview]
Message-ID: <ZfB2-8d2dno_7hD7@casper.infradead.org> (raw)
In-Reply-To: <eb8e157f-6fd8-420d-898e-382138b8b958@redhat.com>
On Tue, Mar 12, 2024 at 03:34:13PM +0100, David Hildenbrand wrote:
> On 12.03.24 15:01, Matthew Wilcox wrote:
> > __free_pages(&folio->page, huge_page_order(h));
>
> Heh, __free_pages() says:
>
> "This function can free multi-page allocations that are not compound pages".
> I suspect that means "can also free compound pages", but it's confusing.
Sorry. I wrote that documentation and I was focused on one thing,
but failed to think of the other thing ... it can indeed free compound
pages. I'll add this:
* If the pages were allocated with __GFP_COMP, prefer using put_page()
* to using this function. Also prefer to call put_page() rather than
* calling __free_page() or __free_pages(page, 0).
> Especially, I thought we recently learned that free hugetlb folios do have a
> refcount of 0? Confusing.
Yes, that is confusing. This function wouldn't work if the refcount
were 0 (put_page_testzero() would complain). Ah, here we go:
In __folio_put(), we know that refcount is 0.
__folio_put_large() -> destroy_large_folio -> free_huge_folio
(refcount still 0 here, indeed it asserts it)
If we add it back to the pool, the refcount stays at 0.
But if we're removing it, we call __remove_hugetlb_folio()
which calls folio_ref_unfreeze().
next prev parent reply other threads:[~2024-03-12 15:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 3:50 Matthew Wilcox (Oracle)
2024-03-12 13:17 ` David Hildenbrand
2024-03-12 14:01 ` Matthew Wilcox
2024-03-12 14:34 ` David Hildenbrand
2024-03-12 15:38 ` Matthew Wilcox [this message]
2024-03-12 15:45 ` David Hildenbrand
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=ZfB2-8d2dno_7hD7@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--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