Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1623841lqa; Mon, 29 Apr 2024 14:06:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVB0MLkLjpXEDWGbR3yWsxloNd2582/xdsMyDdwK4CaDecUyJqgnBMdvPO+KylTGHANO5Rb1wj2dEbwzW1nN/xJhMjg3DAirwe/+nccOg== X-Google-Smtp-Source: AGHT+IH9wMN2OgpSPL4GjaSPREHLfMCPLkKn8454/fpaqRE28D3F5yg/qnXr9jmqEMEiwdwEiN/P X-Received: by 2002:a50:8e5e:0:b0:565:6c72:40a9 with SMTP id 30-20020a508e5e000000b005656c7240a9mr8603312edx.28.1714424795756; Mon, 29 Apr 2024 14:06:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714424795; cv=pass; d=google.com; s=arc-20160816; b=hCAIwqOYnbW8SAsMvH7OGE64Y5+KbnNHsRbNL6WFlB5vfPdVnCad6aSw8DqGS9Ykry QCBrXeitMYn2JwbhNNxTlAllboQ361HlTzedxdIqBSDXceEjyNFBsjZL+CQmTsx0dj9W r+xlTcKnjbpQdKrWCWF8yyOo8dz+/KYcC9vXgCdeJqM8TCrgSHIMbN2b0amyWrN0fPsT WyXPBmiFjzxN8RYOH3rUU3pWKGDGct+MXl/YpACGhGIhn42UacUa8Fg7y0DKCbldinwF Bh3bfbtetlmfTAhIGAPZkIXZXzXz/m6BLry9CtwP9IVjUEyR+Lqtx2GKF6M9Ln2PJPa3 IiCw== 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=RRdids+X4QRv+bPxbj1QerCDqrODkmUYAv3YKJoUxHE=; fh=CzzTLHkTacoooTvvUoTMHS8FRulZhfpGvD94q3XMC4U=; b=iLWp5+J/KBERsiB3sE8GNJnBRbMyWA1SVPwVWJerTWKzCe+G3lDt8orCQipkXATdXv Vo46p6v02tVMEQSeSLQwQUUi9FATJTSxRllNDSkkroi63Q4cOViAz9xHOBraHV0swdwG 2t+viuOiSLdpPGxaP1OhIWV3kamQ1ExuMoqjvIruLIZxUWyZnqKg/xD+0Hk/9F/Ge6/1 CZyQ7sIHYXnwROHb0LZ1ZU4PEjgwVlhCo1lZP+ufZPTOes3x/GM91C0t0jrcAr08wt1j rFfuvi2UrdIyKLLr6FTvGxNDSjDq3EIl61H4/gg3TtnzpUyTanJqd12Qq45VQjluAR/1 Ia6g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YAeGuRwV; 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-163051-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163051-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y5-20020a50bb05000000b005727282b1c0si2577837ede.549.2024.04.29.14.06.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 14:06:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163051-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=YAeGuRwV; 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-163051-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163051-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 7D72C1F224A4 for ; Mon, 29 Apr 2024 21:06:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B34FE17B4E2; Mon, 29 Apr 2024 21:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="YAeGuRwV" 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 3C5D917A93B for ; Mon, 29 Apr 2024 21:02:29 +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=1714424551; cv=none; b=W9sVkIC22xuoxmf98CVMOdpWuFm3jwGEo4b1hqK5QcmCrH1IEuD+DlwgdRYkX9fyP4egfNNKXB4mZtj/QCbJTZ/hsAK+2pgwK8eIJVxc3KJbS68FjYUUcX1mu1XDJrB/ttl3hiNccuHfA/SFWHNl7802nx5MPqFZz6FKoZEWpNA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714424551; c=relaxed/simple; bh=R6DQE5EsEveF1QxT6jB+aOWRYl3SVpGaiivWdByl6x0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lDYc14ley32gJiy8eoEzRnXJTjymzaEEU7GbNAnr3WQxBWnPB8PsuXUUkJSRnLyVbgDUUxTwMuQRwf/bpXHymoSq9HPAebGkMpsCdgbUY88dq01dK6nxJ0tSVXe39C4Mgxqbc9/AlBYR7sA7F/Inca6aSKlVfco3v65BJ+uvlDc= 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=YAeGuRwV; 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: Mon, 29 Apr 2024 14:02:23 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714424548; 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=RRdids+X4QRv+bPxbj1QerCDqrODkmUYAv3YKJoUxHE=; b=YAeGuRwVvnWMG41yijYTcJnXo+X+/idGkOR6uQlipgLmiPtOJmm94Fy2Hp3PXZzq1MhaEY B2HdecrVJDxj9XN6NPrb7ronHcEwd0ONYsx+x+HVunOXNfYcMMcdTACiR2w4Y1/ci2iaN/ qMvcmUyyj/lTsdvaFCvu3GvbNDQOEmU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Shakeel Butt , Andrew Morton Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/7] memcg: dynamically allocate lruvec_stats Message-ID: References: <20240427003733.3898961-1-shakeel.butt@linux.dev> <20240427003733.3898961-3-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: X-Migadu-Flow: FLOW_OUT On Mon, Apr 29, 2024 at 12:46:32PM -0700, Shakeel Butt wrote: > On Mon, Apr 29, 2024 at 08:50:11AM -0700, Roman Gushchin wrote: > > On Fri, Apr 26, 2024 at 05:37:28PM -0700, Shakeel Butt wrote: > [...] > > > > + return x; > > > +} > > > + > > > /* Subset of vm_event_item to report for memcg event stats */ > > > static const unsigned int memcg_vm_event_stat[] = { > > > PGPGIN, > > > @@ -5492,18 +5546,25 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) > > > if (!pn) > > > return 1; > > > > > > + pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL, > > > + node); > > > > Why not GFP_KERNEL_ACCOUNT? > > > > Previously struct lruvec_stats was part of struct mem_cgroup_per_node > and we use GFP_KERNEL to allocate struct mem_cgroup_per_node. I kept the > behavior same and if we want to switch to GFP_KERNEL_ACCOUNT, I think it > should be a separate patch. Agree. Here is the patch: -- From fd6854c0b272c5314bce6c9dee7d3c8f8cee3a86 Mon Sep 17 00:00:00 2001 From: Roman Gushchin Date: Mon, 29 Apr 2024 13:57:26 -0700 Subject: [PATCH] mm: memcg: account memory used for memcg vmstats and lruvec stats The percpu memory used by memcg's memory statistics is already accounted. For consistency, let's enable accounting for vmstats and lruvec stats as well. Signed-off-by: Roman Gushchin --- mm/memcontrol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index d11536ef59ef..2fe25d49cfaa 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5661,8 +5661,8 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) if (!pn) return 1; - pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), GFP_KERNEL, - node); + pn->lruvec_stats = kzalloc_node(sizeof(struct lruvec_stats), + GFP_KERNEL_ACCOUNT, node); if (!pn->lruvec_stats) goto fail; @@ -5733,7 +5733,8 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent) goto fail; } - memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats), GFP_KERNEL); + memcg->vmstats = kzalloc(sizeof(struct memcg_vmstats), + GFP_KERNEL_ACCOUNT); if (!memcg->vmstats) goto fail; -- 2.43.2