From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 AB0F73845C1 for ; Tue, 23 Jun 2026 02:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782183422; cv=none; b=km1jkqoVDddPJSKL35+WfyDA1UUGdR3MxckVpL45TKsHkb/xRm/viGC/pfjFY8cKGahyqMiqenaEGqsgcK5W/BdtN1oVS9rl7pCSCsRNWBfJf5utAJ9K41gaPW+VO2ZNImjSQXYXPlqA6RQp3YZKKruFSwVuKhF/dSPSiMeUFSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782183422; c=relaxed/simple; bh=cq4gwAIKAiSr1nnH84acTmsZcoVvmcL4+9dkCXF00UA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=RyPnY4HOv6on/oTx5nqgjhgHZOUnvUJzYJYt84/XyWeGxD2bjIOFVbruZO7dq/2/bwRTD01JPUaikliVHjVp1GruJvlvi4Rt2Va8HlbCNLtryMw576KvgJ9vrQkOOJxvtVPoYGJCNhylZwzTxr40PcwPX2MpV7cYZlT72DVj3TM= 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=thCksxOr; arc=none smtp.client-ip=95.215.58.178 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="thCksxOr" Message-ID: <08f71d27-db8a-40d3-b906-28405f790e56@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782183409; 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=gamJXZDJG5FoQ+0MRzknU1CG7VksU99okaa549Y0pGE=; b=thCksxOrVcOVb8+PUQuVaNwG96PRajMNWiIzsT7m1Cc/eD1A4hXIZc4cqtegkrbEe2nIRE Z6L7GOJjZCL/Fj16FxaYfthJrd6nUSFj3xiCmnlpgfpFs1/V5nEhpWPc3qfhrpt/CoaBjR ZC4AIccBDvqnrhZ/NDhsEt7zjhQ0Ojo= Date: Tue, 23 Jun 2026 10:56:14 +0800 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v2] mm: mglru: fix stale batch updates after memcg reparenting To: akpm@linux-foundation.org, david@kernel.org, kasong@tencent.com, shakeel.butt@linux.dev, baohua@kernel.org, axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com, hannes@cmpxchg.org, harry@kernel.org, muchun.song@linux.dev, peiyang_he@smail.nju.edu.cn, mhocko@kernel.org, roman.gushchin@linux.dev, ljs@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260623024237.45990-1-qi.zheng@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Qi Zheng In-Reply-To: <20260623024237.45990-1-qi.zheng@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 6/23/26 10:42 AM, Qi Zheng wrote: > From: Qi Zheng > > The mglru page table walker batches per-generation size deltas in > walk->nr_pages while walking page tables without holding the lruvec lock. > The reset_batch_size() later folds those deltas into walk->lruvec under > the lruvec lock. > > The page table walker can run concurrently with the memcg reparenting path > as follows: > > CPU0 CPU1 > ==== ==== > > walk_mm > --> walk_page_range > --> update_batch_size > --> walk->nr_pages += delta > > mem_cgroup_css_offline > --> memcg_reparent_objcgs > --> lock lruvec > lru_gen_reparent_memcg > --> reparent child folios to parent > unlock lruvec > > lock lruvec > reset_batch_size > --> child lrugen->nr_pages += delta > > This will trigger the following warning in lru_gen_exit_memcg(): > > VM_WARN_ON_ONCE(memchr_inv(lruvec->lrugen.nr_pages, 0, > sizeof(lruvec->lrugen.nr_pages))); > > To fix it, add lrugen->reparented to remember the new owner of a > reparented lruvec, and make reset_batch_size() charge pending deltas to > that owner. > > Reported-by: Peiyang He > Closes: https://lore.kernel.org/all/5A9E929D82717101+12fcf643-efb8-4b9a-a53a-1e28cc894f0b@smail.nju.edu.cn > Fixes: f304652609ea ("mm: vmscan: prepare for reparenting MGLRU folios") > Cc: > Signed-off-by: Qi Zheng > Reviewed-by: Barry Song > --- Changes in v2: - update the commit message (pointed by Barry) - collect Reviewed-by > include/linux/mmzone.h | 4 ++++ > mm/vmscan.c | 43 +++++++++++++++++++++++++++++++++++------- > 2 files changed, 40 insertions(+), 7 deletions(-) >