From: Matthew Wilcox <willy@infradead.org>
To: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: mike.kravetz@oracle.com, songmuchun@bytedance.com,
akpm@linux-foundation.org, catalin.marinas@arm.com,
will@kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] mm: hugetlb: kill set_huge_swap_pte_at()
Date: Mon, 27 Jun 2022 15:41:31 +0100 [thread overview]
Message-ID: <YrnBm9FGizF1iLsW@casper.infradead.org> (raw)
In-Reply-To: <20220626145717.53572-1-zhengqi.arch@bytedance.com>
On Sun, Jun 26, 2022 at 10:57:17PM +0800, Qi Zheng wrote:
> The commit e5251fd43007 ("mm/hugetlb: introduce set_huge_swap_pte_at()
> helper") add set_huge_swap_pte_at() to handle swap entries on
> architectures that support hugepages consisting of contiguous ptes.
> And currently the set_huge_swap_pte_at() is only overridden by arm64.
Bleh. I hate the way we handle these currently.
> +static inline struct folio *hugetlb_swap_entry_to_folio(swp_entry_t entry)
> +{
> + VM_BUG_ON(!is_migration_entry(entry) && !is_hwpoison_entry(entry));
> +
> + return page_folio(pfn_to_page(swp_offset(entry)));
> +}
We haven't needed a pfn_to_folio() yet, but perhaps we should have one?
Related, how should we store migration entries for multi-order folios
in the page tables? We can either encode the individual page in
question, or we can encode the folio. Do we need to support folios
being mapped askew (ie unaligned), or will folios always be mapped
aligned?
> + if (!pte_present(pte)) {
> + struct folio *folio;
> +
> + folio = hugetlb_swap_entry_to_folio(pte_to_swp_entry(pte));
> + ncontig = num_contig_ptes(folio_size(folio), &pgsize);
> +
> + for (i = 0; i < ncontig; i++, ptep++)
> + set_pte_at(mm, addr, ptep, pte);
> + return;
> + }
It seems like a shame to calculate folio_size() only to turn it into a
number of pages. Don't you want to just use:
ncontig = folio_nr_pages(folio);
next prev parent reply other threads:[~2022-06-27 14:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-26 14:57 [PATCH] mm: hugetlb: kill set_huge_swap_pte_at() Qi Zheng
2022-06-27 3:32 ` Muchun Song
2022-06-27 6:18 ` Anshuman Khandual
2022-06-27 6:55 ` Qi Zheng
2022-06-27 7:14 ` Anshuman Khandual
2022-06-27 7:29 ` Qi Zheng
2022-06-27 7:35 ` Anshuman Khandual
2022-06-27 14:34 ` Matthew Wilcox
2022-06-28 5:47 ` Anshuman Khandual
2022-06-27 7:44 ` Muchun Song
2022-06-27 14:41 ` Matthew Wilcox [this message]
2022-06-28 3:34 ` Qi Zheng
2023-09-21 16:25 ` Ryan Roberts
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=YrnBm9FGizF1iLsW@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=songmuchun@bytedance.com \
--cc=will@kernel.org \
--cc=zhengqi.arch@bytedance.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).