From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 229B450095D for ; Sun, 18 Jan 2026 05:48:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768715307; cv=none; b=YjFpU0Q2INqKYkhyXTt/dWcbc1TZ8rzqyPZ7SFvfU81yIz1hKwZNHMVogC0Ru3zfB6zv0wZ1r+RDMloTLlQ1NC1UAVjWRDjV3HwX2RwdmWI417P1SPUVUdrlYYVqeK9VroO3ptdtCMmj9jTKEoW2fM/UVCA0q7m+nOkNrpiUqyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768715307; c=relaxed/simple; bh=aeyJQ0iwcjn7R5YKeXyNuevYQgu+Hrw7PQxo20yFU4s=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=g1yFYm46vzyCfezOsLBVtdj94gcoWy57tChSA5yvAZbvER6k5Eo1P3pniC56ldE1yN74iTRiE9JI16miZwh4A3Eza1e7EQHjC77Apnt8UGzum2HWrkhAL/XRog6LULjaKK8MyZeJ1cO1zT1b8oVWaaudAGf7YWEpxX/bderggDs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A3D2F1650; Sat, 17 Jan 2026 21:48:18 -0800 (PST) Received: from [10.164.10.251] (unknown [10.164.10.251]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45E733F632; Sat, 17 Jan 2026 21:48:19 -0800 (PST) Message-ID: <467ab4d7-1ce2-48d4-bff6-6579216569e2@arm.com> Date: Sun, 18 Jan 2026 11:18:16 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 5/5] mm: rmap: support batched unmapping for file large folios To: Barry Song <21cnbao@gmail.com> Cc: Wei Yang , Baolin Wang , akpm@linux-foundation.org, david@kernel.org, catalin.marinas@arm.com, will@kernel.org, lorenzo.stoakes@oracle.com, ryan.roberts@arm.com, Liam.Howlett@oracle.com, vbabka@suse.cz, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, willy@infradead.org, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <142919ac14d3cf70cba370808d85debe089df7b4.1766631066.git.baolin.wang@linux.alibaba.com> <20260106132203.kdxfvootlkxzex2l@master> <20260107014601.dxvq6b7ljgxwg7iu@master> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 16/01/26 8:44 pm, Barry Song wrote: >>> I mean maybe we can skip it in try_to_unmap_one(), for example: >>> >>> diff --git a/mm/rmap.c b/mm/rmap.c >>> index 9e5bd4834481..ea1afec7c802 100644 >>> --- a/mm/rmap.c >>> +++ b/mm/rmap.c >>> @@ -2250,6 +2250,10 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, >>> */ >>> if (nr_pages == folio_nr_pages(folio)) >>> goto walk_done; >>> + else { >>> + pvmw.address += PAGE_SIZE * (nr_pages - 1); >>> + pvmw.pte += nr_pages - 1; >>> + } >>> continue; >>> walk_abort: >>> ret = false; >> I am of the opinion that we should do something like this. In the internal pvmw code, >> we keep skipping ptes till the ptes are none. With my proposed uffd-fix [1], if the old >> ptes were uffd-wp armed, pte_install_uffd_wp_if_needed will convert all ptes from none >> to not none, and we will lose the batching effect. I also plan to extend support to >> anonymous folios (therefore generalizing for all types of memory) which will set a > I posted an RFC on anon folios quite some time ago [1]. > It’s great to hear that you’re interested in taking this over. > > [1] https://lore.kernel.org/all/20250513084620.58231-1-21cnbao@gmail.com/ Great! Now I have a reference to look at :) > >> batch of ptes as swap, and the internal pvmw code won't be able to skip through the >> batch. > Interesting — I didn’t catch this issue in the RFC earlier. Back then, > we only supported nr == 1 and nr == folio_nr_pages(folio). When > nr == nr_pages, page_vma_mapped_walk() would break entirely. With > Lance’s commit ddd05742b45b08, arbitrary nr in [1, nr_pages] is now > supported, which means we have to handle all the complexity. :-) > > Thanks > Barry