Re: [PATCH RFC 3/4] mm/page_alloc: always move pages to the tail of the freelist in unset_migratetype_isolate()

From: Vlastimil Babka
Date: Fri Sep 25 2020 - 04:39:38 EST


On 9/25/20 10:05 AM, David Hildenbrand wrote:
>>>> static inline void del_page_from_free_list(struct page *page, struct zone *zone,
>>>> unsigned int order)
>>>> {
>>>> @@ -2323,7 +2332,7 @@ static inline struct page *__rmqueue_cma_fallback(struct zone *zone,
>>>> */
>>>> static int move_freepages(struct zone *zone,
>>>> struct page *start_page, struct page *end_page,
>>>> - int migratetype, int *num_movable)
>>>> + int migratetype, int *num_movable, bool to_tail)
>>>> {
>>>> struct page *page;
>>>> unsigned int order;
>>>> @@ -2354,7 +2363,10 @@ static int move_freepages(struct zone *zone,
>>>> VM_BUG_ON_PAGE(page_zone(page) != zone, page);
>>>>
>>>> order = page_order(page);
>>>> - move_to_free_list(page, zone, order, migratetype);
>>>> + if (to_tail)
>>>> + move_to_free_list_tail(page, zone, order, migratetype);
>>>> + else
>>>> + move_to_free_list(page, zone, order, migratetype);
>>>> page += 1 << order;
>>>> pages_moved += 1 << order;
>>>> }
>>>> @@ -2362,8 +2374,9 @@ static int move_freepages(struct zone *zone,
>>>> return pages_moved;
>>>> }
>>>>
>>>> -int move_freepages_block(struct zone *zone, struct page *page,
>>>> - int migratetype, int *num_movable)
>>>> +static int __move_freepages_block(struct zone *zone, struct page *page,
>>>> + int migratetype, int *num_movable,
>>>> + bool to_tail)
>>>> {
>>>> unsigned long start_pfn, end_pfn;
>>>> struct page *start_page, *end_page;
>>>> @@ -2384,7 +2397,20 @@ int move_freepages_block(struct zone *zone, struct page *page,
>>>> return 0;
>>>>
>>>> return move_freepages(zone, start_page, end_page, migratetype,
>>>> - num_movable);
>>>> + num_movable, to_tail);
>>>> +}
>>>> +
>>>> +int move_freepages_block(struct zone *zone, struct page *page,
>>>> + int migratetype, int *num_movable)
>>>> +{
>>>> + return __move_freepages_block(zone, page, migratetype, num_movable,
>>>> + false);
>>>> +}
>>>> +
>>>> +int move_freepages_block_tail(struct zone *zone, struct page *page,
>>>> + int migratetype)
>>>> +{
>>>> + return __move_freepages_block(zone, page, migratetype, NULL, true);
>>>> }
>>>
>>> Likewise, just 5 callers of move_freepages_block(), all in the files you're
>>> already changing, so no need for this wrappers IMHO.
>
> As long as we don't want to move the implementation to the header, we'll
> need it for the constant propagation to work at compile time (we don't
> really have link-time optimizations). Or am I missing something?

I guess move_freepages_block() is not exactly fast path, so we could do without it.

> Thanks!
>