Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1431569lqd; Thu, 25 Apr 2024 15:54:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVrXMSltNNKfCPNC9FeC4ywonG8oDPKgbxJtAmirHxatPyiv1ltD6PQeiEv0sa5BfE7NaOqx8In6YQw8Pm45zzzuzHUiaf2Yc7VRNYsjA== X-Google-Smtp-Source: AGHT+IEHAM4uhQz13C7uAf/MRIYi4EdS0XWFFD5jkKipR2Fsgtw/wFK1YZ/Q4B01jIBXldZLTWi1 X-Received: by 2002:a9d:7d1a:0:b0:6eb:7e44:83ec with SMTP id v26-20020a9d7d1a000000b006eb7e4483ecmr894672otn.30.1714085697890; Thu, 25 Apr 2024 15:54:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714085697; cv=pass; d=google.com; s=arc-20160816; b=ZrGJT83DilfpSIRlw+ttWAI5lir3NYgzCToRO/aZYcMwjHG/lzMgqF+OYmmyX/B02p COlG8nFX7vLIpNXg/HynAO61/+dWLgkWDHHrSZ224P9hUOuGvJ+rNrC1R+pPUDY977cI c7f74miIovc0HjOhSYROePnBBo5RkhA/sXRaNn4YmlMC4uTGOuGIcZ9xtoiPYGCdGw1L mMXSQQnv2jOlXLu5n/l79Ns3GSY6DIMrSKrGmGl+6jretsIZxnD0C41fWUFJJoQwMkBC dSOyL00sIgrB7dxwwZsruCLxp6tn5A3vmrd/xOK22tU1Iak/TNpzDFlZoY+teCxul67+ Vz5g== 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=KFy0ruxkfrD7/51FiBIWLXNcstal7LfGC2Msjg4LiFM=; fh=MJyKT06EEAXl6LEl0ePYutec9Ue7sT3VWR19Ub/USr4=; b=gMr4sAhiB+tJl7FUFqyGs9P3qrhNloSKGB81KG7MW2Q0hTXyAnJilLrVGtpHLs0VMI K+onSnLEbxCwpPxI5G5/4ter8iYTYhlbea6Mvc09uWoFaf+zWqYfB+s+zxLc5AGh28Ln T/06m2dYa5npim8j3Pr4G6XDhL2NRyccrU6KYgl6CC7P+56Rwyll2YFu/6MuXbWgSKYh psIubgqBhP3gVhp4axbfi4sevQCaKBSNwu36hT3vJHdN+YdlchajHJlAaouSGm5cGs4I 8buMGSAj9f69lFLHjScRZivZsJweMcVAMHYeRDKS3/55wmrY0bBHhRAGcN3OSDGSqvIz iY3w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=E9g+U6Vf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159340-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s21-20020a634515000000b005e42b4c97f2si13715188pga.289.2024.04.25.15.54.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159340-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=@kernel.org header.s=k20201202 header.b=E9g+U6Vf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-159340-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159340-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 7D370284547 for ; Thu, 25 Apr 2024 22:54:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24B96155A43; Thu, 25 Apr 2024 22:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E9g+U6Vf" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4A37520315 for ; Thu, 25 Apr 2024 22:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714085690; cv=none; b=CUrB/SM+tI8yQ6cj4TLsw9xpLAvPU7mNzvorhjCH80eENrTWwmI0fG8IvWv958XsQInt+VzTdSPb1xCuUbpw69B0tnrHEVMw73a0VUET1Kyw00HOLMitE1BfZypxPYW6Svg/lfpTrftg5kRvXqOqxg5zn8IUEjwrzQl0GLvsqQ4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714085690; c=relaxed/simple; bh=OPvPhadmnJkmJD6QVWg5V0EqAqVaZnNCxCAbiIxAbfM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=gmZLqtxmGAtF6xEFrwtSapbSxd6ayQtcxSTpyVnAPn6uXV6Yp1wH5iA8mDj6WrxvgasGTOZ/vgJ6trW0esXr2eQvSNPadbN4kJdRIvUHv7cKWkGRYGsp23XFm2WmkwF8UuORJeU36MQXQq8vjHCKn1EIj1X3U+N/oUZQ81N63p0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E9g+U6Vf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE7C4C2BD11 for ; Thu, 25 Apr 2024 22:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714085689; bh=OPvPhadmnJkmJD6QVWg5V0EqAqVaZnNCxCAbiIxAbfM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=E9g+U6VfRi9yDSMuMhrxB1Mp9RXJQ1zLp0BKXAT5nk6Xma8ccQ32PgMLDssWa6hKh 7TPxaOLJtVGIigUsVL1JghFdKQ8uaMNYEeoCiRTzK3+Yb96rZI3fitdHiJQUm2nucm Ki8sb72fwIIU0pnCr5mNwwpr8IWz4X3vWH3vT7jMQjjccWc1LW3QGddl5eJwB2XBWa nUmR9AduiPk0tXnUuUCAmtP6cyQR4MiLE0N5rvRNJaf7ZHf6sJ1+ppjeemWfz9UYEQ 74M/0gp8GmAA3GyAgu06T/GoP6by2zKaAh95AgiseLQ77OpvSrw/XPGmPJe+e+Kbqm 6RbRjTaDVenlg== Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-516d2600569so1885051e87.0 for ; Thu, 25 Apr 2024 15:54:49 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXfe9y7JVghC05qX5vuc735qKxH3kRjcklCgbRN2UGktReBYrW7JEVTM9Q+tAvoUogN+Ij9biwBj6JQddTRO63KruwXJxkEyfJyTBfP X-Gm-Message-State: AOJu0Yy4cc984yVB9FQNb0w7JiF5jvJIzj1n8oxtwZn/luGCiH5B3YkH kPn9jyLEwn+ayF/Q0xPoaNcZbosrjy7msuLubBGsHF75kzxarO58yhzc1eCC6fMXTvod93fuyFh Jg2MdhsjwLniLXrXZl0Dcq8f/fg== X-Received: by 2002:a05:6512:208:b0:51b:18f7:6a9e with SMTP id a8-20020a056512020800b0051b18f76a9emr463183lfo.45.1714085688498; Thu, 25 Apr 2024 15:54:48 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240423051826.791934-1-shakeel.butt@linux.dev> <20240423051826.791934-2-shakeel.butt@linux.dev> <20240423135844.GA21141@cmpxchg.org> <20240423183041.GA318022@cmpxchg.org> In-Reply-To: <20240423183041.GA318022@cmpxchg.org> From: Chris Li Date: Thu, 25 Apr 2024 15:54:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/4] mm: rearrange node_stat_item to put memcg stats at start To: Johannes Weiner Cc: Shakeel Butt , Andrew Morton , 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 Tue, Apr 23, 2024 at 11:30=E2=80=AFAM Johannes Weiner wrote: > > On Tue, Apr 23, 2024 at 10:44:07AM -0700, Shakeel Butt wrote: > > On Tue, Apr 23, 2024 at 09:58:44AM -0400, Johannes Weiner wrote: > > > On Mon, Apr 22, 2024 at 10:18:23PM -0700, Shakeel Butt wrote: > > > > At the moment the memcg stats are sized based on the size of enum > > > > node_stat_item but not all fields in node_stat_item corresponds to = memcg > > > > stats. So, rearrage the contents of node_stat_item such that all th= e > > > > memcg specific stats are at the top and then the later patches will= make > > > > sure that the memcg code will not waste space for non-memcg stats. > > > > > > > > Signed-off-by: Shakeel Butt > > > > > > This series is a great idea and the savings speak for themselves. > > > > > > But rearranging and splitting vmstats along the memcg-nomemcg line > > > seems like an undue burden on the non-memcg codebase and interface. > > > > > > - It messes with user-visible /proc/vmstat ordering, and sets things > > > up to do so on an ongoing basis as stats are added to memcg. > > > > > > - It also separates related stats (like the workingset ones) in > > > /proc/vmstat when memcg only accounts a subset. > > > > > > Would it make more sense to have a translation table inside memcg? > > > Like we have with memcg1_events. > > > > Thanks for taking a look. I will look into the translation table > > approach. The reason I went with this approach was that I am in paralle= l > > looking into rearranging fields of important MM structs and also enums > > to improve cache locality. For example, the field NR_SWAPCACHE is alway= s > > accessed together with NR_FILE_PAGES, so it makes sense to have them on > > same cacheline. So, is the rearrangement of vmstats a big NO or a littl= e > > bit here and there is fine unlike what I did with this patch? > > I'm curious what other folks think. > I slightly prefer not to change user visible ordering for no good reason. It is not said the order is carved to stone. It depends on the ROI. > The cache optimization is a stronger argument, IMO, because it > directly benefits the users of /proc/vmstat. And it would be fairly > self contained inside the node_stat_item enum - "ordered for cache". Not sure how much of the cache optimization is measurable here. I suspect it is going to be hard to measure a meaningful difference just from the cache line order alone. > I was more hesitant about imposing a memcg requirement on the generic > vmstat ordering. That is a valid reason. Chris