From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6638D4C92 for ; Tue, 7 Apr 2026 07:40:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775547629; cv=none; b=A3aGoccSoV/RmVKvfIZhTs9tIOPmqaUo6XKRGAKqLHKOuz+Fpp0mCoKIJfjcYnJw8fx46yMIwZSRJdZqj4kWJwIL4+SxDFzCg7em2EEHiAKM7qBWnJoCC3b5qWRtBqRVfGZGdUO0cZ3FsvzdtI/p9ZQon26R6Ri8Os4lyXsfEpg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775547629; c=relaxed/simple; bh=z26PDORBKjI0Mgsv0OXDR2aHotMHq1+PdahvYdtNucg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=qN05U2EV40byBElEZg/NZm7CDeyyDjjhAt8d195tPnDwZ2PwfqDQVudNNb6SuMXvmqlusJrfGdtXNXf/NJNuAAqF7v929iH7CrgydWv86XWOfDeru9lASzsmofA5knyqXiyJt1xQBgnl/xaih/Tr58ptPGAe6ls6qol02mtFmYg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=F2VGo9uC; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="F2VGo9uC" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775547618; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=DA1gS7QAqLDq83Q/XySCI7Hpj4QTI9z7098AZR9nD+c=; b=F2VGo9uCV3BaNcLDNNr089xFxDMv3iUJe5OHWV9jU4XXfp/jx2+5S6fYi2HIivoFuguGIB4S2LFOSYw1UDpthheER2pI1ASWO5ax40ka/k7D9GhYb6HrCGLsGIca8LzdWTYE4UaGqfEzs0f1TnYk4tMHdjvvt7TRWfJrfZoZclU= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R471e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=ying.huang@linux.alibaba.com;NM=1;PH=DS;RN=40;SR=0;TI=SMTPD_---0X0azkhQ_1775547614; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X0azkhQ_1775547614 cluster:ay36) by smtp.aliyun-inc.com; Tue, 07 Apr 2026 15:40:15 +0800 From: "Huang, Ying" To: "Garg, Shivank" Cc: akpm@linux-foundation.org, david@kernel.org, lorenzo.stoakes@oracle.com, Liam.Howlett@oracle.com, vbabka@kernel.org, willy@infradead.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, ziy@nvidia.com, matthew.brost@intel.com, joshua.hahnjy@gmail.com, rakie.kim@sk.com, byungchul@sk.com, gourry@gourry.net, apopple@nvidia.com, dave@stgolabs.net, Jonathan.Cameron@huawei.com, rkodsara@amd.com, vkoul@kernel.org, bharata@amd.com, sj@kernel.org, weixugc@google.com, dan.j.williams@intel.com, rientjes@google.com, xuezhengchu@huawei.com, yiannis@zptcorp.com, dave.hansen@intel.com, hannes@cmpxchg.org, jhubbard@nvidia.com, peterx@redhat.com, riel@surriel.com, shakeel.butt@linux.dev, stalexan@redhat.com, tj@kernel.org, nifan.cxl@gmail.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Mike Day Subject: Re: [RFC PATCH v4 4/6] mm/migrate: add copy offload registration infrastructure In-Reply-To: <70414c31-d928-41a6-89db-eeb0f34ec07d@amd.com> (Shivank Garg's message of "Fri, 3 Apr 2026 16:41:06 +0530") References: <20260309120725.308854-3-shivankg@amd.com> <20260309120725.308854-12-shivankg@amd.com> <87o6kdzeei.fsf@DESKTOP-5N7EMDA> <70414c31-d928-41a6-89db-eeb0f34ec07d@amd.com> Date: Tue, 07 Apr 2026 15:40:16 +0800 Message-ID: <87ldezfcbj.fsf@DESKTOP-5N7EMDA> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ascii "Garg, Shivank" writes: > On 3/24/2026 4:24 PM, Huang, Ying wrote: >> Shivank Garg 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? The size difference of "vmlinux" is 5.5KB. While that of *.o is 2.55k. Not too big for me. >From another point of view, if we will add kconfig for "migrator" implementations, we can make this general kconfig option invisible and be selected automatically? >> >>> +#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. In general, I think that "reason" based policy should be in the general migrate_pages function. While "batch size" based policy can be in the migrator implementations. >>> >>> +#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. --- Best Regards, Huang, Ying