Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1816329lqa; Mon, 29 Apr 2024 23:06:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBSSSiQNklrW7mxnSWkrE3AdYRkO/toYxVcYk/7uL+hLp9mRa2TE44Lq0HNa5tJN2P+CFrIYpDD6QV8vfvnMODPQQrHk5r1jLf+U4TNg== X-Google-Smtp-Source: AGHT+IHJVOnFQuZWD1ATvjXQ013ohcVtaHlnbwRrcOWfjsSZ3Vq1szK2NxipxIXG2I+wShWrZb9l X-Received: by 2002:a05:6a21:3418:b0:1af:5246:69c3 with SMTP id yn24-20020a056a21341800b001af524669c3mr2088828pzb.13.1714457192918; Mon, 29 Apr 2024 23:06:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714457192; cv=pass; d=google.com; s=arc-20160816; b=e+fBDZuqneRdPaIGkZUi8pM17aMw04l6yhgUwLzIax+uPF4Kzy2x/ZoMUB82AiPHOj 0gOoWD0fRe9bn1ruZCARhZ9/EylsB6cc0Wazp4TYZ9N71MYodKd9kD/wSz97pG21vv6/ XEMyPFudsPCzFU3dKd5oTEyAE+Sj1taBT4QznufW3iljsj5NmXVzMxMGSHOKfl8CgjxN rfVC9X8ui5ozyzSIgfOlRklc6+AN11hgCD94zJK0Oa51GiCtgo2nisx+rw30XKrXYvmP eE0Zrn5f/lyGou9kudhaXC3O54ztvrzJOrYtp9bN/6a/2kZGWi+sOxSixC72kGDSwbFj kGpA== 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=PXNo4uDkvXkGowWyfavQ/wvT4lCKFMctusOOMGZYPL4=; fh=wnfKuHOUY4Mz1NUoc5XDTD1KV85duf1XGuItoJ8zV0s=; b=RUuME+zefgB3WD/dxUCjBixWWljuwMZCbUMwYyBOU+qPp8yAq+n2k9B4HPkRB2Xr+t WB2g61KXv4ruINcf8w0MgnEFoKjsLK/A+eYxFKy0kfMcNRWFrPxH/knH2TOJODx9/RGE y5KlA0Ys86TtOsLBWl5DSHTfXpZgvXmq5I/oSh3qqT7pWDwGX5fKfdhV0elbrIxbOyhp z72/AMmM2GztiCBRVPTyaM4Q4dRr8V+R7hnvzaz2wTYBTMwcI59ACP+Rp5IZBL7bqC58 dVw/fGd5ekRBtDqV6+3EjeWPgKCc/ncPQJ0VR0hoFunOWiWRWCHM+I0PSB8y6zPD6ZBx GHUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=m35tfVAE; 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-163385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163385-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b14-20020a170902d88e00b001debbbba48dsi20918338plz.197.2024.04.29.23.06.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 23:06:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=m35tfVAE; 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-163385-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163385-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0D4D5281AD1 for ; Tue, 30 Apr 2024 06:06:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C994917BA2; Tue, 30 Apr 2024 06:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="m35tfVAE" Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (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 7860A2F2B for ; Tue, 30 Apr 2024 06:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714457186; cv=none; b=Fe7pOrSlqhhoKzdok/YT8NcgQ1lofpmrAxqD5NQXSh1vT8+3ogxFV+TJHUk3h3wWQCM6ZnZdMlAJ2UL+IHeN5+dlpCsSrtjoGxSukJcMWD761S5hBY083lhGcI/hC/LCJNDz6RdLO3CTaRafYIzJrMb3EmhPqCduqrpuUPANU7U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714457186; c=relaxed/simple; bh=n/R8IpJB3FeRMW4e+6liO7Ln35uKGLJqrIK6tK5jH9o=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=PAY6RgLo5ILv8J299pmfw7jvU7vbaxhVQ4Hso09UX8FAw04e07pK1S9NZeYKyhiql8FlPnIeMPgI0MH/JaIe4A+vx46lGmVHlHtLavhlS5hv+nW7efZbYuR4mzOt44YByMmbdGdYf/pxKZ6GcTLHrPLLWrpnDbD1UpbU5nRJAls= 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=m35tfVAE; arc=none smtp.client-ip=91.218.175.177 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=1714457181; 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=PXNo4uDkvXkGowWyfavQ/wvT4lCKFMctusOOMGZYPL4=; b=m35tfVAE4Y0Uh5X9Q0T/7eI9OEwXIlToUjoo3IBcXMIkxE3yPu/M+V8skCMNcqs6iYCxEp 0BmG/cM3LDSnVSL5TJXLj0XVVgYDmXKj1NVjT9DGumiEowCHm1RpRAWuMDWohGcG8Ga1xt 8bJtEsJrWTU89Y6mKsUuaGo8/IGKckM= From: Shakeel Butt To: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Yosry Ahmed , "T . J . Mercier" Cc: kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 0/8] memcg: reduce memory consumption by memcg stats Date: Mon, 29 Apr 2024 23:06:04 -0700 Message-ID: <20240430060612.2171650-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. Changelog since v2: Using WARN_ONCE() instead of pr_warn_once() and some changes commit log changes. Also included a patch from Roman. Changelog since v1: The main change from the v1 is the indirection approach used in this patchset instead of rearranging the members of node_stat_item. Roman Gushchin (1): mm: memcg: account memory used for memcg vmstats and lruvec stats 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 mm: cleanup WORKINGSET_NODES in workingset memcg: warn for unexpected events and stats memcg: use proper type for mod_memcg_state include/linux/memcontrol.h | 75 ++---------- mm/memcontrol.c | 244 +++++++++++++++++++++++++++++++------ mm/workingset.c | 7 +- 3 files changed, 222 insertions(+), 104 deletions(-) -- 2.43.0