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 7AF893CE083 for ; Tue, 23 Jun 2026 08:42:57 +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=1782204179; cv=none; b=d/dAVmJXpAPUxXzsNf6mbtJrFQicHs8e83A+yDFW68rmApZ+BZQ+vZDUGyOIuebF0zDUAM35a3FhwpQwpnQT5OGUsTWUK+rFqNhx759up7n2A0aaFlMbqMok7KvS8XMRHUE83UqS6wy3J6TPEEkjUgfOi967i58wjzK2s1t0t4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782204179; c=relaxed/simple; bh=apcyADjqiE8fk9NSJLQOIEwwZsOqAW2rHJXWbblmtUc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D06805mEhM2iSDslgKs+gUQkMK5NwfkdFCS4aaiujErz5S2GAiJ2V/K0wBCkwDnT1N0DKajv/ssK7+o9CNGE4OsJmv7AOM/fw+7XgVtT1yywoafj63qJP/1OfRip9LOF8jSwRgj1LQ/KdcnuCqEWRt7MpFw3v5WNb2/P4ucXKl0= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=G549Fzeu; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="G549Fzeu" 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 44EDC1A25; Tue, 23 Jun 2026 01:42:52 -0700 (PDT) Received: from [10.164.19.14] (unknown [10.164.19.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 28FF13F632; Tue, 23 Jun 2026 01:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1782204176; bh=apcyADjqiE8fk9NSJLQOIEwwZsOqAW2rHJXWbblmtUc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=G549Fzeu52BzvudWHBhxRkDR214H/0uxNE6OXRIold2m/bYzwYxocXNWqAmUZHy02 wUw7nMEDNKVsvbszcz5sHDzBdd2TbjBRLM41Ttcvs+b45MgNRNZBOBFwkCqqgjWbQT B4Y3hrKfaBbwh2AUXi86Wyky/2mAhQ6pJ0bHOlZ8= Message-ID: Date: Tue, 23 Jun 2026 14:12:46 +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 v4 03/12] mm/rmap: refactor some code around lazyfree folio unmapping To: "David Hildenbrand (Arm)" , akpm@linux-foundation.org, ljs@kernel.org, chrisl@kernel.org, kasong@tencent.com, hughd@google.com, liam@infradead.org Cc: riel@surriel.com, vbabka@kernel.org, harry@kernel.org, jannh@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, qi.zheng@linux.dev, shakeel.butt@linux.dev, baohua@kernel.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, shikemeng@huaweicloud.com, nphamcs@gmail.com, bhe@redhat.com, youngjun.park@lge.com, baolin.wang@linux.alibaba.com, pfalcato@suse.de, ryan.roberts@arm.com, anshuman.khandual@arm.com References: <20260526063635.61721-1-dev.jain@arm.com> <20260526063635.61721-4-dev.jain@arm.com> Content-Language: en-US From: Dev Jain In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 09/06/26 7:50 pm, David Hildenbrand (Arm) wrote: > On 5/26/26 08:36, Dev Jain wrote: >> For lazyfree folio unmapping, after clearing the ptes we must abort the >> operation if the folio got dirtied or it has unexpected references. >> >> Refactor this logic into a function which will return whether we need >> to abort or not. >> >> If we abort, we restore the ptes and bail out of try_to_unmap_one. >> Otherwise adjust the rss stats of the mm and jump to a label. >> >> Also rename that label from "discard" to "finish_unmap"; the former >> is appropriate in the lazyfree context, but the code following the label >> is executed for other successful unmap code paths too, so 'discard' does >> not sound correct for them. >> >> Signed-off-by: Dev Jain >> --- >> mm/rmap.c | 88 +++++++++++++++++++++++++++++++------------------------ >> 1 file changed, 50 insertions(+), 38 deletions(-) >> >> diff --git a/mm/rmap.c b/mm/rmap.c >> index 06ab1158d4cd1..12bbee57f20da 100644 >> --- a/mm/rmap.c >> +++ b/mm/rmap.c >> @@ -2093,6 +2093,52 @@ static bool try_to_unmap_hugetlb_one(struct folio *folio, >> return ret; >> } >> >> +static inline bool ttu_lazyfree_folio(struct vm_area_struct *vma, >> + struct folio *folio) > > Nitty, but I wonder whether we want to return an int with 0 vs. -EBUSY instead. > > Reading "!ttu_lazyfree_folio" naturally makes me assume that this would be a > success path (which it is not). You have a point but if you don't have a strong opinion I'll prefer to keep as is. -EBUSY won't be consumed by the callers anyways : ) > > > Apart from that LGTM. >