From patchwork Tue Apr 23 05:18:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13639354 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76C79C4345F for ; Tue, 23 Apr 2024 05:18:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5ECE6B00B6; Tue, 23 Apr 2024 01:18:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E0D476B00B7; Tue, 23 Apr 2024 01:18:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD5B36B00B8; Tue, 23 Apr 2024 01:18:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AEEE06B00B6 for ; Tue, 23 Apr 2024 01:18:56 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 4C836160E29 for ; Tue, 23 Apr 2024 05:18:56 +0000 (UTC) X-FDA: 82039642272.20.FB9B54F Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) by imf05.hostedemail.com (Postfix) with ESMTP id 7E65A100006 for ; Tue, 23 Apr 2024 05:18:54 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bBLq3m27; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.182 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713849534; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=u+Gs6LB363taYfjAOAQVCNufxH8UGDdaQui3/WUq4mQ=; b=orLKP0nWmHke57kcN8HCZz/ZpLYXcDGUbmr2cyAryvsP1YhLP60Kq9KZ78isCRyX8xLQx2 QJJwbCbeHQrPI3XwYNE/X5BqCdCRNHjyt1YaJbW25JjbRT+hkFc/+ziNDOCts0yCNvmGoR 3bM1vVoEdyGl3LpO0u8bK6cQt9W3afI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713849534; a=rsa-sha256; cv=none; b=EVOcexpKQQqsPXH+ssRRAD5/e70muRbnR1m8SrvqOzbkCZzyVvsM+EAb1qlf5jgTgzdBW2 n7GB9YDUgNI5gaaLpH9YHWtOcPQw+E3Fp209EqcPPtkElkfGicL/YpT5rvzwrVIvjE1aNE juyHfgwE4mGQcnqfLzvD02ln1XXidgI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=bBLq3m27; spf=pass (imf05.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.182 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=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=1713849532; 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=u+Gs6LB363taYfjAOAQVCNufxH8UGDdaQui3/WUq4mQ=; b=bBLq3m27Tn/gftsxnQ+b/3UOGu62ExpEaLl5AhSr/FXbLt9NTj4ccNhUHecUwNpOh6XBQl n0H2Hl4cbxfmZ7MnrEY9xq9LIdVxqQUzUOpOVSCjtO78dntHP4vMKox+oIqGghAnd8OgbE bj27r8Gr7uZCwrCrhcxfB7T8O9c903A= 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 0/4] memcg: reduce memory consumption by memcg stats Date: Mon, 22 Apr 2024 22:18:22 -0700 Message-ID: <20240423051826.791934-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: ozhffigmigdpm44awwcw13tyezyy8duw X-Rspamd-Queue-Id: 7E65A100006 X-Rspamd-Server: rspam06 X-Rspam-User: X-HE-Tag: 1713849534-71765 X-HE-Meta: U2FsdGVkX1/WidI+9WS2NblDQcBCFa9THxfxC1FqmoNQONVBwBeaLH6xnwM2DfR1w6XiOoV1utiXGn1HTmrq0LimmCAVLmlR/k8+wWpNaLcG6DLsp+Xf5mP7KDyava4e1/Sve+e6wqgQO/DYNHHEODyMtwqQyew+F+CNkR9xIc+2vk89j1Rldh0HQdlOKBLnU8vQCPjP3HvqPTx1m3ys9m2LehTGdgBEFlSfDcjJb1DKzspQgVAQKsNbF+xqXhQVpclZsZPwVyhjxm+tEUKk09JYtibswXq4DI0C9SYnKhvvi4Z5Y2Cmidc/1n4/1g7KbfxNCICGCRb4ouB4f+KsqSriPORE1911jNL+YkB3nWcNl347FtRRAHtilxj3hLHA2iSQ8qz1LwGLsaIwKhBeNlpbAzm04UFsI86b57ug7iU96mpGLH85G+u1D3/YeC0taeuU9UJJhgaOCQLHHwf2Nh1t1VgqgQRmRtTYqa+1wiSzDRkVQ3AUHrniwBZdfkqgfnCm/00FJDxjuiaQMki3E+f9QFplyW/jh2U142UT279iLJLttnDlL9Teogae8oya4V27zYXR7ehp+b1KzhnOGlRrNDQCDC0vQDir7luNGIG+4E1tNACCvn8Mq/D1xs/4nyEA7LlUpw/vVcEg3S7LBKCKYqjVh30Og1sfUpWqdRR6nbTsmVtXOSVnKpmAzeJH/Me+qCEm7AQkmdCEeCRCE4KbQmgA7B6NeZD9Cmm+Bt058Iri16CAitoTGpl26XP+iyjpgbLac5X+JuGW8Q2klgMPCrIQTlXzFkISUPSkTirefJ0qpHq31MKlARydMjx4mXnLvhNeyT+JuVTzNSkL/3ApdR291lMT3705JLdCfqVCEB38YExH03CtZkPLl96FaUqxEgKKhP0zc2MHiwwc34qXRCC5WOQUiiCjtqph0aqCuOr1NK6jFXs9LnaPgC4MY/5964BdAtUGDTHBGiP mQrWFq6/ HtPSmnLMCy3g6mogdoolO120evyeDdnWXpaPG/0M0wZzEBLPEw7HsYd4Vv7gSSXL/YaTSkBDgBTkTid4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. Shakeel Butt (4): mm: rearrange node_stat_item to put memcg stats at start memcg: reduce memory for the lruvec and memcg stats memcg: use proper type for mod_memcg_state memcg: restrict __mod_memcg_lruvec_state to memcg stats include/linux/memcontrol.h | 25 +++++++++++++------------ include/linux/mmzone.h | 29 +++++++++++++++++------------ mm/memcontrol.c | 12 +++++++----- mm/vmstat.c | 24 ++++++++++++------------ 4 files changed, 49 insertions(+), 41 deletions(-)