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 97FE4253328; Tue, 29 Apr 2025 18:10:00 +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=1745950200; cv=none; b=qR1gE+4216W0w6h6kRk9XmASXut3Tm+lMBMkR/YfJFWSQ8jxZIZGeGHHFnOygoDMDOuewa/wg9OHEyD+o1FPQ6f8drSXz4ySXVanc5nIbRCusT7//lhWZlb5or0n19HruR5rgDcVKcI79QOElS5OXlxXYdxBb1U5/c8O50+J8tM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745950200; c=relaxed/simple; bh=chntxT41UW8FJB2wdsd+nQyoh4YCNrH18LRxFtDLcBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ljRI+jBdomGltwFCiEFu96FFrxbV5P+cnupb7ztGQHlXzS7Vn52UqrBb6+5m40SgCJeWqItAoLoFM38etaVBwk7U5t8uggSWBbUMByLQ9ZL1d3wsUU+lO0Xirhym6YLID5uh/O+h6pk6T51kIHMw6gkzxXV6jSW7w+1jW7A+KEQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yJCQnftk; 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="yJCQnftk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 200AAC4CEE9; Tue, 29 Apr 2025 18:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745950200; bh=chntxT41UW8FJB2wdsd+nQyoh4YCNrH18LRxFtDLcBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJCQnftk8vesZ8aXZ8HaY4693AnoxDqdb1XxQUl18yd59VrTWs4lcy2oH4BljybQK yvyc9TWTdRUrTl0S80yT5wH8UOFaAWezS+v8yuUDijf4twSbBeuliDHgVBG/LU4pGA aflDgTn0934M+gKjkXIQfWsyiVSmNvcR7/tlSYlQ= 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 , Sasha Levin Subject: [PATCH 6.6 002/204] memcg: drain obj stock on cpu hotplug teardown Date: Tue, 29 Apr 2025 18:41:30 +0200 Message-ID: <20250429161059.501454979@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161059.396852607@linuxfoundation.org> References: <20250429161059.396852607@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shakeel Butt [ Upstream commit 9f01b4954490d4ccdbcc2b9be34a9921ceee9cbb ] 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: Sasha Levin --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9bf5a69e20d87..ab9afcd372a93 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2378,9 +2378,18 @@ static void drain_all_stock(struct mem_cgroup *root_memcg) 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; } -- 2.39.5