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 B6F1E36827B for ; Tue, 10 Mar 2026 08:44:00 +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=1773132242; cv=none; b=NnVrfe1rRyALL75HEDU5yfVtsqFe48Z85nlBpRCHCz2FqXrZVQjl9UKhjsk9B6qMx7Auc3Gz/bxTFSnhHgYoumWNUjrMLPSJVKGeqzdd2z03+o9RMcmwNv3smtLQP4I+b+ivm73ATjtE0b9ISNpCUaiT8ZJyIT+IFFr3sm4eeWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773132242; c=relaxed/simple; bh=GTrRX+Qo2deU/+LKf5Ydfp6W7ciT5ddYqzEpNcbNHZs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=eCCewm4v3sBr9JGlAAs1QEDf6BnNM16efDupn7cs3KgdRDVPi5PbS6ZQKOrkPARjDYsLLMe7XEFk4MGFp2eiqvOBIJERY3tc9yRCcpx1ss8m62+1LNkv9wrpwap30YBvzblguQuLz74JJtjxN9sDoLhRoiHzgq2skUquM2VAyB8= 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 DC80D169C; Tue, 10 Mar 2026 01:43:53 -0700 (PDT) Received: from [10.164.19.59] (unknown [10.164.19.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 508BD3F7BD; Tue, 10 Mar 2026 01:43:51 -0700 (PDT) Message-ID: Date: Tue, 10 Mar 2026 14:13:48 +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 2/9] mm/rmap: initialize nr_pages to 1 at loop start in try_to_unmap_one To: "Lorenzo Stoakes (Oracle)" 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 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> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 10/03/26 2:09 pm, Lorenzo Stoakes (Oracle) wrote: > 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 :) Okay, thanks. > > Thanks, Lorenzo