* Re: [PATCH v2 08/22] mm: introduce for_each_free_list() [not found] ` <20260320-page_alloc-unmapped-v2-8-28bf1bd54f41@google.com> @ 2026-05-11 13:46 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 13:46 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > Later patches will rearrange the free areas, but there are a couple of > places that iterate over them with the assumption that they have the > current structure. > > It seems ideally, code outside of mm should not be directly aware of > struct free_area in the first place, but that awareness seems relatively > harmless so just make the minimal change. I think we should lift the code from kernel/power/snapshot.c to under mm/ eventually, ISTR discussing it somewhere recently. But doesn't have to be in this series. > Now instead of letting users manually iterate over the free lists, just > provide a macro to do that. Then adopt that macro in a couple of places. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> > --- > include/linux/mmzone.h | 7 +++++-- > kernel/power/snapshot.c | 8 ++++---- > mm/mm_init.c | 11 +++++++---- > 3 files changed, 16 insertions(+), 10 deletions(-) > > diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h > index 7bd0134c241ce..c49e3cdf4f6bb 100644 > --- a/include/linux/mmzone.h > +++ b/include/linux/mmzone.h > @@ -177,9 +177,12 @@ static inline bool migratetype_is_mergeable(int mt) > return mt < MIGRATE_PCPTYPES; > } > > -#define for_each_migratetype_order(order, type) \ > +#define for_each_free_list(list, zone, order) \ > for (order = 0; order < NR_PAGE_ORDERS; order++) \ > - for (type = 0; type < MIGRATE_TYPES; type++) > + for (unsigned int type = 0; \ > + list = &zone->free_area[order].free_list[type], \ > + type < MIGRATE_TYPES; \ > + type++) \ > > extern int page_group_by_mobility_disabled; > > diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c > index 7dcccf378cc2f..abd33ca13eec4 100644 > --- a/kernel/power/snapshot.c > +++ b/kernel/power/snapshot.c > @@ -1245,8 +1245,9 @@ unsigned int snapshot_additional_pages(struct zone *zone) > static void mark_free_pages(struct zone *zone) > { > unsigned long pfn, max_zone_pfn, page_count = WD_PAGE_COUNT; > + struct list_head *free_list; > unsigned long flags; > - unsigned int order, t; > + unsigned int order; > struct page *page; > > if (zone_is_empty(zone)) > @@ -1270,9 +1271,8 @@ static void mark_free_pages(struct zone *zone) > swsusp_unset_page_free(page); > } > > - for_each_migratetype_order(order, t) { > - list_for_each_entry(page, > - &zone->free_area[order].free_list[t], buddy_list) { > + for_each_free_list(free_list, zone, order) { > + list_for_each_entry(page, free_list, buddy_list) { > unsigned long i; > > pfn = page_to_pfn(page); > diff --git a/mm/mm_init.c b/mm/mm_init.c > index 969048f9b320c..f6f9455bc42b6 100644 > --- a/mm/mm_init.c > +++ b/mm/mm_init.c > @@ -1445,11 +1445,14 @@ static void __meminit zone_init_internals(struct zone *zone, enum zone_type idx, > > static void __meminit zone_init_free_lists(struct zone *zone) > { > - unsigned int order, t; > - for_each_migratetype_order(order, t) { > - INIT_LIST_HEAD(&zone->free_area[order].free_list[t]); > + struct list_head *list; > + unsigned int order; > + > + for_each_free_list(list, zone, order) > + INIT_LIST_HEAD(list); > + > + for (order = 0; order < NR_PAGE_ORDERS; order++) > zone->free_area[order].nr_free = 0; > - } > > #ifdef CONFIG_UNACCEPTED_MEMORY > INIT_LIST_HEAD(&zone->unaccepted_pages); > ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-9-28bf1bd54f41@google.com>]
* Re: [PATCH v2 09/22] mm/page_alloc: don't overload migratetype in find_suitable_fallback() [not found] ` <20260320-page_alloc-unmapped-v2-9-28bf1bd54f41@google.com> @ 2026-05-11 13:51 ` Vlastimil Babka (SUSE) 2026-05-11 16:44 ` Brendan Jackman 0 siblings, 1 reply; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 13:51 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > This function currently returns a signed integer that encodes status > in-band, as negative numbers, along with a migratetype. > > This function is about to be updated to a mode where this in-band > signaling no longer makes sense. Therefore, switch to a more > explicit/verbose style that encodes the status and migratetype > separately. > > In the spirit of making things more explicit, also create an enum to > avoid using magic integer literals with special meanings. This enables > documenting the values at their definition instead of in one of the > callers. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 09/22] mm/page_alloc: don't overload migratetype in find_suitable_fallback() 2026-05-11 13:51 ` [PATCH v2 09/22] mm/page_alloc: don't overload migratetype in find_suitable_fallback() Vlastimil Babka (SUSE) @ 2026-05-11 16:44 ` Brendan Jackman 2026-05-11 16:53 ` Vlastimil Babka (SUSE) 0 siblings, 1 reply; 14+ messages in thread From: Brendan Jackman @ 2026-05-11 16:44 UTC (permalink / raw) To: Vlastimil Babka (SUSE), Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On Mon May 11, 2026 at 1:51 PM UTC, Vlastimil Babka (SUSE) wrote: > On 3/20/26 19:23, Brendan Jackman wrote: >> This function currently returns a signed integer that encodes status >> in-band, as negative numbers, along with a migratetype. >> >> This function is about to be updated to a mode where this in-band >> signaling no longer makes sense. Therefore, switch to a more >> explicit/verbose style that encodes the status and migratetype >> separately. >> >> In the spirit of making things more explicit, also create an enum to >> avoid using magic integer literals with special meanings. This enables >> documenting the values at their definition instead of in one of the >> callers. >> >> Signed-off-by: Brendan Jackman <jackmanb@google.com> > > Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Thanks, This and the prior patch could arguably just be considered independent cleanups, shall I send them on their own? Equally if they feel like "churn" I'm happy to keep them in this patchset. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 09/22] mm/page_alloc: don't overload migratetype in find_suitable_fallback() 2026-05-11 16:44 ` Brendan Jackman @ 2026-05-11 16:53 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 16:53 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 5/11/26 18:44, Brendan Jackman wrote: > On Mon May 11, 2026 at 1:51 PM UTC, Vlastimil Babka (SUSE) wrote: >> On 3/20/26 19:23, Brendan Jackman wrote: >>> This function currently returns a signed integer that encodes status >>> in-band, as negative numbers, along with a migratetype. >>> >>> This function is about to be updated to a mode where this in-band >>> signaling no longer makes sense. Therefore, switch to a more >>> explicit/verbose style that encodes the status and migratetype >>> separately. >>> >>> In the spirit of making things more explicit, also create an enum to >>> avoid using magic integer literals with special meanings. This enables >>> documenting the values at their definition instead of in one of the >>> callers. >>> >>> Signed-off-by: Brendan Jackman <jackmanb@google.com> >> >> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> > > Thanks, > > This and the prior patch could arguably just be considered independent > cleanups, shall I send them on their own? I guess why not, fewer patches in the patchset :) You're probably going to need to rebase this on current mm tree anyway for the next posting? > Equally if they feel like "churn" I'm happy to keep them in this > patchset. ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-10-28bf1bd54f41@google.com>]
* Re: [PATCH v2 10/22] mm: introduce freetype_t [not found] ` <20260320-page_alloc-unmapped-v2-10-28bf1bd54f41@google.com> @ 2026-05-11 15:34 ` Vlastimil Babka (SUSE) 2026-05-11 16:49 ` Brendan Jackman 2026-05-11 18:17 ` Vlastimil Babka (SUSE) 2026-05-11 18:26 ` Vlastimil Babka (SUSE) 2 siblings, 1 reply; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 15:34 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > This is preparation for teaching the page allocator to break up free > pages according to properties that have nothing to do with mobility. For > example it can be used to allocate pages that are non-present in the > physmap, or pages that are sensitive in ASI. > > For these usecases, certain allocator behaviours are desirable: > > - A "pool" of pages with the given property is usually available, so > that pages can be provided with the correct sensitivity without > zeroing/TLB flushing. > > - Pages are physically grouped by the property, so that large > allocations rarely have to alter the pagetables due to ASI. > > - The properties can be forced to vary only at a certain fixed address > granularity, so that the pagetables can all be pre-allocated. This is > desirable because the page allocator will be changing mappings: > pre-allocation is a straightforward way to avoid recursive allocations > (of pagetables). > > It seems that the existing infrastructure for grouping pages by > mobility, i.e. pageblocks and migratetypes, serves this purpose pretty > nicely. However, overloading migratetype itself for this purpose looks > like a road to maintenance hell. In particular, as soon as such > properties become orthogonal to migratetypes, it would start to require > "doubling" the migratetypes. > > Therefore, introduce a new higher-level concept, called "freetype" > (because it is used to index "free"lists) that can encode extra > properties, orthogonally to mobility, via flags. > > Since freetypes and migratetypes would be very easy to mix up, freetypes > are (at least for now) stored in a struct typedef similar to atomic_t. > This provides type-safety, but comes at the expense of being pretty > annoying to code with. For instance, freetype_t cannot be compared with > the == operator. Once this code matures, if the freetype/migratetype > distinction gets less confusing, it might be wise to drop this > struct and just use ints. > > Because this will eventually be needed from pageblock-flags.h, put this > in its own header instead of directly in mmzone.h. > > To try and reduce review pain for such a churny patch, first introduce > freetypes as nothing but an indirection over migratetypes. The helpers > concerned with the flags are defined, but only as stubs. Convert > everything over to using freetypes wherever they are needed to index > freelists, but maintain references to migratetypes in code that really > only cares specifically about mobility. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Seems mechanistic enough. Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Some nits: > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index ac077d98019f3..018622aa19006 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -422,6 +422,37 @@ bool get_pfnblock_bit(const struct page *page, unsigned long pfn, > return test_bit(bitidx + pb_bit, bitmap_word); > } > > +/** > + * __get_pfnblock_freetype - Return the freetype of a pageblock, optionally > + * ignoring the fact that it's currently isolated. > + * @page: The page within the block of interest > + * @pfn: The target page frame number > + * @ignore_iso: If isolated, return the migratetype that the block had before > + * isolation. > + */ > +__always_inline freetype_t 'static' too? > +__get_pfnblock_freetype(const struct page *page, unsigned long pfn, > + bool ignore_iso) > +{ > + int mt = get_pfnblock_migratetype(page, pfn); > + > + return migrate_to_freetype(mt, 0); > +} > + > +/** > + * get_pfnblock_migratetype - Return the freetype of a pageblock > + * @page: The page within the block of interest > + * @pfn: The target page frame number > + * > + * Return: The freetype of the pageblock > + */ > +__always_inline freetype_t And this is declared in a header so the __always_inline is not really applicable? (seems we should fix up get_pfnblock_migratetype too) > +get_pfnblock_freetype(const struct page *page, unsigned long pfn) > +{ > + return __get_pfnblock_freetype(page, pfn, 0); > +} > + > + > /** > * get_pfnblock_migratetype - Return the migratetype of a pageblock > * @page: The page within the block of interest > @@ -2262,10 +2323,18 @@ find_suitable_fallback(struct free_area *area, unsigned int order, > > for (i = 0; i < MIGRATE_PCPTYPES - 1 ; i++) { > int fallback_mt = fallbacks[migratetype][i]; > + /* > + * Fallback to different migratetypes, but currently always with > + * the same freetype flags. > + */ > + freetype_t fallback_ft = freetype_with_migrate(freetype, fallback_mt); > > - if (!free_area_empty(area, fallback_mt)) { > - if (mt_out) > - *mt_out = fallback_mt; > + if (freetype_idx(fallback_ft) < 0) > + continue; How can this happen? Is it preparatory? > + > + if (!free_area_empty(area, fallback_ft)) { > + if (ft_out) > + *ft_out = fallback_ft; > return FALLBACK_FOUND; > } > } ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 10/22] mm: introduce freetype_t 2026-05-11 15:34 ` [PATCH v2 10/22] mm: introduce freetype_t Vlastimil Babka (SUSE) @ 2026-05-11 16:49 ` Brendan Jackman 2026-05-11 16:58 ` Vlastimil Babka (SUSE) 0 siblings, 1 reply; 14+ messages in thread From: Brendan Jackman @ 2026-05-11 16:49 UTC (permalink / raw) To: Vlastimil Babka (SUSE), Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On Mon May 11, 2026 at 3:34 PM UTC, Vlastimil Babka (SUSE) wrote: >> +/** >> + * __get_pfnblock_freetype - Return the freetype of a pageblock, optionally >> + * ignoring the fact that it's currently isolated. >> + * @page: The page within the block of interest >> + * @pfn: The target page frame number >> + * @ignore_iso: If isolated, return the migratetype that the block had before >> + * isolation. >> + */ >> +__always_inline freetype_t > > 'static' too? Yup thanks > >> +__get_pfnblock_freetype(const struct page *page, unsigned long pfn, >> + bool ignore_iso) >> +{ >> + int mt = get_pfnblock_migratetype(page, pfn); >> + >> + return migrate_to_freetype(mt, 0); >> +} >> + >> +/** >> + * get_pfnblock_migratetype - Return the freetype of a pageblock >> + * @page: The page within the block of interest >> + * @pfn: The target page frame number >> + * >> + * Return: The freetype of the pageblock >> + */ >> +__always_inline freetype_t > > And this is declared in a header so the __always_inline is not really > applicable? > (seems we should fix up get_pfnblock_migratetype too) Um, I think it probably still forces inlining in calls within the same translation unit? Anyway I am pretty meh about this, I suspect humans and compilers are equally bad at making this decision, I was just trying to be consistent with the code it's replacing. >> + /* >> + * Fallback to different migratetypes, but currently always with >> + * the same freetype flags. >> + */ >> + freetype_t fallback_ft = freetype_with_migrate(freetype, fallback_mt); >> >> - if (!free_area_empty(area, fallback_mt)) { >> - if (mt_out) >> - *mt_out = fallback_mt; >> + if (freetype_idx(fallback_ft) < 0) >> + continue; > > How can this happen? Is it preparatory? Oops, yeah looks like I need to clean up how this happens in the history and clarify the commit messages. In a later patch I add an optimisation where we avoid having freelists for freetypes that never arise in practice. And in those cases freetype_idx() returns -1. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 10/22] mm: introduce freetype_t 2026-05-11 16:49 ` Brendan Jackman @ 2026-05-11 16:58 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 16:58 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 5/11/26 18:49, Brendan Jackman wrote: > On Mon May 11, 2026 at 3:34 PM UTC, Vlastimil Babka (SUSE) wrote: >>> +/** >>> + * __get_pfnblock_freetype - Return the freetype of a pageblock, optionally >>> + * ignoring the fact that it's currently isolated. >>> + * @page: The page within the block of interest >>> + * @pfn: The target page frame number >>> + * @ignore_iso: If isolated, return the migratetype that the block had before >>> + * isolation. >>> + */ >>> +__always_inline freetype_t >> >> 'static' too? > > Yup thanks > >> >>> +__get_pfnblock_freetype(const struct page *page, unsigned long pfn, >>> + bool ignore_iso) >>> +{ >>> + int mt = get_pfnblock_migratetype(page, pfn); >>> + >>> + return migrate_to_freetype(mt, 0); >>> +} >>> + >>> +/** >>> + * get_pfnblock_migratetype - Return the freetype of a pageblock >>> + * @page: The page within the block of interest >>> + * @pfn: The target page frame number >>> + * >>> + * Return: The freetype of the pageblock >>> + */ >>> +__always_inline freetype_t >> >> And this is declared in a header so the __always_inline is not really >> applicable? > >> (seems we should fix up get_pfnblock_migratetype too) > > Um, I think it probably still forces inlining in calls within the same > translation unit? True but I don't think we try to do that consciously, seems like it was just an oversight for get_pfnblock_migratetype, maybe Zi Yan remembers? > Anyway I am pretty meh about this, I suspect humans and compilers are > equally bad at making this decision, I was just trying to be consistent > with the code it's replacing. True. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 10/22] mm: introduce freetype_t [not found] ` <20260320-page_alloc-unmapped-v2-10-28bf1bd54f41@google.com> 2026-05-11 15:34 ` [PATCH v2 10/22] mm: introduce freetype_t Vlastimil Babka (SUSE) @ 2026-05-11 18:17 ` Vlastimil Babka (SUSE) 2026-05-11 18:26 ` Vlastimil Babka (SUSE) 2 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:17 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > +/** > + * get_pfnblock_migratetype - Return the freetype of a pageblock Also just noticed the wrong name here > + * @page: The page within the block of interest > + * @pfn: The target page frame number > + * > + * Return: The freetype of the pageblock > + */ > +__always_inline freetype_t > +get_pfnblock_freetype(const struct page *page, unsigned long pfn) > +{ > + return __get_pfnblock_freetype(page, pfn, 0); > +} ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2 10/22] mm: introduce freetype_t [not found] ` <20260320-page_alloc-unmapped-v2-10-28bf1bd54f41@google.com> 2026-05-11 15:34 ` [PATCH v2 10/22] mm: introduce freetype_t Vlastimil Babka (SUSE) 2026-05-11 18:17 ` Vlastimil Babka (SUSE) @ 2026-05-11 18:26 ` Vlastimil Babka (SUSE) 2 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:26 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -422,6 +422,37 @@ bool get_pfnblock_bit(const struct page *page, unsigned long pfn, > return test_bit(bitidx + pb_bit, bitmap_word); > } > > +/** > + * __get_pfnblock_freetype - Return the freetype of a pageblock, optionally > + * ignoring the fact that it's currently isolated. > + * @page: The page within the block of interest > + * @pfn: The target page frame number > + * @ignore_iso: If isolated, return the migratetype that the block had before > + * isolation. > + */ > +__always_inline freetype_t > +__get_pfnblock_freetype(const struct page *page, unsigned long pfn, > + bool ignore_iso) Hm I also noticed ignore_iso is ... ignored until later patch. > +{ > + int mt = get_pfnblock_migratetype(page, pfn); > + > + return migrate_to_freetype(mt, 0); > +} > + > +/** > + * get_pfnblock_migratetype - Return the freetype of a pageblock > + * @page: The page within the block of interest > + * @pfn: The target page frame number > + * > + * Return: The freetype of the pageblock > + */ > +__always_inline freetype_t > +get_pfnblock_freetype(const struct page *page, unsigned long pfn) > +{ > + return __get_pfnblock_freetype(page, pfn, 0); And here it passes 0 to bool. > +} > + > + ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-11-28bf1bd54f41@google.com>]
* Re: [PATCH v2 11/22] mm: move migratetype definitions to freetype.h [not found] ` <20260320-page_alloc-unmapped-v2-11-28bf1bd54f41@google.com> @ 2026-05-11 15:35 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 15:35 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > Since migratetypes are a sub-element of freetype, move the pure > definitions into the new freetype.h. > > This will enable referring to these raw types from pageblock-flags.h. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> git coloring agrees it's just moves Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-12-28bf1bd54f41@google.com>]
* Re: [PATCH v2 12/22] mm: add definitions for allocating unmapped pages [not found] ` <20260320-page_alloc-unmapped-v2-12-28bf1bd54f41@google.com> @ 2026-05-11 18:01 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:01 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > Create __GFP_UNMAPPED, which requests pages that are not present in the > direct map. Since this feature has a cost (e.g. more freelists), it's > behind a kconfig. Unlike other conditionally-defined GFP flags, it > doesn't fall back to being 0. This prevents building code that uses > __GFP_UNMAPPED but doesn't depend on the necessary kconfig, since that > would lead to invisible security issues. > > Create a freetype flag to record that pages on the freelists with this > flag are unmapped. This is currently only needed for MIGRATE_UNMOVABLE > pages, so the freetype encoding remains trivial. > > Also create the corresponding pageblock flag to record the same thing. > > To keep patches from being too overwhelming, the actual implementation > is added separately, this is just types, Kconfig boilerplate, etc. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Aside from the gfp vs internal flag decision, seems fine. Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-13-28bf1bd54f41@google.com>]
* Re: [PATCH v2 13/22] mm: rejig pageblock mask definitions [not found] ` <20260320-page_alloc-unmapped-v2-13-28bf1bd54f41@google.com> @ 2026-05-11 18:07 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:07 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > A later patch will complicate the definition of these masks, this is a > preparatory patch to make that patch easier to review. > > - More masks will be needed, so add a PAGEBLOCK_ prefix to the names > to avoid polluting the "global namespace" too much. > > - This makes MIGRATETYPE_AND_ISO_MASK start to look pretty long. Well, > that global mask only exists for quite a specific purpose so just drop > it and take advantage of the newly-defined PAGEBLOCK_ISO_MASK. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> LGTM. Could be also part of the immediate cleanup series? Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-14-28bf1bd54f41@google.com>]
* Re: [PATCH v2 14/22] mm: encode freetype flags in pageblock flags [not found] ` <20260320-page_alloc-unmapped-v2-14-28bf1bd54f41@google.com> @ 2026-05-11 18:29 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:29 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, Kalyazin, Nikita, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > In preparation for implementing allocation from FREETYPE_UNMAPPED lists. > > Since it works nicely with the existing allocator logic, and also offers > a simple way to amortize TLB flushing costs, __GFP_UNMAPPED will be > implemented by changing mappings at pageblock granularity. Therefore, > encode the mapping state in the pageblock flags. > > Also add the necessary logic to record this from a freetype, and > reconstruct a freetype from the pageblock flags. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> nit: > @@ -434,9 +431,20 @@ __always_inline freetype_t > __get_pfnblock_freetype(const struct page *page, unsigned long pfn, > bool ignore_iso) > { > - int mt = get_pfnblock_migratetype(page, pfn); > + unsigned long mask = PAGEBLOCK_FREETYPE_MASK; > + enum migratetype migratetype; > + unsigned int ft_flags; > + unsigned long flags; > > - return migrate_to_freetype(mt, 0); > + flags = __get_pfnblock_flags_mask(page, pfn, mask); > + ft_flags = (flags & PAGEBLOCK_FREETYPE_FLAGS_MASK) >> PB_freetype_flags; > + > + migratetype = flags & PAGEBLOCK_MIGRATETYPE_MASK; > +#ifdef CONFIG_MEMORY_ISOLATION > + if (!ignore_iso && flags & BIT(PB_migrate_isolate)) (flags & BIT(PB_migrate_isolate)) ? > + migratetype = MIGRATE_ISOLATE; > +#endif > + return migrate_to_freetype(migratetype, ft_flags); > } > > /** > @@ -570,6 +578,15 @@ static void set_pageblock_migratetype(struct page *page, > PAGEBLOCK_MIGRATETYPE_MASK | PAGEBLOCK_ISO_MASK); > } > > +static inline void set_pageblock_freetype_flags(struct page *page, > + unsigned int ft_flags) > +{ > + unsigned int flags = ft_flags << PB_freetype_flags; > + > + __set_pfnblock_flags_mask(page, page_to_pfn(page), flags, > + PAGEBLOCK_FREETYPE_FLAGS_MASK); > +} > + > void __meminit init_pageblock_migratetype(struct page *page, > enum migratetype migratetype, > bool isolate) > @@ -593,7 +610,7 @@ void __meminit init_pageblock_migratetype(struct page *page, > flags |= BIT(PB_migrate_isolate); > #endif > __set_pfnblock_flags_mask(page, page_to_pfn(page), flags, > - PAGEBLOCK_MIGRATETYPE_MASK | PAGEBLOCK_ISO_MASK); > + PAGEBLOCK_FREETYPE_MASK); > } > > #ifdef CONFIG_DEBUG_VM > ^ permalink raw reply [flat|nested] 14+ messages in thread
[parent not found: <20260320-page_alloc-unmapped-v2-15-28bf1bd54f41@google.com>]
* Re: [PATCH v2 15/22] mm/page_alloc: remove ifdefs from pindex helpers [not found] ` <20260320-page_alloc-unmapped-v2-15-28bf1bd54f41@google.com> @ 2026-05-11 18:30 ` Vlastimil Babka (SUSE) 0 siblings, 0 replies; 14+ messages in thread From: Vlastimil Babka (SUSE) @ 2026-05-11 18:30 UTC (permalink / raw) To: Brendan Jackman, Borislav Petkov, Dave Hansen, Peter Zijlstra, Andrew Morton, David Hildenbrand, Wei Xu, Johannes Weiner, Zi Yan, Lorenzo Stoakes Cc: linux-mm, linux-kernel, x86, rppt, Sumit Garg, derkling, reijiw, Will Deacon, rientjes, patrick.roy, Itazuri, Takahiro, Andy Lutomirski, David Kaplan, Thomas Gleixner, Yosry Ahmed On 3/20/26 19:23, Brendan Jackman wrote: > The ifdefs are not technically needed here, everything used here is > always defined. > > They aren't doing much harm right now but a following patch will > complicate these functions. Switching to IS_ENABLED() makes the code a > bit less tiresome to read. > > Signed-off-by: Brendan Jackman <jackmanb@google.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Also good for prep series? ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-05-11 18:31 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260320-page_alloc-unmapped-v2-0-28bf1bd54f41@google.com>
[not found] ` <20260320-page_alloc-unmapped-v2-8-28bf1bd54f41@google.com>
2026-05-11 13:46 ` [PATCH v2 08/22] mm: introduce for_each_free_list() Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-9-28bf1bd54f41@google.com>
2026-05-11 13:51 ` [PATCH v2 09/22] mm/page_alloc: don't overload migratetype in find_suitable_fallback() Vlastimil Babka (SUSE)
2026-05-11 16:44 ` Brendan Jackman
2026-05-11 16:53 ` Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-10-28bf1bd54f41@google.com>
2026-05-11 15:34 ` [PATCH v2 10/22] mm: introduce freetype_t Vlastimil Babka (SUSE)
2026-05-11 16:49 ` Brendan Jackman
2026-05-11 16:58 ` Vlastimil Babka (SUSE)
2026-05-11 18:17 ` Vlastimil Babka (SUSE)
2026-05-11 18:26 ` Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-11-28bf1bd54f41@google.com>
2026-05-11 15:35 ` [PATCH v2 11/22] mm: move migratetype definitions to freetype.h Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-12-28bf1bd54f41@google.com>
2026-05-11 18:01 ` [PATCH v2 12/22] mm: add definitions for allocating unmapped pages Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-13-28bf1bd54f41@google.com>
2026-05-11 18:07 ` [PATCH v2 13/22] mm: rejig pageblock mask definitions Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-14-28bf1bd54f41@google.com>
2026-05-11 18:29 ` [PATCH v2 14/22] mm: encode freetype flags in pageblock flags Vlastimil Babka (SUSE)
[not found] ` <20260320-page_alloc-unmapped-v2-15-28bf1bd54f41@google.com>
2026-05-11 18:30 ` [PATCH v2 15/22] mm/page_alloc: remove ifdefs from pindex helpers Vlastimil Babka (SUSE)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox