Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp132005lqa; Fri, 26 Apr 2024 17:37:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUcF1jb2KGlvTBlOdLiJ1Hy/qMWbndk3+bvSm6TiYUiOKJUhSaaWm6cHMiqefCbKft6WF0+zKdhFnbvR58vLLUEaJCbyn0Yta1f/lNgAg== X-Google-Smtp-Source: AGHT+IFq9eb7zVuVS/hH5mhb3IpPc9YqLrGvooaC1m0jR7lrZlhg5gSq2vUK9goOq0WpdOqF5xUq X-Received: by 2002:a50:bb2a:0:b0:56b:829a:38e3 with SMTP id y39-20020a50bb2a000000b0056b829a38e3mr3400337ede.16.1714178273785; Fri, 26 Apr 2024 17:37:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714178273; cv=pass; d=google.com; s=arc-20160816; b=lRjXunOFEugzRYkwfMaF1PGoSSnkuHKOcbxAp92MwnWreAM1K8sMuv73+Al3Pk0o/U CHYutGIJa8enefRWR1bYiILfna+rqVmliHVVoe6wnebyanEhtg5OQ4uc5zk4293mwrSw iBVFFTKza33BIBe+mhg/SUup/DrAVql6fkyrbxa4ycSLz5V5RNgAiZKs3gND/uvUdJRt yHKjPwwQh+L47Xz2wi/AEOxa2nRXvULhQFrnxh2fgEIRLTVShjmIUjjWQv1AKYg/YMd/ jGXmb4Gu4EX2pEY39ID2TBQPK67IB0JdaPTNezKiUGWB7HWiEfm1URbMQbPVOOsp6BpE NLkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=WYNfEx046+Zg1e0ZE5FIHgcHeAK6n8iKSeECtiaoy+Y=; fh=RT6qUd/cFk7mA1daRZyPKZ73SkJUv705B/3NiEK9oSU=; b=u92JXHUpudeDdA7Rtc6f8+xFL4WWUAm7Sn/PsrwxxGCesLTinzTLcnsy+CcZfSdR9S KiXTM/jms1Ls7NIeEeR23w6BSoxDd3cVvSv8HOPzbrGOpfHxUR6oXDIko+s5wfX2Ks9k 8M/Z2fQIdnnk4JinWLUpRKm6+rYVYsJ2vxqAVTtZb6BUHuRvxuJLMMha7zHZl+WGCVTr Yh9J0JMBOWZsQVrj0vrYmMm0W4l98zXzbd8X+AZ/YwCsJJFxIjwFwwds6AyJ/A3Sco+5 gFILrB3O/c+7YdobWa1Syk5F8QrOMJ15sKD3lYWw04+ICIDkVThgxgfPHcLeVnxigzi2 svig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vA7Uc4ka; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-160819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id s9-20020a05640217c900b00572405fb851si2325107edy.559.2024.04.26.17.37.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=vA7Uc4ka; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-160819-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160819-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 70FAB1F22B2E for ; Sat, 27 Apr 2024 00:37:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A15E428DDE; Sat, 27 Apr 2024 00:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vA7Uc4ka" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 7EF4325778 for ; Sat, 27 Apr 2024 00:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714178265; cv=none; b=UgGzz76o3T+0iydCZyIIDQjTd/PP9qyRHNG4pltnQgbWWHMe7iaW7dw5NkKavopkbF8zLTzrqkeyMKDu8eP/nzDN4Z7G57xtKnRHcEQ067vQ4tHi43fNM961cjsUTT4ITW0Ju6sOARyuze4lMTGeGep0WvX+FstTMa2dhVPZZDM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714178265; c=relaxed/simple; bh=rj1GLtQS6DQwxX9KbDMMu1V4mPtoT6FkkGxBrZEknzw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MSD3gsIzI9oDLmJm+dl5CoM67yc4FhMykdOKgs4lZwj4+tGg8i2rSPQaTlb0q++zchAHR6q586snglLBDeEeHRtzvOFGFexLc603aZnMfsXTmvUVIMUyoobZcfOrTN7MljzB8CatSFpmJIJcN6MrY84PqJCqwsEt5GmI5l1dQ9w= 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=vA7Uc4ka; arc=none smtp.client-ip=95.215.58.183 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 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714178261; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WYNfEx046+Zg1e0ZE5FIHgcHeAK6n8iKSeECtiaoy+Y=; b=vA7Uc4kaEXk9cYZ+SWIllP0RBW+mMmq3NAYFFagkEPY87n1OK/eBY/5h9xW4/AgF51AaoL q41t1JNMl6wMgbfsY9LQtM8+pqXdiURuIL/wpLHTrX1/8v6eI6TMMjo42G9mP4lwitWQB0 R3b0v0CiiLLNFbp8ecY+uvP3fm4kcqw= From: Shakeel Butt To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/7] memcg: reduce memory consumption by memcg stats Date: Fri, 26 Apr 2024 17:37:26 -0700 Message-ID: <20240427003733.3898961-1-shakeel.butt@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Most of the memory overhead of a memcg object is due to memcg stats maintained by the kernel. Since stats updates happen in performance critical codepaths, the stats are maintained per-cpu and numa specific stats are maintained per-node * per-cpu. This drastically increase the overhead on large machines i.e. large of CPUs and multiple numa nodes. This patch series tries to reduce the overhead by at least not allocating the memory for stats which are not memcg specific. The main change from the v1 is the indirection approach used in this patchset instead of rearranging the members of node_stat_item. Shakeel Butt (7): memcg: reduce memory size of mem_cgroup_events_index memcg: dynamically allocate lruvec_stats memcg: reduce memory for the lruvec and memcg stats memcg: cleanup __mod_memcg_lruvec_state memcg: pr_warn_once for unexpected events and stats memcg: use proper type for mod_memcg_state mm: cleanup WORKINGSET_NODES in workingset include/linux/memcontrol.h | 75 ++---------- mm/memcontrol.c | 245 ++++++++++++++++++++++++++++++++----- mm/workingset.c | 7 +- 3 files changed, 230 insertions(+), 97 deletions(-) -- 2.43.0