From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (mta1.migadu.com [37.59.57.117]) (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 740A8305E3B for ; Sat, 8 Aug 2026 01:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=37.59.57.117 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786152978; cv=none; b=Kt+FrVrU6i7HA5KqPBT1bZWfabC5LCegK1ZV5isRhnY/XAgVYs2V88opl7HoQONKKTrCyBDwdBmElso35hsUjlHm260klvC9z2/Ece2tmtFifaz8rnFuRcaqQlUCKAhDE1jHMcVykMa2KP6tunW6DrrHIXsWutObbMyNYjd5Opk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786152978; c=relaxed/simple; bh=VqJ/5vx1+/Tgbi7U14FnSG+i7R5Bb0mRyNoBP8I9kMo=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=AUk2TZax3rJETjEn53ZKz9eC8v7WqsEq39F+YclJfr+MmQ/UmHr0CTgZrLwScn9zR16JhHJ/eWpPh0jgir8LvvtxyhGnf0sXPVoUh+D5xCDs2AJYaJmI4txFl1Pm0YJ9KbaD/7USHeGJZdjH+P1bqNbrOv1EvYM7zrMnrcPO7V8= 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=LI/AXB+s; arc=none smtp.client-ip=37.59.57.117 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="LI/AXB+s" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1786152971; 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=mBze6R+Yde21iZRthxsluHvPvQaZpfZt7IhiN6kDbGs=; b=LI/AXB+sl/lAsfXlZgmEG1cRftwk6gDS1C1hOcW1gnixTb7sKudbdP/f+F4XA2F7tLCXnF e6sGu5pPc2E6cB4241E+FS8cHpWkWeVlOdYK7nVO+Y0KFRjnp2wcHfJhfjzfj4EZURu/jw /XzeJHn5jY4kzwNsJMVweKHyhZ5XDBA= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH v3] memcg: keep folio's objcg same as its node X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <20260807142406.443516-1-shakeel.butt@linux.dev> Date: Sat, 8 Aug 2026 09:35:36 +0800 Cc: Andrew Morton , Michal Hocko , Johannes Weiner , Roman Gushchin , Qi Zheng , Meta kernel team , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Karl Erik Hofseth , stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <9B30927B-4154-4FA4-B62E-425F6EC4FA89@linux.dev> References: <20260807142406.443516-1-shakeel.butt@linux.dev> To: Shakeel Butt X-Migadu-Flow: FLOW_OUT > On Aug 7, 2026, at 22:24, Shakeel Butt wrote: >=20 > memcg_reparent_objcgs() has an inherent assumption that a folio's = objcg > is the objcg of the folio's node. Folio migration across nodes breaks > that assumption: the new folio simply inherits the old folio's objcg > while living on a different node. >=20 > Once the assumption is broken, the reparenting of the folio's objcg = and > the reparenting of the folio's LRU list are no longer atomic. > memcg_reparent_objcgs() handles one node per iteration and drops all = the > locks in between, so the objcg gets reparented in the iteration for = the > objcg's node while the LRU list gets spliced in the iteration for the > folio's node. Any LRU operation on that folio in between resolves its > lruvec through the objcg, and thus takes the lru_lock of the wrong > memcg, not the lru_lock of the list the folio is actually on. >=20 > Fix this by selecting the objcg by folio_nid() at charge time, and by > re-deriving it for the destination node in mem_cgroup_migrate() and > mem_cgroup_replace_folio(). >=20 > Reported-by: Karl Erik Hofseth > Closes: https://lore.kernel.org/all/anMmd1ADrDVwMO6v@work/ > Fixes: f1cf8d2f36dc ("mm: memcontrol: eliminate the problem of dying = memory cgroup for LRU folios") > Cc: stable@vger.kernel.org > Co-developed-by: Johannes Weiner > Signed-off-by: Johannes Weiner > Signed-off-by: Shakeel Butt Acked-by: Muchun Song Thanks.