From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8845F339701 for ; Thu, 18 Dec 2025 13:45:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766065553; cv=none; b=eVeJnhZOcWWl8lmUXdcsZEu0RSM5FQE09XPptusnL1yp5FriVkt9eTsgezVdN2zjgO/jVmrf8X5QIr/D/y3YE1P14l5dVnQ8x3DU93OTEEOS6mNZ6a5yBC12lCZKJbUHvywhBmGoqlBTN8r0wH9Lh/P9NC4ITvraw7i2AF076JA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766065553; c=relaxed/simple; bh=1lcHYZLIEywXGzhjdYArWAPhpkkoaX7i0+X/MDQj6nE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=st6R+QyYDzqkC4FA5on/7sGJeNghNlqjGKJBm75G7qM/uJwKny0QN4FauFG5Kz3iHl3HYhRORk9Fg5VAIdjWwI8rWD1Bd3iDUe5O4yjyzkXTw7fq89kxBFPBM7NBAf4PNvk0EaDfgBEgBMhEmSbPGxfWeR2V5f/HVyZdJF71SvE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=mMpeTU+o; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="mMpeTU+o" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8b144ec3aa8so65159285a.2 for ; Thu, 18 Dec 2025 05:45:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1766065549; x=1766670349; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=pvIGD3XhABoeshtW2+k0QV9MFWwD4zZ6lmu7IG4CN2c=; b=mMpeTU+oqP88tbl+YFMQsvDFdctzgoqYgzHSXXBTN1TH+SKYndrcrsnao7olp2Jx1P pgEfynT20tL5laQJibLNgMeO78czSqyGlC3lo72j6Otj2jIRAqo61as5/+R+n/0enHfQ yR/jciVX74yDERGv4d+R1Q6l76ZhqGJvlz70XY6JmjhbpBlwv1vT20JhKJ/9p6lYPLl1 8ntAOoTO0Qef26civyE8QPhepTim7ZbAweLei0sTk5r4LBgYaGFlss08x/v3jzNyVU2b pYhcNaLloxnaV4MohARtICCS+nMyOMx3DDINaRiICRGFzenRP2j1OoH5Fu0Q033hSfMs 0boA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766065549; x=1766670349; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pvIGD3XhABoeshtW2+k0QV9MFWwD4zZ6lmu7IG4CN2c=; b=DfBX9xnMASqF+CJtt58tjMumxIO7uTbLDJhwWHyK8YYqgd2+M5NwpzR2xOnOQHinzT tumTomMpTHVE82hzAZKHuo1tQJtDiBSFXMBQZBuONPYvUn9MCa48wXpaP6qyRZmv9aCB +I/15yvcyE3xWWYn36ysb0tdc85Zaa5tawLaHk4ht3Dtr7pot9NnKs+VE1oW8wHdZb83 QBpHh+pvY7BhlYStbM4Gi0v266xqIQhOdWEE4ffSC1A9GjVP/NlfKws8luSNON22iLHG fEy1RlG9RVvGZFT2w11GrXJxzK/z2GdnDdHmXtbuvAQsfkL7G8BJtsurFlR9B6DRdr0Y 44pw== X-Forwarded-Encrypted: i=1; AJvYcCXAx2VV1PbxcWmPCw5Em127MwuVFFb8YMSxQ0UOWz+5FikApidjVvdpvI26QfcOGSF1v9TlWWU5uyJs3wA=@vger.kernel.org X-Gm-Message-State: AOJu0YxHi6Pa15qaORrbOZpH5NOcaLMnLxXeApeRIEAdJ8w8WeIcAQZC YSV31/G5TxOjRUUMNYwk2h2FzHqwaZr6TU+I5WWChwqObbz3FRV99k0xjN8nUjeG6TU= X-Gm-Gg: AY/fxX5n4eF5ltRg4+abMlywySGzyvSK9a0F/gnqyThV3VFtSKcsAkrm1nD7KjfYliZ CDC1h2urEEbtjN9O8I7ayuDWT4IH4T7KUrboerL64EN3yy6UYlimw42pOxjghnJfCVrTfGz+RUl io5ej4UHswBvASQhi8r/PJuEnSV6NB30JWHqvFFAw0mGq88h8GgQR/XdNzygk/8M6kl93Bpwhnc lnmxnoC0GUFs+OQ+rXZKChI/2BSqpIe76kcRQleENEMKWbkCTfnbwPUsHyERlP1LMagwYOntkJ/ yIdw/SUXS14OR5k5nwX5dn8JGBEjsJZiVRTQhYvLdTb8aB02JU6Ie/7dtpetIORj7sbY68FIAVo sGyKfRXPpuhM/I0tbUCaI1d1dXRLTmKOW+4D0ORGuVjqGmVAR5He1lg8E7gf+G6fbDOhT9miEqt ApiHO8gCCYQQ== X-Google-Smtp-Source: AGHT+IHAR30jxVI+lBEnXpDkahfpDPcr5qT9JVMfZp+S17qgX37B1fvWEalT5dou0/zVepFQknr8zw== X-Received: by 2002:a05:622a:1e94:b0:4f3:4415:e8f4 with SMTP id d75a77b69052e-4f34415eae2mr141964871cf.38.1766065549231; Thu, 18 Dec 2025 05:45:49 -0800 (PST) Received: from localhost ([2603:7000:c01:2716:929a:4aff:fe16:c778]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4f35fd60192sm15091761cf.19.2025.12.18.05.45.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Dec 2025 05:45:48 -0800 (PST) Date: Thu, 18 Dec 2025 08:45:44 -0500 From: Johannes Weiner To: Qi Zheng Cc: 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, 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, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Qi Zheng Subject: Re: [PATCH v2 26/28] mm: memcontrol: refactor memcg_reparent_objcgs() Message-ID: References: <8e4dff3139390fc0f18546a770d2b35c9c148b8b.1765956026.git.zhengqi.arch@bytedance.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: <8e4dff3139390fc0f18546a770d2b35c9c148b8b.1765956026.git.zhengqi.arch@bytedance.com> On Wed, Dec 17, 2025 at 03:27:50PM +0800, Qi Zheng wrote: > +static void memcg_reparent_objcgs(struct mem_cgroup *src) > +{ > + struct obj_cgroup *objcg = rcu_dereference_protected(src->objcg, true); > + struct mem_cgroup *dst = parent_mem_cgroup(src); > + > + reparent_locks(src, dst); > + > + __memcg_reparent_objcgs(src, dst); Please have __memcg_reparent_objcgs() return the dead objcg for the percpu_ref_kill(), instead of doing the deref twice. And please use @child, @parent (or @memcg, @parent) throughout instead of @src and @dst. > + > + reparent_unlocks(src, dst); > > percpu_ref_kill(&objcg->refcnt); With that, Acked-by: Johannes Weiner