From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-189.mta0.migadu.com (out-189.mta0.migadu.com [91.218.175.189]) (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 85AB1309DC4 for ; Sun, 11 Jan 2026 13:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.189 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768138938; cv=none; b=STitTKTeZ3Y0QakQdrLj9C9Tr+UoaSum8HCOZabdkmC9dsqGBJrvyntCGF4zTiIX45zA3FUP3eJeaUlBBiFBG5u9n/5Dhjl0WYpExA5kg5EpwwmybFg8xNMd/4M7+u6Sr5W7Geeu2lsnPViLz07Olt3wDrEl/7ZUrTDUFSzc0mE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768138938; c=relaxed/simple; bh=iTeV1jDl6XUQPI8lB725VnojChm1Sxz5Ejv/jsA4D6E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QUBsHDjjyegI835nut9HWMU13gEW4EN4CXRGmvx4rXE4NpF308CmM4qr2AHlgWiDia4zQitp8wNyQT3whiOcMUDi02nMj4BwWkccdWmFToZLVaXvbLrJkI97n8Oc63L8VnR/qr0FWbZ5gA+F0k2UpTpYDqYE7mPTNWK3HDEC8qU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=jxPsPKHi; arc=none smtp.client-ip=91.218.175.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jxPsPKHi" Message-ID: <78a2ab5b-5ece-4d82-a229-594fb8672108@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1768138934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AcaRG6W2GHf2TJkOHLOa6E9Px941H/52oDWSAloAQHQ=; b=jxPsPKHivZ9cUz8HAyuKq24MJq+Bq95285K4NFNc5HaVLwyGwesCTyUZ6RtBMrVTjAOnOI zS20FEQMVyGJtTKK/A/V+2eq+DwbQzemBDt+iyjUCNPf5tH8eNrSY7owefBeHlojoVmRrD ut6TdBDAyUh9BAWiopZG1jVSWGBVuwI= Date: Sun, 11 Jan 2026 21:41:59 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH mm-new v4 4/6] mm: add folio_is_lazyfree helper Content-Language: en-US To: Vernon Yang Cc: lorenzo.stoakes@oracle.com, ziy@nvidia.com, akpm@linux-foundation.org, dev.jain@arm.com, baohua@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vernon Yang , david@kernel.org References: <20260111121909.8410-1-yanglincheng@kylinos.cn> <20260111121909.8410-5-yanglincheng@kylinos.cn> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Lance Yang In-Reply-To: <20260111121909.8410-5-yanglincheng@kylinos.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/1/11 20:19, Vernon Yang wrote: > Add folio_is_lazyfree() function to identify lazy-free folios to improve > code readability. > > Signed-off-by: Vernon Yang > --- > include/linux/mm_inline.h | 5 +++++ > mm/rmap.c | 2 +- > mm/vmscan.c | 5 ++--- > 3 files changed, 8 insertions(+), 4 deletions(-) > > diff --git a/include/linux/mm_inline.h b/include/linux/mm_inline.h > index fa2d6ba811b5..65a4ae52d915 100644 > --- a/include/linux/mm_inline.h > +++ b/include/linux/mm_inline.h > @@ -35,6 +35,11 @@ static inline int page_is_file_lru(struct page *page) > return folio_is_file_lru(page_folio(page)); > } > > +static inline int folio_is_lazyfree(const struct folio *folio) > +{ It's 2026, could we use bool instead of int? Yeah, I see folio_is_file_lru() uses int but that's legacy ... > + return folio_test_anon(folio) && !folio_test_swapbacked(folio); > +} > + > static __always_inline void __update_lru_size(struct lruvec *lruvec, > enum lru_list lru, enum zone_type zid, > long nr_pages) > diff --git a/mm/rmap.c b/mm/rmap.c > index 336b27e00238..fd335b171ea7 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -2042,7 +2042,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, > } > > if (!pvmw.pte) { > - if (folio_test_anon(folio) && !folio_test_swapbacked(folio)) { > + if (folio_is_lazyfree(folio)) { > if (unmap_huge_pmd_locked(vma, pvmw.address, pvmw.pmd, folio)) > goto walk_done; > /* > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 81828fa625ed..ad3516ff1381 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -964,8 +964,7 @@ static void folio_check_dirty_writeback(struct folio *folio, > * They could be mistakenly treated as file lru. So further anon > * test is needed. > */ > - if (!folio_is_file_lru(folio) || > - (folio_test_anon(folio) && !folio_test_swapbacked(folio))) { > + if (!folio_is_file_lru(folio) || folio_is_lazyfree(folio)) { > *dirty = false; > *writeback = false; > return; > @@ -1506,7 +1505,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > } > } > > - if (folio_test_anon(folio) && !folio_test_swapbacked(folio)) { > + if (folio_is_lazyfree(folio)) { > /* follow __remove_mapping for reference */ > if (!folio_ref_freeze(folio, 1)) > goto keep_locked; Otherwise, LGTM. Reviewed-by: Lance Yang