Re: [PATCH] mm: migrate: requeue destination folio on deferred split queue

From: Usama Arif

Date: Fri Mar 06 2026 - 11:28:05 EST




On 06/03/2026 16:08, Matthew Wilcox wrote:
> On Fri, Mar 06, 2026 at 05:12:38PM +0300, Usama Arif wrote:
>> + /*
>> + * Record whether the source folio is on the deferred split queue
>> + * before move_to_new_folio(), which unqueues it via
>> + * __folio_migrate_mapping().
>> + */
>> + if (folio_test_large(src) && folio_test_large_rmappable(src) &&
>> + !data_race(list_empty(&src->_deferred_list)))
>
> Why do you need data_race() here? list_empty() contains a READ_ONCE()
> so shouldn't be necessary?

Ah mainly because we dont acquire split_queue_lock before accessing,
similar to what we do in folio_unqueue_deferred_split().

>
>> + old_page_state |= PAGE_WAS_ON_DEFERRED_SPLIT;
>
> You've done a great job of the naming. So much so that the comment
> seems entirely unnecessary?
>
>> + /*
>> + * Requeue the destination folio on the deferred split queue if
>> + * the source was on the queue. The source is unqueued in
>> + * __folio_migrate_mapping(), so we record and check the state
>> + * from before move_to_new_folio().
>> + */
>> + if (old_page_state & PAGE_WAS_ON_DEFERRED_SPLIT)
>> + deferred_split_folio(dst, false);
>
> Again, I'm not sure the comment says anything that the code doesn't?

Yeah there is a much simpler version in reply to Zi's review in [1].
I found the whole migrate_folio_move() function quite verbose already,
was keeping up with the theme of that function lol. I will see if I can
cut down on the comment in [1] as well. Thanks!

[1] https://lore.kernel.org/all/28e48b47-f215-4e4a-b55a-01dbf293ff35@xxxxxxxxx/