From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.69 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795592387; b=HpgGkojnzoJC73EFeCpPMFxg+9h5AqlnKJHL9gi20DH3yG8qTa1Kyf9UXS3vES7Ufy74 AwdQh1kMoIi/eEilnuW6DY477+Hwg2nHrztUBOauZ7RwfL0ki3t1P9KU9MHvaB0XWVDJz EgbR11BP52RN+uq3vY/rEPNUTYck2mxv0HcQE8kLqCtnnwxUSpCgWasb+Pf9fLjpoQ4/A vmHVrGOkjbU9ypTPqyjQdK8coS9hjSARNMdbeUZMGPCrz2QGjb/XlvtzTdtE1oC0MVA77 Xzvt+Y6m+68Zz+jMSecbioFUrnoEe1G/G7PEo+1V14yRzjlVqPNFRIinWAgnoYDZcqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795592387; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=QyuaUJ+4lg3ErXzz2AqnSWN5VklK1zHAWHe8IsT8cPA=; b=2OPKCOagQ1cOvHpQ/Snz1VXU6dPtJEPIBfkFqLUl7DMGrWLohRvKMFrGfIVkASGu37DA +1ogBO2LVq/nmam7NtQspQlwkbBE9i9rUPiTs2KZXYMkyKjes7GBkqTE35TQdJ2vKoOGg qdtXV1s5q+lGmvUSamWNp1V9m/INjn0vXXLVvi0WndxN1o4zbc+nyzNzTVIiyZitK3eMt jr+GOPzYKzqNGJNX1rFAtokAOdlydtUfFU+n5xxocBBmsuRPgfPL9L9kvKFkPkkxF8/uY XwgxzaIvbAUDqjr70QFr9Li2Q11+CWsnAR2ywsHDXK9PNKVLVnPdyA4YS2UXuQCPqVw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XuevB5jE; arc=none smtp.remote-ip=91.218.175.69 Received: from mta0.migadu.com (out-69.mta0.migadu.com [91.218.175.69]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3A9B606A321 for ; Wed, 25 Nov 2026 07:39:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3A9B606A321 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, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=XuevB5jE X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=NdER6oRtsKeTuIl117XW6vlFvInI0gofh/dTxKEIjdA=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1795592384; v=1; x=1796197184; b=XuevB5jEtDVT7lbmN3LnMsW89qiwuRnyo76pyWeMbi5FjQ2efMB2L6U1qRcWOfPMRe3C90S/ OH/FqJpxuOcElORVR6yqFy/NI1OSxwYOfOGvwGh/mRkGo+JzWBchPK7H5vd2A7O6dn04DmYRP33 5f7iNf+tBRdaWSre6gMvphWA= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 882ad378360a5791; Wed, 25 Nov 2026 07:39:44 +0000 X-Mizu-Trace-ID: 882ad378360a5791 X-Migadu-Flow: FLOW_OUT From: "Hui Zhu" To: "Andrew Morton" , "Kairui Song" , "Qi Zheng" , "Shakeel Butt" , "Barry Song" , "Axel Rasmussen" , "Yuanchu Xie" , "Wei Xu" , "Baoquan He" , "Baolin Wang" , "Johannes Weiner" , "David Hildenbrand" , "Michal Hocko" , "Lorenzo Stoakes" , "Harry Yoo" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu , stable@vger.kernel.org Subject: [PATCH v2] mm: mglru: reset the mm iteration cursor in try_to_inc_max_seq_nowalk() Date: Wed, 25 Nov 2026 15:39:31 +0800 Message-ID: <20261125073931.1171242-1-hui.zhu@linux.dev> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Hui Zhu try_to_inc_max_seq_nowalk() advances mm_state->seq without walking the mm_list, but unlike iterate_mm_list_nowalk() it leaves head and tail alone. If it races with an ongoing page table walk, the cursor is left in the middle of the fifo. The next walker reads that as "this generation already started": it skips reset_bloom_filter() and resumes after the cursor. The mm it visits are the ones the aborted walk never reached, so they have no bits in the filter being read and walk_pmd_range() descends into none of their PMDs. try_to_shrink_lruvec() ignores the failed try_to_inc_max_seq() and keeps evicting, so those hot folios are not promoted and refault in the parent memcg, until head wraps around a generation later. Reset head and tail with the seq increment, as iterate_mm_list_nowalk() does. It is safe: get_next_mm() holds an mmgrab() reference and a concurrent walker bails out at "walk->seq <= mm_state->seq" before touching head again. Only reachable from memcg_reparent_objcgs() -> max_lru_gen_memcg(); not a memory safety issue, since lru_gen_del_mm() repoints head and tail under mm_list->lock. Fixes: f304652609ea ("mm: vmscan: prepare for reparenting MGLRU folios") Cc: stable@vger.kernel.org Signed-off-by: Hui Zhu Reviewed-by: Baoquan He --- Changelog: v2: Drop the helper and keep the fix open-coded (Baoquan He). mm/vmscan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6a1af9b92349..3601e58f2a69 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4694,6 +4694,8 @@ static void try_to_inc_max_seq_nowalk(struct mem_cgroup *memcg, spin_lock(&mm_list->lock); VM_WARN_ON_ONCE(mm_state->seq + 1 < max_seq); if (max_seq > mm_state->seq) { + mm_state->head = NULL; + mm_state->tail = NULL; WRITE_ONCE(mm_state->seq, mm_state->seq + 1); success = true; } -- 2.53.0