Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp788505lqm; Wed, 1 May 2024 16:20:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXk4332ZV1tckUoyAt2FBD+5QGmnLD38dorgjToOd/qQprYr7W8WqsiO+iF/ISkJbnmv3nCeiJak5a0jhdqrUXJk1F/Ce7rsdbUYXo7YQ== X-Google-Smtp-Source: AGHT+IG+aXfERbeV40FLz0YpR1SRfnbzJEVJM0AkI268i/R3ld6bpxGkgpxxuJcWNJJ4286uQ/mo X-Received: by 2002:a17:90b:ecd:b0:2ab:eff6:e2ce with SMTP id gz13-20020a17090b0ecd00b002abeff6e2cemr4487750pjb.0.1714605659508; Wed, 01 May 2024 16:20:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714605659; cv=pass; d=google.com; s=arc-20160816; b=k4zk6sIYsBdAVuPwc5KGJ5gM8MMFv7/ttB3/gkMe2ZeehQ8UMFtDpe1LLp0K9OsliK O2uOYwfyPUZq1jd7ksFG1EnFA+rRqWyxZ5ZoTvBR2QXgtNMBrX2lyXRxg5Cfhasj61wD NXl9DpGhKePbuOXoKN3dMby/TV1eQVWJX3t0ACVHzdbJnsIqH00666PiiCBTXaa7Q7lB 1qRRMNSpBq0sg6/ttSIX/dpvDalg2mc5Wo26Z/YzyCmIgekkQiNkTCydUB3tgX9yKJW/ J6ImWL/BzZZ6HZfbxeqiSWc7teGcy6GxSJMgbYNIa7z4Ak3e3HRkuyHy6eYmyHutloV5 3pmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=xQGvBTiKc/Smn7PsXZR4CxTZ3TuKVJXHLFhqIG/ZgXI=; fh=eRiufWnjPA3EhuPXgfdkrXSOa7zf1EnYInj/GSYzabg=; b=Zl7bs6dAcvmFzBeo5OPpNhv9oFyT9y5SJdehr0Be/eckjLE59Jk6XD/pcjRfB2Gl1h shJS5nKhRecThexztSVZMRqCUB72y8zipzxhQFW6IhuC2ZblHrlGaDH9TsfAxTs5v9sC mCZzOj0zBrwadjk439Hw9bbb9WOReFrB/vH55Nz7ZXgs+wgLataLCdY+RgaO9Lu+4V7j z4c8u2eg3K8X4t5oPcPYHN8Wo9SlAJHfTibYXM2wQyJAYXR7hEp3f6ljyvLZziqS0yVi Cb/LYS7q/drf70qGChrpGswK8R53njuADJFmjCl87rzkK1ZzO4I6OcUTSHcclRCN+/2T xc2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=S0228WRJ; 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-165836-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165836-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id y8-20020a17090a784800b002a2bab50de7si2286984pjl.121.2024.05.01.16.20.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 16:20:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165836-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=S0228WRJ; 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-165836-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165836-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 223E4281F9A for ; Wed, 1 May 2024 23:20:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB860168AF9; Wed, 1 May 2024 23:20:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="S0228WRJ" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (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 6EF0A165FAA for ; Wed, 1 May 2024 23:20:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714605654; cv=none; b=FXP4r8vM/0G/B9BjgNuTZ9foexmPtyvoctcF6tsxbWlqTXUG67g8QtD/IkBbl/iq8JPotIiFQbQuCqxnXk0/N46JREjqfcRCUmd5kjAewufuspO3WvdrTpQMRL+lfxmed4Ojncs4RsJBXxHoQK+1F0bHoURtc3z97ro08niwj58= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714605654; c=relaxed/simple; bh=KkRajjlS8HkWbirozFoOcw7AxOnIYrAjP74llWm5fr8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ICIavqeTX1JrcYq/KUH2XhPadYaCwQ5gtV2V6LGm9DKOkPm9Khmbo/10beqIWZn2EhpGHwtdivzyMVkaT7sSn8ux9RQNxNSBnvcdT4OKf7Rdzgd6JHu8Nozo4E+wILaxP7eD3U1/9P8Om5Dkt0wOn1K7GcXblVs10e6YIPx76Ho= 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=S0228WRJ; arc=none smtp.client-ip=95.215.58.188 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 Date: Wed, 1 May 2024 16:20:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714605650; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xQGvBTiKc/Smn7PsXZR4CxTZ3TuKVJXHLFhqIG/ZgXI=; b=S0228WRJ4hUXgrkaTPHAYSlfCkqUGGRa6LGZ27deiYvlP+6Wno6frVJeBzRJVNvaNmh0HU VEnYsj1h2SPc4qy3jvzRTuy14Yoz8xcdwamTdF0DMjhLOh/KWXO8QWBfjnXdyFzyNYXZPI i2+rsSTGdNDl+Lv0CXM+QTEoimO53ew= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , Yosry Ahmed , "T . J . Mercier" , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 4/8] memcg: reduce memory for the lruvec and memcg stats Message-ID: References: <20240501172617.678560-1-shakeel.butt@linux.dev> <20240501172617.678560-5-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501172617.678560-5-shakeel.butt@linux.dev> X-Migadu-Flow: FLOW_OUT On Wed, May 01, 2024 at 10:26:13AM -0700, Shakeel Butt wrote: > At the moment, the amount of memory allocated for stats related structs > in the mem_cgroup corresponds to the size of enum node_stat_item. > However not all fields in enum node_stat_item have corresponding memcg > stats. So, let's use indirection mechanism similar to the one used for > memcg vmstats management. > > For a given x86_64 config, the size of stats with and without patch is: > > structs size in bytes w/o with > > struct lruvec_stats 1128 648 > struct lruvec_stats_percpu 752 432 > struct memcg_vmstats 1832 1352 > struct memcg_vmstats_percpu 1280 960 > > The memory savings is further compounded by the fact that these structs > are allocated for each cpu and for each node. To be precise, for each > memcg the memory saved would be: > > Memory saved = ((21 * 3 * NR_NODES) + (21 * 2 * NR_NODES * NR_CPUS) + > (21 * 3) + (21 * 2 * NR_CPUS)) * sizeof(long) > > Where 21 is the number of fields eliminated. > > Signed-off-by: Shakeel Butt Reviewed-by: Roman Gushchin