From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 D852E19992C for ; Fri, 12 Jun 2026 05:17:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781241422; cv=none; b=obMBkgV/sfxrHOipV4oXxRwvg+UnhDTKgbYAVAINsNiwdDGXLxLkyHbVJP/FYpz/e1O1TRx4fYBkpO4X6Hs8ppzT5DVyC/MSyLjcZWY6lgJL/YVUqtfzBZVby8Ly3F/QPF54B3gCU6Al4H3v3g6MJ2Xkhms9szGDYDScs36mQvY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781241422; c=relaxed/simple; bh=7qKrLtwr7ik9C4/MqS2TfpzQWURaZjJlAr6D0lgw4eM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VOkigfO6cbtT4yvIOYoAL+Ij8LIPLMadygXeCyYAJZD5JTpv9o90R91KvT1ybv+PoJ3iWN2eBWhg3pivjXu9chkwZwx887SDCRgziNeOvPitmT5hf89DZZT1OxjG75W5oNH5WocMCc2j03qu08l1d3w2qoHRQanw88l8AD4UP+Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=pass smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=Lvf1anZ+; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Lvf1anZ+" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8raZXv/J5rTvp9TGhy9Jw0/HHc7BoN0/jPQQy86iNe0=; b=Lvf1anZ+ooIiKk0AdaKZIOQ/0J aKIpJ9ep3MYz1mpNHisbDgpSlRFeaiRjwXdeEtSGgr2ZcRwOJXt7US29j6LWrZUyR5HR+w2aiTb9r dABYdHqeOe0D188WNV1MnwrhfPlxWn5ri0IRjQhcJu4LYidXFiZotCsWLDqg0aO9EcPLikEPO/9u9 SZ7/UTEVuAJPTjV7j1JFYe27a3bGpTiBXJoFqifJjbc+pPbHuLzwLUOf1AOEXNT20ZpBc2dF9Aw9U onqkgnEiEBRJocsyhJ9sbMcHKvhZHklDKvMZoaRZxJwBxeeIZgHcA3RJX4q/DA2a2pvUbs2gr2UD+ iAdNcqjw==; Received: from willy by casper.infradead.org with local (Exim 4.99.1 #2 (Red Hat Linux)) id 1wXuG4-00000003Atb-1fgn; Fri, 12 Jun 2026 05:16:44 +0000 Date: Fri, 12 Jun 2026 06:16:44 +0100 From: Matthew Wilcox To: "zhaoyang.huang" Cc: Andrew Morton , David Hildenbrand , Zi Yan , Lorenzo Stoakes , Barry Song , Baolin Wang , Lance Yang , "Liam R . Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Jaegeuk Kim , Chao Yu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , steve.kang@unisoc.com, xiuhong.wang@unisoc.com Subject: Re: [PATCHv2] mm/huge_memory: do not add dropped split tail folios to LRU Message-ID: References: <20260612023456.2424044-1-zhaoyang.huang@unisoc.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: <20260612023456.2424044-1-zhaoyang.huang@unisoc.com> On Fri, Jun 12, 2026 at 10:34:56AM +0800, zhaoyang.huang wrote: > [2] > *F: big folio before split > *T: tail folio after split > CPU0 (f2fs GC) CPU1 (split_folio_to_order) CPU2 (folio_isolate_lru) > *F: pagecache refs = n > *F: extra refs = split > *F: PG_lru set, mapping != NULL > split_folio_to_order(F) > folio_ref_freeze(F, 1) I'll stop you right there. folio_ref_freeze() is called with folio_cache_ref_count(folio) + 1. That's defined as: static unsigned int folio_cache_ref_count(const struct folio *folio) { if (folio_test_anon(folio) && !folio_test_swapcache(folio)) return 0; return folio_nr_pages(folio); } so you'd have to freeze it with 2^order + 1. The 2^order is the number of references the page cache takes on it and the 1 is the reference held by the caller of split_folio_to_order(). If anybody else has a reference to it at this point, the call to freeze will fail.