Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp133847lqa; Fri, 26 Apr 2024 17:43:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU19NUt3BGh9qNd7mf0mce1WfR8ogIoNDwmPilvuu+ByODgvQLMbOTiKfuZ2QACJlIl4iV4Nj4BwYMbHNz/PQocJ18J4HpzpbN+apHnPA== X-Google-Smtp-Source: AGHT+IGItHGTj8l3r9zpQQNAf1SQFeA25ImriZhvcsdrYjpTeEYq6mWALZk5SQ1pGjsbZ5SsDSfT X-Received: by 2002:a19:5f43:0:b0:51c:b8ec:c46f with SMTP id a3-20020a195f43000000b0051cb8ecc46fmr1872151lfj.22.1714178619641; Fri, 26 Apr 2024 17:43:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714178619; cv=pass; d=google.com; s=arc-20160816; b=orjpLKvHt9C16rJt+hjtD++pPimONYpQRxLffnxG26WZRKAigEcZCfP7LMEwikE/3S f5e9hktJOtvi7TiVRX380Sx7F0Vu4XzzZOv+cL/CnseQkyYQsx7sIo1xM24iS/7dxCaE B9Rq8pkHirmUN6pap79Ivc21EW4R8V6hzwGPKU84r4+7PnJrEz5oUUQJitbP/gUI9yd+ +vH6zUsonRAatPCK8PuLyinunZ1X1LLX/d4hsbs6kaNQAXFEMo0Wx9XIz5Sf3Evr33+c gboiJdKJTer5XneQadHTOkRt/OvhFg25asXlelGN6V0wr3meH+FptlC+lfo5H7XxYbHP etgA== 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=cAV5lb9sQLlVxGGdRZG8Wcfo2rn1ufwq+aieY6fQ3sM=; fh=bdRea4aKYtUpZzUh/EXQRbfWw/O7us3zFSpyqhz+BC4=; b=yWNRRwgKN3604Mb7FIHoAUGiXWCGjBc48c5Xn7sdeBRJWJpPKmm9s5Jx+bGEWwDSuZ +yxC4GTLxJiMJYVIIJ1rMTfJQPVwlu9Zx7+rpGy2ywgVJDzrtIsaBjZI35Fl12IYx6kf BeF+cTYKY/SxHoS8+RONUFaqRgL5gYdGfFu9po9FQ2HG9aBaKaPcb89jNPt4XGMB4P6t GkKCE9KFeH/A8jNW5SIJEjr0tdZQeI9OaYY/qOyigFmrOq04Bu1axXcuI8MRSNML5vrN xjruEOQu8IyU4wHbXm6mNqMLe3BBaiUEaSLEekPwpF/gJnsTroL3PlK+rNBrAQvgcXCC gn7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ByCGYqTv; 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-160828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160828-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c29-20020a50d65d000000b005726d41021esi95357edj.570.2024.04.26.17.43.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 17:43:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ByCGYqTv; 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-160828-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160828-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 33F471F216A0 for ; Sat, 27 Apr 2024 00:43:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7BCA29424; Sat, 27 Apr 2024 00:43:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ByCGYqTv" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 8E4C94C99 for ; Sat, 27 Apr 2024 00:43:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714178610; cv=none; b=gPaLcU6dy6av01ie7eX049Y46YRr48fhplpWcV5N7jWNdntfhfKzBGg4jIh5oJTTh2bOYO+e4skOZIW5xqWkusl/0TyzEi984j+Iq6RpuD/7YOcz00+OoRf7NkXyCeXlCz76iJ5e6a5A6SCxa4tFRTkGRyvy4GFSijgAcmbqaWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714178610; c=relaxed/simple; bh=8CbY436CyB1LG0mIf6lnhnsp9BSccmu06BQaEafvmAU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=FCoRo3tYKEFi9I5TSgOUmF7Qj7qtUJDSXSTlRpudEAkpvrIhtnraYhImRYY/TpQfz/hoMxwAQX+9wD7ku43zNcstAUJGnYY0WScwrinNunVa7E7UW6Fb24uat+5ciL/asE5q3kpVMunk8Xe8xGv1K7Fx9Tq9VOqm5qSyCM4XWyA= 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=ByCGYqTv; arc=none smtp.client-ip=209.85.218.54 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-f54.google.com with SMTP id a640c23a62f3a-a56d7d457a1so325879666b.1 for ; Fri, 26 Apr 2024 17:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1714178607; x=1714783407; 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=cAV5lb9sQLlVxGGdRZG8Wcfo2rn1ufwq+aieY6fQ3sM=; b=ByCGYqTvF/aPrwEteOGHmNTlBbeT/8EYRWRjWnqmMF8F7os2xBPrxlWP2dgAuiq6wq nk4HAIx0Q7aIZweea76uTH/HC3D0ri05Nk9+nxEmdV6NLUIFYRObd3wWHbxV+gEJj80s /EqwGkO/EAbCHxEB9dR2Y5h9ov22NxMWZtlrBA4cYpQ6+tO0ze8Odx0XSQXU6ifbXgoO SqjFtEd2UfuHqmed0dX85LmJ67Jmg+wyybuMMM3th7iD9QPd0orEEVfF4zf9b+EUP3FQ pa7S7A5PgyII9oSa0sbB0jvZItoVN3ndEqhmEnRBQqsfJlBURgFr5+DUto1rLszTjsn4 4Dqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714178607; x=1714783407; 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=cAV5lb9sQLlVxGGdRZG8Wcfo2rn1ufwq+aieY6fQ3sM=; b=EsRXsJdZaI3uh/a3SF/IkqZn5xb9DZijAIvBqlxlEljjdB/fA65ONpT2vZfhMZOf5f SbIaBuxZsGaZ4FC1bQ8OxT3mi0RM2gtxMjIxTbI7wspbUAm5z/Gml6ErRARzjuZcpRD6 V/TMakWOEyOCwhA4gt4837inuinWJ/Cr4WyLie+vuWakcQzNQLrnvRcEsLNcX0f9aNg+ KGm9PEtqz6t8zZVuZhUVN/hlzQYHKTcgErgh+/RJ10zTNUIGpgudyBEnrnrUjXvncitA 4eZL21aDfUAqxXgKpxWdLBgTSFmG94MAFnCwJMdm4Pjhd72PN+4sU9viCZDOMLa0pfAL ctYA== X-Forwarded-Encrypted: i=1; AJvYcCXHEE6ZGrJRLJHAnXVzWh2XpdBwi+/S4fmJi5qeo9fQP0mPQQX6AHmjEL/FVnNJ1uBuicAStgHKUhCny0wyVF+7Fe0f1EsoYSOaOZCd X-Gm-Message-State: AOJu0YxZ+6YrMREVja/Q/LsDePddrVPmXmyJRylt4EsdcFYlcX0sK3rN B6xiY879IpQR7nZeSA6sq67dmLpG3eqlUkAJVt/1NqqlCjWB+RNS0+prIzkzGVEn+L/gHLNScJ7 K9lQMV77/kfDoa98PJBUCLKSM4/hJt2Yavn+e X-Received: by 2002:a17:906:2dda:b0:a55:9e16:f005 with SMTP id h26-20020a1709062dda00b00a559e16f005mr2853749eji.57.1714178606615; Fri, 26 Apr 2024 17:43:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240427003733.3898961-1-shakeel.butt@linux.dev> <20240427003733.3898961-2-shakeel.butt@linux.dev> In-Reply-To: <20240427003733.3898961-2-shakeel.butt@linux.dev> From: Yosry Ahmed Date: Fri, 26 Apr 2024 17:42:48 -0700 Message-ID: Subject: Re: [PATCH v2 1/7] memcg: reduce memory size of mem_cgroup_events_index To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Apr 26, 2024 at 5:37=E2=80=AFPM Shakeel Butt wrote: > > mem_cgroup_events_index is a translation table to get the right index of > the memcg relevant entry for the general vm_event_item. At the moment, > it is defined as integer array. However on a typical system the max > entry of vm_event_item (NR_VM_EVENT_ITEMS) is 113, so we don't need to > use int as storage type of the array. For now just use int8_t as type > and add a BUILD_BUG_ON() and will switch to short once NR_VM_EVENT_ITEMS > touches 127. Any reason not to use uint8_t (or simply u8) and U8_MAX (instead of the hardcoded 127)? > > Signed-off-by: Shakeel Butt > --- > mm/memcontrol.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 602ad5faad4d..53769d06053f 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -607,11 +607,14 @@ static const unsigned int memcg_vm_event_stat[] =3D= { > }; > > #define NR_MEMCG_EVENTS ARRAY_SIZE(memcg_vm_event_stat) > -static int mem_cgroup_events_index[NR_VM_EVENT_ITEMS] __read_mostly; > +static int8_t mem_cgroup_events_index[NR_VM_EVENT_ITEMS] __read_mostly; > > static void init_memcg_events(void) > { > - int i; > + int8_t i; > + > + /* Switch to short once this failure occurs. */ > + BUILD_BUG_ON(NR_VM_EVENT_ITEMS >=3D 127 /* INT8_MAX */); > > for (i =3D 0; i < NR_MEMCG_EVENTS; ++i) > mem_cgroup_events_index[memcg_vm_event_stat[i]] =3D i + 1= ; > -- > 2.43.0 > >