From: Johannes Weiner <hannes@cmpxchg.org>
To: Zi Yan <ziy@nvidia.com>
Cc: linux-mm@kvack.org, David Hildenbrand <david@redhat.com>,
Oscar Salvador <osalvador@suse.de>,
Vlastimil Babka <vbabka@suse.cz>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Mel Gorman <mgorman@suse.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] mm/page_isolation: make page isolation a standalone bit.
Date: Fri, 14 Feb 2025 11:45:41 -0500 [thread overview]
Message-ID: <20250214164541.GA233399@cmpxchg.org> (raw)
In-Reply-To: <20250214154215.717537-2-ziy@nvidia.com>
On Fri, Feb 14, 2025 at 10:42:12AM -0500, Zi Yan wrote:
> During page isolation, the original migratetype is overwritten, since
> MIGRATE_* are enums. Change MIGRATE_ISOLATE to be a standalone bit like
> PB_migrate_skip. pageblock bits needs to be word aligned, so expand
> the number of pageblock bits from 4 to 8 and make migrate isolate bit 7.
>
> Signed-off-by: Zi Yan <ziy@nvidia.com>
> ---
> include/linux/mmzone.h | 18 +++++++++++++-----
> include/linux/page-isolation.h | 2 +-
> include/linux/pageblock-flags.h | 33 ++++++++++++++++++++++++++++++++-
> mm/page_alloc.c | 21 +++++++++++++++++++--
> 4 files changed, 65 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
> index 8aecbbb0b685..3c7d3f22ccb2 100644
> --- a/include/linux/mmzone.h
> +++ b/include/linux/mmzone.h
> @@ -106,14 +106,22 @@ static inline bool migratetype_is_mergeable(int mt)
>
> extern int page_group_by_mobility_disabled;
>
> -#define MIGRATETYPE_MASK ((1UL << PB_migratetype_bits) - 1)
> +#ifdef CONFIG_MEMORY_ISOLATION
> +#define MIGRATETYPE_NO_ISO_MASK (BIT(PB_migratetype_bits) - 1)
> +#define MIGRATETYPE_MASK (MIGRATETYPE_NO_ISO_MASK | PB_migrate_isolate_bit)
> +#else
> +#define MIGRATETYPE_NO_ISO_MASK (BIT(PB_migratetype_bits) - 1)
> +#define MIGRATETYPE_MASK (BIT(PB_migratetype_bits) - 1)
> +#endif
There is no user of the NO_ISO_MASK until the last patch. Can you
please defer introduction until then?
> -#define get_pageblock_migratetype(page) \
> - get_pfnblock_flags_mask(page, page_to_pfn(page), MIGRATETYPE_MASK)
> +#define get_pageblock_migratetype(page) \
> + get_pfnblock_flags_mask(page, page_to_pfn(page), \
> + MIGRATETYPE_MASK)
>
> -#define folio_migratetype(folio) \
> - get_pfnblock_flags_mask(&folio->page, folio_pfn(folio), \
> +#define folio_migratetype(folio) \
> + get_pfnblock_flags_mask(&folio->page, folio_pfn(folio), \
> MIGRATETYPE_MASK)
That's a spurious change currently. I assume you tweaked the
MIGRATETYPE_MASK parameter during development, but I can't see a
functional difference now.
> @@ -373,7 +374,13 @@ unsigned long get_pfnblock_flags_mask(const struct page *page,
> * racy, are not corrupted.
> */
> word = READ_ONCE(bitmap[word_bitidx]);
> - return (word >> bitidx) & mask;
> + flags = (word >> bitidx) & mask;
> +
> +#ifdef CONFIG_MEMORY_ISOLATION
> + if (flags & PB_migrate_isolate_bit)
> + return MIGRATE_ISOLATE;
> +#endif
> + return flags;
> }
>
> static __always_inline int get_pfnblock_migratetype(const struct page *page,
> @@ -397,8 +404,18 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
> unsigned long bitidx, word_bitidx;
> unsigned long word;
>
> +#ifdef CONFIG_MEMORY_ISOLATION
> + BUILD_BUG_ON(NR_PAGEBLOCK_BITS != 8);
> + /* keep other migratetype bits if MIGRATE_ISOLATE is set */
> + if (flags == MIGRATE_ISOLATE) {
> + mask &= ~((1UL << PB_migratetype_bits) - 1);
> + flags = PB_migrate_isolate_bit;
> + }
Please change the callers in both cases to pass the appropriate masks
of interest instead.
That's likely a bit of churn in the allocator code, but adding caller
specifics to this function violates abstraction layering rules.
next prev parent reply other threads:[~2025-02-14 16:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 15:42 [PATCH v2 0/4] Make MIGRATE_ISOLATE a standalone bit Zi Yan
2025-02-14 15:42 ` [PATCH v2 1/4] mm/page_isolation: make page isolation " Zi Yan
2025-02-14 16:45 ` Johannes Weiner [this message]
2025-02-14 17:58 ` Zi Yan
2025-02-14 15:42 ` [PATCH v2 2/4] mm/page_isolation: remove migratetype from move_freepages_block_isolate() Zi Yan
2025-02-14 17:20 ` Johannes Weiner
2025-02-14 18:04 ` Zi Yan
2025-02-14 15:42 ` [PATCH v2 3/4] mm/page_isolation: remove migratetype from undo_isolate_page_range() Zi Yan
2025-02-14 15:42 ` [PATCH v2 4/4] mm/page_isolation: remove migratetype parameter from more functions 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=20250214164541.GA233399@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=osalvador@suse.de \
--cc=vbabka@suse.cz \
--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