From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C18BB2580DE; Tue, 25 Mar 2025 12:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742906009; cv=none; b=eV+skoJNnbDg0RDS738azKbrvIlJoC8x/QdoxO4lxP195qZovA7xRUrGGBVPgW9eZT/AIn51aHPmeS+Tn+2FU15+drC8YqRtG0SUWrnd3VjQmFu4SPYSMaKgJPrECjHfGa72BoZ8xpivPxFzAhmhmisf47GTWlfBbEJMV6foFFM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742906009; c=relaxed/simple; bh=PTFiKX4j1r4pQ3LojLA4syYKH8JiZxE1mkSxQp1cQ24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CfPyhfYviH7XSqynk2NgJD1Igdy3wMpFpcIP/YhUpybukBelGfKagjrBugS3l9tI513qoHSWtGEarsMPG1r+o0ibUR6wE6P/eFA7d7pZ9c9Qr795EH80wFOYJtiWd+d6ku47++Hefbtn+6KdwmzlIFgW3rbufwCybNyljSehzSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hNvPK4j4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hNvPK4j4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76FE9C4CEE4; Tue, 25 Mar 2025 12:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1742906009; bh=PTFiKX4j1r4pQ3LojLA4syYKH8JiZxE1mkSxQp1cQ24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hNvPK4j4IGsCxSoT8cxTUyis1Xtprr39LISm++H1JxC9k/ZuJP2/tWILhFIvVQG6G kjPwg5JnMg7+Z6oXykQvluekPibbKqPFtLiJmgzVqCODVldZzggRLjWdcehUEodUxF 3L90+Q1vHQTbAvoRMWoOhnrAS2aDmzgZPyQx1uwk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shakeel Butt , Roman Gushchin , Johannes Weiner , Michal Hocko , Muchun Song , Andrew Morton Subject: [PATCH 6.13 084/119] memcg: drain obj stock on cpu hotplug teardown Date: Tue, 25 Mar 2025 08:22:22 -0400 Message-ID: <20250325122151.205652640@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250325122149.058346343@linuxfoundation.org> References: <20250325122149.058346343@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shakeel Butt commit 9f01b4954490d4ccdbcc2b9be34a9921ceee9cbb upstream. Currently on cpu hotplug teardown, only memcg stock is drained but we need to drain the obj stock as well otherwise we will miss the stats accumulated on the target cpu as well as the nr_bytes cached. The stats include MEMCG_KMEM, NR_SLAB_RECLAIMABLE_B & NR_SLAB_UNRECLAIMABLE_B. In addition we are leaking reference to struct obj_cgroup object. Link: https://lkml.kernel.org/r/20250310230934.2913113-1-shakeel.butt@linux.dev Fixes: bf4f059954dc ("mm: memcg/slab: obj_cgroup API") Signed-off-by: Shakeel Butt Reviewed-by: Roman Gushchin Acked-by: Johannes Weiner Cc: Michal Hocko Cc: Muchun Song Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1909,9 +1909,18 @@ void drain_all_stock(struct mem_cgroup * static int memcg_hotplug_cpu_dead(unsigned int cpu) { struct memcg_stock_pcp *stock; + struct obj_cgroup *old; + unsigned long flags; stock = &per_cpu(memcg_stock, cpu); + + /* drain_obj_stock requires stock_lock */ + local_lock_irqsave(&memcg_stock.stock_lock, flags); + old = drain_obj_stock(stock); + local_unlock_irqrestore(&memcg_stock.stock_lock, flags); + drain_stock(stock); + obj_cgroup_put(old); return 0; }