From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta0.migadu.com (out-180.mta0.migadu.com [91.218.175.180]) (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 00BF8284686 for ; Sun, 4 Jan 2026 11:42:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767526952; cv=none; b=SL3jvj7GDGhxexhvVpOPzwdImV/otqSXLvWZbj+fCpUZGBpBg3FW6NRDXz9upi6gWxcYipPIri9zI2RjidKYxIuK4Kcv7cFa9xEk2oDWOORX96E80FPwxhvA/le1S8RMNWEbnywj7WYPn39T8uSU2wsB8NgIKdKMtdlZBWvHuA8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767526952; c=relaxed/simple; bh=zCw5hFqpvSBRPAPKzLlqJyRccRJb0rTTH6dXwLKlTWo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=b7RUrgdt6xtgZBAWVKlG6M2u5qf80W2Z2CiYj82nq9+YLagj3Bg/V3awbPLyERK7Fg1Sh9cy7zEeWmYw5v6wbg4yN2iUIDKUab2pKy8k4IK1lPIrSZZ/OdVEhSQqAm8s2auWh3PWKp64umjCEtvtBqrJKrhUMhDtCEj7Up4utYY= 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=RpICdXFw; arc=none smtp.client-ip=91.218.175.180 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="RpICdXFw" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1767526946; 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=AOwFX5tiVkgDyyRQLg53zLZoYmPa6rEzkBzCc52YJus=; b=RpICdXFwM2bpv2uDR71rh9y/MhZPTu5CAXYOzxJZzG778IK7V2psirnGHr197RexXfyoe3 W2kgrUs/lvzqTxvrecaYIWYJKymJYAfV5aQWnOWJQQMcscf6OfZJpLRj8m2srI6BSQG40/ pyHgXe5dGBjx7LZzmXzJ4fwwRKh9uS4= Date: Sun, 4 Jan 2026 19:42:16 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v3 4/6] mm: add folio_is_lazyfree helper Content-Language: en-US To: Vernon Yang , baolin.wang@linux.alibaba.com Cc: lorenzo.stoakes@oracle.com, ziy@nvidia.com, dev.jain@arm.com, baohua@kernel.org, richard.weiyang@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Vernon Yang , akpm@linux-foundation.org, david@kernel.org References: <20260104054112.4541-1-yanglincheng@kylinos.cn> <20260104054112.4541-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: <20260104054112.4541-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/4 13:41, 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 | 4 ++-- > mm/vmscan.c | 5 ++--- > 3 files changed, 9 insertions(+), 5 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) > +{ > + 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 f955f02d570e..7241a3fa8574 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -1838,7 +1838,7 @@ static inline unsigned int folio_unmap_pte_batch(struct folio *folio, > max_nr = (end_addr - addr) >> PAGE_SHIFT; > > /* We only support lazyfree batching for now ... */ > - if (!folio_test_anon(folio) || folio_test_swapbacked(folio)) > + if (!folio_is_lazyfree(folio)) Please rebase against mm-new. Commit[1] already supports file folios batching in folio_unmap_pte_batch() + /* We only support lazyfree or file folios batching for now ... */ + if (folio_test_anon(folio) && folio_test_swapbacked(folio)) [1] https://lore.kernel.org/all/142919ac14d3cf70cba370808d85debe089df7b4.1766631066.git.baolin.wang@linux.alibaba.com/ Thanks, Lance > return 1; > if (pte_unused(pte)) > return 1; > @@ -1934,7 +1934,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 670fe9fae5ba..f357f74b5a35 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -963,8 +963,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; > @@ -1501,7 +1500,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;