From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) (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 3D39838C2D4 for ; Tue, 7 Apr 2026 06:52:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.100 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775544765; cv=none; b=NUWi2rIsMcVicSKWioojIjPdOeZfnK1LwUBRRpdhx6e/DNruk/RHYTlN2mUKTRHfggWdDTJAmHDGpFcsL5Jnc1bN5dZmuU9KshmiQyv6PiivjEq1NKpLOyRGi9Di/LIkHwFoRQ9Amrm+8CB8rM1RGyOxc64FOIx4b21M/PdNcFE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775544765; c=relaxed/simple; bh=v6Euw3Rgoc4QCFl2pEQQ2bzcvb5THXo2sd94J7YO8qo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Lno0NSuaqpkpfNxwm6GjjamwUduyHEge5nQjZDhMu64MnGODn7Dc2U22iagHIyPvcrCDmXebOjkoO49dI6804T2URumFoqFxTEYdBdSi6RFleftmM9co0ROVt/PfR4bX4mgFyIYpZAla38gAUFVC357w5Dwet36oREq6MWKApw0= 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=DmClcCxZ; arc=none smtp.client-ip=115.124.30.100 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="DmClcCxZ" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775544760; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; bh=4+YRbn5xz4gzMbT7dbOS4IA4ueE8oXOrYHLytz90mcI=; b=DmClcCxZj8RHiexFkb9m3psM1uz3cIzb6QYbse+e1qD6YnZsm17NYQIIHKWXH4wNOvJM/IVlgYqmLmQn+g+CQ/mWkHnpyanjN+O29kzOpB+Ekvz7xF6mXMHp8Iznv3SjByhCW/TtQ5vksrzBbgrE0xTHns+ooNQryPb9nTGKpNo= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R401e4;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=39;SR=0;TI=SMTPD_---0X0azT3w_1775544748; Received: from DESKTOP-5N7EMDA(mailfrom:ying.huang@linux.alibaba.com fp:SMTPD_---0X0azT3w_1775544748 cluster:ay36) by smtp.aliyun-inc.com; Tue, 07 Apr 2026 14:52:37 +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 Subject: Re: [RFC PATCH v4 2/6] mm/migrate: skip data copy for already-copied folios In-Reply-To: <3e1f520f-e3d8-4ef2-b474-ca4e988bbf2d@amd.com> (Shivank Garg's message of "Fri, 3 Apr 2026 16:38:32 +0530") References: <20260309120725.308854-3-shivankg@amd.com> <20260309120725.308854-8-shivankg@amd.com> <87wlz1zlf8.fsf@DESKTOP-5N7EMDA> <3e1f520f-e3d8-4ef2-b474-ca4e988bbf2d@amd.com> Date: Tue, 07 Apr 2026 14:52:30 +0800 Message-ID: <87pl4bfej5.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 1:52 PM, Huang, Ying wrote: >> Shivank Garg writes: >> > >>> static int move_to_new_folio(struct folio *dst, struct folio *src, >>> - enum migrate_mode mode) >>> + enum migrate_mode mode, bool already_copied) >>> { >>> struct address_space *mapping = folio_mapping(src); >>> int rc = -EAGAIN; >>> @@ -1096,6 +1114,9 @@ static int move_to_new_folio(struct folio *dst, struct folio *src, >>> VM_BUG_ON_FOLIO(!folio_test_locked(src), src); >>> VM_BUG_ON_FOLIO(!folio_test_locked(dst), dst); >>> >>> + if (already_copied) >>> + dst->private = (void *)(unsigned long)PAGE_ALREADY_COPIED; >>> + >> >> IMHO, this appears to be an unusual way to pass arguments to a function. >> Why not adjust the parameters of migrate_folio()? How about turning enum >> migrate_mode into a bitmask (migrate_flags)? >> > > Using folio->private, keeps the change self-contained in migrate.c > > David suggested adding a dedicated unsigned long migrate_info field in the > folio union. I'll switch to that, as this is cleaner and avoid hacky use of ->private. > > https://lore.kernel.org/linux-mm/27b1b602-129f-4bc5-a553-386e8d1f5d90@kernel.org That's good for the original usage of folio->private. That is, to record migration related information for a list of folios. > > Changing the migrate_folio() a_ops signature would touch nearly every > filesystem for something that only core migration cares about, and does not look > practical. We can't add to migrate_mode enum either as currently those values are mutually > exclusive and ordered levels of increasing synchrony (ASYNC < SYNC_LIGHT < SYNC) > And there are checks like this (cc->mode < MIGRATE_SYNC) or mode != MIGRATE_SYNC > This could break it. IMHO, code readability is more important than limiting the scope of changes. The migrate_folio callback of most file systems shares a few common implementations in migrate.c. So, I think it is doable. --- Best Regards, Huang, Ying