From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7CDB0428480 for ; Tue, 10 Mar 2026 08:39:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773131978; cv=none; b=gbuPynaYW2SBSUjsGmGZeB42GWQqr5z52YcbjMJYV2AJhLu5Y+tVPuXXBNDFI94/a9qmbR/g+gBxB3IUaPLeJExI7DpGm5Lm4BvDugYXi/j1b9cbwMpYTk599HZgV6sVn0Jh7WuliTBSinpbRQR2zcAD+uNSaRExJQ9Pi8WIISo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773131978; c=relaxed/simple; bh=OvTuI5e/v4ITnyizhqNfbGVqo3AxDWqnzY3yfyFe6Wc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=XTRi4CXYrlrDiA0mKeSfPu9Mah3i4yAsaRIIOH8tTFo/D/34ZK4UL+iX/v22niNGuyBVACN8mLhLszLC/J+vyw3KzwfMOf8Yi4ZXYZ0whjOr8AO3SL1iBvhUMgE63ORVT5dSR+jme1K/e5zejO14DidO1odppUZPCt7HtnUz3j4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IgV+/w8O; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IgV+/w8O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6993C19423; Tue, 10 Mar 2026 08:39:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773131977; bh=OvTuI5e/v4ITnyizhqNfbGVqo3AxDWqnzY3yfyFe6Wc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IgV+/w8O3GgzKq1ABNb2HtKj+DPFzHORrYG7fSDM5JH2L4g+/YjmwxspHj4bGvWye Wm+Wdd9OMD0rRKj+w3kWRJ7DcGkBZtcYVi2Ktc2uVsgpF9PcX+qikwgomItdNULvRV 3z+nI4yxFcfkqd4Z5HexyUGCuxH3V14QP99d5fOpWh2dZh8t45Q0ISXUx3rW/sPlOC 8xZwrKSqhlBHXweI2UYLq9iP4SS9vgTO0EzdZxs5IHdRMH30xnVgQEkWIqw++7VdR2 yuyOBV88edQ77ZwIs2PdOnKD9hGhsMwBSqqHCfgKzH+KgGaOV7j6OskXyknCanh3nK fB9S7PV8r/NrA== Date: Tue, 10 Mar 2026 08:39:27 +0000 From: "Lorenzo Stoakes (Oracle)" To: Dev Jain Cc: akpm@linux-foundation.org, axelrasmussen@google.com, yuanchu@google.com, david@kernel.org, hughd@google.com, chrisl@kernel.org, kasong@tencent.com, weixugc@google.com, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, riel@surriel.com, harry.yoo@oracle.com, jannh@google.com, pfalcato@suse.de, baolin.wang@linux.alibaba.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, baohua@kernel.org, youngjun.park@lge.com, ziy@nvidia.com, kas@kernel.org, willy@infradead.org, yuzhao@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, ryan.roberts@arm.com, anshuman.khandual@arm.com Subject: Re: [PATCH 2/9] mm/rmap: initialize nr_pages to 1 at loop start in try_to_unmap_one Message-ID: References: <20260310073013.4069309-1-dev.jain@arm.com> <20260310073013.4069309-3-dev.jain@arm.com> <92b8f168-b135-4c2b-a0be-36c8f8079684@lucifer.local> <58b3878a-24fe-4ed1-a870-604b44da71f7@arm.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <58b3878a-24fe-4ed1-a870-604b44da71f7@arm.com> On Tue, Mar 10, 2026 at 02:01:44PM +0530, Dev Jain wrote: > > > On 10/03/26 1:40 pm, Lorenzo Stoakes (Oracle) wrote: > > On Tue, Mar 10, 2026 at 01:00:06PM +0530, Dev Jain wrote: > >> Initialize nr_pages to 1 at the start of the loop, similar to what is being > >> done in folio_referenced_one(). It may happen that the nr_pages computed > >> from a previous call to folio_unmap_pte_batch gets reused without again > >> going through folio_unmap_pte_batch, messing up things. Although, I don't > >> think there is any bug right now; a bug would have been there, if in the > >> same instance of a call to try_to_unmap_one, we end up in the > >> pte_present(pteval) branch, then in the else branch doing pte_clear() for > >> device-exclusive ptes. This means that a lazyfree folio has some present > >> entries and some device entries mapping it. Since a pte being > >> device-exclusive means that a GUP reference on the underlying folio is > >> held, the lazyfree unmapping path upon witnessing this will abort > >> try_to_unmap_one. > > > > Dude, paragraphs. PARAGRAPHS :) this is one dense set of words. > > > > It's also a very compressed 'stream of consciousness' hard-to-read block here. > > Sure :) I'll try to break this down. > > > > > I'm not sure it's really worth having this as a separate commit either, it's > > pretty trivial. > > Hmm...well, as I explain above, it's not trivial for me :) it is difficult > for me to reason here whether nr_pages can be reused without a reset in > a future iteration. OK you can have it be separate, let's just really clean up the commit message then please :) Thanks, Lorenzo