From: Matthew Wilcox <willy@infradead.org>
To: Zi Yan <ziy@nvidia.com>
Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
Yosry Ahmed <yosryahmed@google.com>,
Mike Kravetz <mike.kravetz@oracle.com>
Subject: Re: [RFC PATCH] mm: use nth_page() for all memmap (struct page) position operations.
Date: Wed, 23 Aug 2023 04:27:15 +0100 [thread overview]
Message-ID: <ZOV8kyfiBWo9vbyu@casper.infradead.org> (raw)
In-Reply-To: <20230823030622.96112-1-zi.yan@sent.com>
On Tue, Aug 22, 2023 at 11:06:22PM -0400, Zi Yan wrote:
> With sparsemem and without vmemmap, memmap (struct page) array might not be
> contiguous all the time. Thus, memmap position operations like page + N,
> page++, might not give a valid struct page. Use nth_page() to properly
> operate on struct page position changes.
This is too big to be a single patch; you need to break it up by
subsystem at least. And it's not against current -next; just the first
one I'm looking at is wrecked by "block: move the bi_size update out of
__bio_try_merge_page" from July 24th.
> +++ b/block/bio.c
> @@ -923,7 +923,7 @@ static inline bool page_is_mergeable(const struct bio_vec *bv,
> return true;
> else if (IS_ENABLED(CONFIG_KMSAN))
> return false;
> - return (bv->bv_page + bv_end / PAGE_SIZE) == (page + off / PAGE_SIZE);
> + return nth_page(bv->bv_page, bv_end / PAGE_SIZE) == nth_page(page, off / PAGE_SIZE);
I think this one is actually wrong. We already checked the addresses were
physically contiguous earlier in the function:
phys_addr_t vec_end_addr = page_to_phys(bv->bv_page) + bv_end - 1;
phys_addr_t page_addr = page_to_phys(page);
if (vec_end_addr + 1 != page_addr + off)
return false;
so this line is checking whether the struct pages are virtually contiguous.
That makes me suspicious of the other changes in the block layer,
because a bvec is defined to not cross a virtual discontiguity in
memmap.
> +++ b/fs/hfs/btree.c
> @@ -270,7 +270,7 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
> off = off16;
>
> off += node->page_offset;
> - pagep = node->page + (off >> PAGE_SHIFT);
> + pagep = nth_page(node->page, (off >> PAGE_SHIFT));
Are normal filesystems ever going to see folios that cross memmap
discontiguities? I think hugetlb is the only way to see such things.
> +++ b/mm/compaction.c
> @@ -362,7 +362,7 @@ __reset_isolation_pfn(struct zone *zone, unsigned long pfn, bool check_source,
> return true;
> }
>
> - page += (1 << PAGE_ALLOC_COSTLY_ORDER);
> + page = nth_page(page, (1 << PAGE_ALLOC_COSTLY_ORDER));
> } while (page <= end_page);
>
> return false;
Isn't this within a single page block?
> +++ b/mm/debug.c
> @@ -67,7 +67,7 @@ static void __dump_page(struct page *page)
> int mapcount;
> char *type = "";
>
> - if (page < head || (page >= head + MAX_ORDER_NR_PAGES)) {
> + if (page < head || (page >= nth_page(head, MAX_ORDER_NR_PAGES))) {
It's kind of right there in the name. MAX_ORDER_NR_PAGES.
next prev parent reply other threads:[~2023-08-23 3:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-23 3:06 Zi Yan
2023-08-23 3:27 ` Matthew Wilcox [this message]
2023-08-23 14:31 ` Zi Yan
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=ZOV8kyfiBWo9vbyu@casper.infradead.org \
--to=willy@infradead.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=yosryahmed@google.com \
--cc=ziy@nvidia.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