Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp146682lqm; Tue, 30 Apr 2024 16:09:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWRJetEgMv3nIvu6ftzAsyML0ZqHvdruMXkD+QbXTKct27IO2GeaoUEXEpEBshaDJgnAZWeAJwBxF2RKtu+hAtcSwBdFAJ+g/OfBwfrqg== X-Google-Smtp-Source: AGHT+IHOx2lOJPWV6gn+wrWg7xQTQcoNl6cuqmgnzluokJ3zKSCCb/wZEgQTIlm36duclXPrs2NB X-Received: by 2002:a05:6a20:9759:b0:1af:66aa:7fc7 with SMTP id hs25-20020a056a20975900b001af66aa7fc7mr1065405pzc.3.1714518555608; Tue, 30 Apr 2024 16:09:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714518555; cv=pass; d=google.com; s=arc-20160816; b=L356iZ+tx1umY8m2wWYkdolnm/amwgD/SX2SB35ZWLx+LtPleGSgP+w5RZGEGxTBpV BMUB3uGHSLScEtwCxSe1m35k9R2JQzeOz7NZYh9hN79ClzurqjsVlePv+j3L/MuWPt6m hxf0svLJsl7zicF+7QTmzB6zS5ktilrTbJwKO2z/+pxuBPWziRBixHipIEYS8prGqCVV X2CzGurZ4QhsVM6utrLYpNvW7wlYOE3i+YLG2ZUA/6u32V79TGpt77t0C2zZryatluoc ZUukjQlBSBbbx+l41XaTKCrwQYqNoCHzC5uPWLtBYSOrxfkzfK39x69xu95vCuE2VVtq ySrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=hWHSx8x3CglXCpDsqd2sqLojUv7uUIhFAB1g3nMJgVQ=; fh=HHzFcwzG8ORy39kNilyyeAZA8kC1D8UQWD4ctlFNHHo=; b=HKVfAnYjws0BJVzr4hsVQXMBMMqPmnrXw53iqAupdp0yfsFSv3vy/m6qAxEwNtA+3F dDwAAAbYN8GBNdP2o80iqkKMnUhU5u4IPYPQlwSbkPgrMOmvpvw8/SPu7A5tba4uLn0N Ds5tfPUuXDgMkCSqHZ61qbQoy8RAVzXjmgWFh18Hqqdxkf1F63z/Ep8JVmGvvzYydzeD bVDZJdpVwLgs8/gelZ+m+a3D+b/FF4mPw8Nb5SAdtf+edtXlniqgJG8LLSkwSgS4ip5y sFDgCyt+Xq4GFlydkvAGWsNL2OOmERvhR6vY+mFBJOVsT2MPc39UBNlTjHryIqbcvZ+H i7Ig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Wl3R5p/X"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164792-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id kp7-20020a056a00464700b006ece3da5268si22818956pfb.391.2024.04.30.16.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 16:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164792-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=@google.com header.s=20230601 header.b="Wl3R5p/X"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-164792-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164792-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 6096A28484D for ; Tue, 30 Apr 2024 23:08:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D6BE1BF6F1; Tue, 30 Apr 2024 23:07:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Wl3R5p/X" Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4CC21A38DE for ; Tue, 30 Apr 2024 23:07:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714518466; cv=none; b=JFfHaD00sdI0/UouOFA/W2En4zu3v5KjY+F5SL3VCOG/BZFKviGJzhl5vAN1I20Iu85myf1bhFCRt4z5TIY10SVy+D+1xNwt0OHK1sy2aAw/DHSKVKgHK73sta5fm6hmLRqPDChiPOnCQtfQYZX+16mEOE6je0stW5sxP1OxSTI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714518466; c=relaxed/simple; bh=uPucxD96zlnvHpGfo/0h9rz4gjVxdwhwNcSJTZ2X/ng=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IOy1ZXJKh02XQPHe1kPWrFF5WQxy71TLCQyPXDWzvLxJqb6wTO6mRaihMXGNQBfA7mFCSKSOJYRKGcjxTEcLUoAIqPnv92GqqJPiu9GcYkd6zVnGpMLwQlfjdqeG2QgtbKwNThV1x4iLCEIwukaDASBQWyR8QOAgElORbXChsaY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Wl3R5p/X; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a58eb9a42d9so483466466b.0 for ; Tue, 30 Apr 2024 16:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714518463; x=1715123263; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hWHSx8x3CglXCpDsqd2sqLojUv7uUIhFAB1g3nMJgVQ=; b=Wl3R5p/XX1iuunawwp/dkVu1MR4D33X+xxoxG9o5GlAUCgF8R0iOj2iajOvRFmYUg2 aRGLjJMAsVb+MKk9nZDqwntjseq64TjAUi/niCUNYdic4wRUFbOqm2PSW5qoaGHJjAyj NgnbpOvFGEJyM/ICzJ0ZSQ3o/gg76T4vsQ9i8jYAv1tDJcL1gWzsN9UV9wAVKFE6wJIF /WdQ2jtCW5CWHQCEsMhHZZVGptiVsF3yZHpMBwuuLZQlter5FAC1jlrV8xzKyY96OO9T tGdGsqDvCM625bSqqxV98v4BKpEKl0DhmwhxNo7jZkjRtaa6VBbs8o5PqpWR0DvQN+vw stAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714518463; x=1715123263; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hWHSx8x3CglXCpDsqd2sqLojUv7uUIhFAB1g3nMJgVQ=; b=QGAs1AJ3U61JasKngwHuj7mWHLooA6VJ5GOjd317+5IyhzgJLoC92Y6htOC02w6iqm UgbSUEylkJK88XSxXjyotzJPs6YSey9Xp78ElEdo4w93a0fP2fQXhrTdbd8v2ZtMoCRk afeOy6idRklLjOQVydOEQaz9jg/G248IX7EPRMcdOpUyQrherJ3/NcAKduXnQQ/EQuKt ZbTSFQn7Vfz7FyTV3by6+Q443WVm4NE5olt2utwV5fe+j9tplfM194JYgGQeds1pRTnJ /Gg7t990567gCmmT6lQXxYhZC4eeB5EF6Jqr1IrFp66m4gIoaoTXqFeeRF9LN6vEj7Rf UJ0Q== X-Forwarded-Encrypted: i=1; AJvYcCVRbzi48VC3unRSjw0jGmxoTTEPCTmxm6+uQaB0RcrlhD6ivyw2KrBeWV1WXYhXo08wosAjPYmeZ4ejz3WJa8XnEb2Le4Z13XMoEHL6 X-Gm-Message-State: AOJu0Yys7OjXvWuZO8t4s7K6BtrIQveoIPb1F/7ryJZ9pzB6ofNTQeI9 jCGZ/7k2v9CmiHPob/6M1ZA1Vx2IvjMlY1/lUthy5Suun/XNSSDiQh36wcHyCQW0jQ8IoXqkEOk DFjXrp29moiJfYMwTG7qI4vQmp2l8RwdXFxGU X-Received: by 2002:a17:906:b351:b0:a59:674:a297 with SMTP id cd17-20020a170906b35100b00a590674a297mr692168ejb.64.1714518462865; Tue, 30 Apr 2024 16:07:42 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240430060612.2171650-1-shakeel.butt@linux.dev> <20240430060612.2171650-5-shakeel.butt@linux.dev> In-Reply-To: From: Yosry Ahmed Date: Tue, 30 Apr 2024 16:07:05 -0700 Message-ID: Subject: Re: [PATCH v3 4/8] memcg: reduce memory for the lruvec and memcg stats To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , "T . J . Mercier" , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 30, 2024 at 4:00=E2=80=AFPM Shakeel Butt wrote: > > On Tue, Apr 30, 2024 at 10:41:01AM -0700, Yosry Ahmed wrote: > > On Tue, Apr 30, 2024 at 10:38=E2=80=AFAM Shakeel Butt wrote: > > > > > > On Tue, Apr 30, 2024 at 01:41:38AM -0700, Yosry Ahmed wrote: > > > > On Mon, Apr 29, 2024 at 11:06=E2=80=AFPM Shakeel Butt wrote: > > > > > > > > [...] > > > > > + > > > > > +#define NR_MEMCG_NODE_STAT_ITEMS ARRAY_SIZE(memcg_node_stat_item= s) > > > > > +#define NR_MEMCG_STATS (NR_MEMCG_NODE_STAT_ITEMS + ARRAY_SIZE(me= mcg_stat_items)) > > > > > +static int8_t mem_cgroup_stats_index[MEMCG_NR_STAT] __read_mostl= y; > > > > > > > > NR_MEMCG_STATS and MEMCG_NR_STAT are awfully close and have differe= nt > > > > meanings. I think we should come up with better names (sorry nothin= g > > > > comes to mind) or add a comment to make the difference more obvious= . > > > > > > > > > > How about the following comment? > > > > The comment LGTM. I prefer renaming them though if someone can come up > > with better names. > > > > I will be posting v4 and will change the name (still thinking about the > name) becasuse: > > > > > > +static void init_memcg_stats(void) > > > > > +{ > > > > > + int8_t i, j =3D 0; > > > > > + > > > > > + /* Switch to short once this failure occurs. */ > > > > > + BUILD_BUG_ON(NR_MEMCG_STATS >=3D 127 /* INT8_MAX */); > > The above should be MEMCG_NR_STAT instead of NR_MEMCG_STATS. Yeah it's pretty confusing :) How about something explicit like: NR_MEMCG_POSSIBLE_STAT_ITEMS / MEMCG_MAX_STAT_ITEM NR_MEMCG_ACTUAL_STAT_ITEMS / MEMCG_ACTUAL_NR_STAT They look ugly, but I can't think of anything better. Maybe they will inspire something better :)