From nobody Fri Apr 3 10:17:52 2026 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) (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 B00143DEAC6 for ; Tue, 24 Mar 2026 11:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774353022; cv=none; b=b1MU9Rac1XrbgZ+YSd/hqrmdXkh9YwpudU6YIMF/HKp4HgP+FjHEMbqEMQhIUFJuwhFxJXLK4A/tSgYpmcfkvxIXLzmCiYufDPTk7gKbcxF/yuj7v7R8Q+vTe5lw3oBEd3wDjw3ES/JBZoUcm9sCJTt05TenqKKuFajfExLxwhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774353022; c=relaxed/simple; bh=hOzZMdwd2QLy0gdmvBnphW6umDmVAKGtcdIiejQ0cnc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rcljmNbFgPcaysRvvkavRu6B0UQrs2xM7003Miq5+oAiOR0G9fXz0AjC9RXPgTEMJyrdeWQDzndRERmaQl/XRFK9y3f9YhNxmmM9FkTDc+E4UfXAH53ibTBzPPZCtqWWRJVw1oOGcSbo7pz4PF47E2zlK5M9DZLsgAS8lBhR004= 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=lzTs3iuR; arc=none smtp.client-ip=95.215.58.181 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="lzTs3iuR" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774353017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1H0PcRwRWsj1424kk+Vkpn7bu1YblVD7xgckWcbNsX4=; b=lzTs3iuR1Pwv68Prted2fEIVq4VUS4eCdaB1zvJOFuJdsux7ry8b1utL9Ph3MCObjnAYzS 3aaZ5KgPl44IF+KmJUNzrTv+ifD33oSkuTsr01h/xiGYiqN0Z3wxbXEuXqg8gVpNpLhQLZ rabGQdpt6g4fUHahmu88tNqiWC/qb3Q= From: Qi Zheng To: hannes@cmpxchg.org, hughd@google.com, mhocko@suse.com, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, david@kernel.org, lorenzo.stoakes@oracle.com, ziy@nvidia.com, harry.yoo@oracle.com, yosry.ahmed@linux.dev, imran.f.khan@oracle.com, kamalesh.babulal@oracle.com, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, chenridong@huaweicloud.com, mkoutny@suse.com, akpm@linux-foundation.org, hamzamahfooz@linux.microsoft.com, apais@linux.microsoft.com, lance.yang@linux.dev, bhe@redhat.com, usamaarif642@gmail.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qi Zheng Subject: [PATCH] fix: mm: vmscan: prepare for reparenting MGLRU folios Date: Tue, 24 Mar 2026 19:49:37 +0800 Message-ID: <20260324114937.28569-1-qi.zheng@linux.dev> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Qi Zheng The lru_to_folio() returns the tail folio, and the lruvec_add_folio() adds folio to the head, so the tail page is colder. Since we always assume that the folios in child memcg (about to go offline) are always colder, we should use list_splice_tail_init() to reparent the child folios to the tail of the lru list of parent memcg. Reported-by: Harry Yoo Signed-off-by: Qi Zheng Reviewed-by: Harry Yoo --- mm/vmscan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 33287ba4a5003..e4a1078254ff1 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4524,8 +4524,8 @@ static void __lru_gen_reparent_memcg(struct lruvec *c= hild_lruvec, struct lruvec int parent_lru_active =3D lru_gen_is_active(parent_lruvec, gen) ? LRU_AC= TIVE : 0; =20 /* Assuming that child pages are colder than parent pages */ - list_splice_init(&child_lrugen->folios[gen][type][zone], - &parent_lrugen->folios[gen][type][zone]); + list_splice_tail_init(&child_lrugen->folios[gen][type][zone], + &parent_lrugen->folios[gen][type][zone]); =20 WRITE_ONCE(child_lrugen->nr_pages[gen][type][zone], 0); WRITE_ONCE(parent_lrugen->nr_pages[gen][type][zone], --=20 2.20.1