Re: [RFC V3 5/9] mm: add support for copy offload for folio Migration
From: Jonathan Cameron
Date: Thu Oct 02 2025 - 07:10:26 EST
On Tue, 23 Sep 2025 17:47:40 +0000
Shivank Garg <shivankg@xxxxxxx> wrote:
> From: Mike Day <michael.day@xxxxxxx>
>
> Offload-Copy drivers should implement following functions to enable folio
> migration offloading:
> migrate_offc() - This function takes src and dst folios list undergoing
Trivial but I'd burn the characters to just spell out offc.
migrate_offload_copy() isn't exactly long.
> migration. It is responsible for transfer of page content between the
> src and dst folios.
> can_migrate_offc() - It performs necessary checks if offload copying
> migration is supported for the give src and dst folios.
>
> Offload-Copy driver should include a mechanism to call start_offloading and
> stop_offloading for enabling and disabling migration offload respectively.
>
> Signed-off-by: Mike Day <michael.day@xxxxxxx>
> Co-developed-by: Shivank Garg <shivankg@xxxxxxx>
> Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
Just a trivial comment inline.
Ultimately feels like more complexity will be needed to deal with
multiple providers of copying facilities being available, but I guess
this works for now.
Jonathan
> diff --git a/mm/migrate_offc.c b/mm/migrate_offc.c
> new file mode 100644
> index 000000000000..a6530658a3f7
> --- /dev/null
> +++ b/mm/migrate_offc.c
> @@ -0,0 +1,58 @@
> +
> +struct migrator migrator = {
> + .name = "kernel",
> + .migrate_offc = folios_mc_copy,
> + .srcu_head.func = srcu_mig_cb,
> + .owner = NULL,
No point in setting this to null explicitly unless intent
is to act as some sort of documentation.
> +};
> +
> +int start_offloading(struct migrator *m)
> +{
> + int offloading = 0;
> + int ret;
> +
> + pr_info("starting migration offload by %s\n", m->name);
> + ret = offc_update_migrator(m);
> + if (ret < 0) {
> + pr_err("failed to start migration offload by %s, err=%d\n",
> + m->name, ret);
> + return ret;
> + }
> + atomic_try_cmpxchg(&dispatch_to_offc, &offloading, 1);
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(start_offloading);
> +
> +int stop_offloading(void)
> +{
> + int offloading = 1;
> + int ret;
> +
> + pr_info("stopping migration offload by %s\n", migrator.name);
> + ret = offc_update_migrator(NULL);
> + if (ret < 0) {
> + pr_err("failed to stop migration offload by %s, err=%d\n",
> + migrator.name, ret);
> + return ret;
> + }
> + atomic_try_cmpxchg(&dispatch_to_offc, &offloading, 0);
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(stop_offloading);