lkml.org 
[lkml]   [2026]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC PATCH v4 4/6] mm/migrate: add copy offload registration infrastructure
Date
"Garg, Shivank" <shivankg@amd.com> writes:

> On 4/3/2026 4:41 PM, Garg, Shivank wrote:
>>
>>
>> On 3/24/2026 4:24 PM, Huang, Ying wrote:
>>> Shivank Garg <shivankg@amd.com> writes:
>>>
>>>> Introduce CONFIG_MIGRATION_COPY_OFFLOAD, which lets offload driver
>>>
>>> Do we really need a new kconfig option? IMHO, we have too many now.
>>> Because we have a jump label already, the performance difference should
>>> be trivial. Can you measure the size difference?
>>
>> BASELINE (offload=n)
>> text data bss dec filename
>> 23577 1632 32 25241 mm/migrate.o
>> 39202900 14159750 6502152 59864802 vmlinux
>>
>> WITH OFFLOAD (offload=y)
>> text data bss dec filename
>> 24444 2568 32 27044 mm/migrate.o
>> 676 64 8 748 mm/migrate_copy_offload.o
>> 39208218 14163942 6498120 59870280 vmlinux
>>
>> WITHOUT CONFIG (always-on)
>> text data bss dec filename
>> 24444 2568 32 27044 mm/migrate.o
>> 676 64 8 748 mm/migrate_copy_offload.o
>> 39208405 14163942 6498120 59870467 vmlinux
>>
>> It saves around 5.5KB of size, when offload support is disabled.
>> Is it meaningful savings? What do you think?
>>
>>>
>>>> +#ifdef CONFIG_MIGRATION_COPY_OFFLOAD
>>>> +extern struct static_key_false migrate_offload_enabled;
>>>> +extern struct srcu_struct migrate_offload_srcu;
>>>> +bool migrate_should_batch_default(int reason);
>>>> +int migrate_offload_start(struct migrator *m);
>>>> +int migrate_offload_stop(struct migrator *m);
>>>
>>> Why not naming the function migrate_offload_register/unregister()?
>>> IMHO, that sounds more natural.
>>
>> Ack. I'll rename to migrate_offload_register/unregister().
>>
>>>
>>>>
>>>> +#ifdef CONFIG_MIGRATION_COPY_OFFLOAD
>>>> + /* Check if the offload driver wants to batch for this reason */
>>>> + if (static_branch_unlikely(&migrate_offload_enabled))
>>>> + do_batch = static_call(migrate_should_batch)(reason);
>>>
>>> Should batching based on "reason" be determined by the general migrate
>>> code instead of the migrator implementation? For example, if we only
>>> batch copying for ASYNC migration, we should determine that in
>>> migrate_pages_batch() instead of the migreation implementation. Or am I
>>> missed something? If so, can you provide an example?
>>>
>>
>> My idea was that different drivers may have different cost/benefit
>> profiles(e.g. setup cost, migrate batch-size, etc..)
>>
>> For instance, a DMA driver may want to target only bulk migration usecase.
>> And a CPU-thread based driver can be used more broadly, without worrying
>> about setup-costs.
>>
>> But I agree it's premature with only one-driver.
>> I'll move the reason check with target usecases into migrate_pages_batch()
>> and drop the should_batch() callback. If a future driver needs different
>> filtering, we can add it back then.
>>
>>>>
>>>> +#ifdef CONFIG_MIGRATION_COPY_OFFLOAD
>>>> /* Batch-copy eligible folios before the move phase */
>>>> if (!list_empty(&src_batch)) {
>>>
>>> Guard with "static_branch_unlikely(&migrate_offload_enabled)" first?
>>> Better to define a inline function to shorten the expression.
>>>
>>
>> Sure, will add the static_branch_unlikely guard and wrap in a helper
>> function. Thanks.
>
> Coming back to this while reworking the patch.
> I think the static branch guard here is actually redundant. We already check it at
> the per-folio classification that builds src_batch,
> so when offload is disabled src_batch stays empty and the list_empty() check
> short-circuits. I'll still wrap the SRCU + static_call into a helper at this call
> site, as you suggested. Sorry for the flip-flop.

Yes. It's functionally redundant. I just want to know whether it can
benefit performance (in a minor way).

---
Best Regards,
Huang, Ying


\
 
 \ /
  Last update: 2026-04-30 03:24    [W:0.096 / U:13.071 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog