Received: by 2002:ab2:7b86:0:b0:1f7:5705:b850 with SMTP id q6csp85452lqh; Fri, 3 May 2024 14:18:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVYIEzia4zxZ+42dZE/uahZSgNyHPFsrL8/vcnujajNH4f1j+dFNneMdqun0gdTOO5XZ6HPeDIGnEjD5XRiBr2927C/hi3EmRJv1J9pdA== X-Google-Smtp-Source: AGHT+IFhh4qAf4jdLd65/RPhcmC3YMg04iDdnQdeatzFIyLiftcZV9X5nIIFov27FVskspOFIVfB X-Received: by 2002:a05:6000:1c4:b0:34d:b549:9465 with SMTP id t4-20020a05600001c400b0034db5499465mr2845862wrx.32.1714771122815; Fri, 03 May 2024 14:18:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714771122; cv=pass; d=google.com; s=arc-20160816; b=vZp2lWKLH+NMUQGyuX/JxLAuCHUau0BMyAvPxVSomg+ZFUDg2TKICytl5uc1M61HLs pUquT/3BjKBzC2Cenrg1jJR5u1PPb8FKM+kc2OQAgjIi5ylmv7S3cMSep6vQkGONvULN OyUerzkiK3qD8Loays9Kehomueq7kiu7Hb89ou5RbAI6zINiOwDsIwQo+GF4wrTKUl6I u+Xb94YX702RNwAKJc5wBnHDbBdU0sh88aQvzwp37ZZTg1xjOu4t3HYt9HqSOCBgL+Ml 6WaoyUjhQUXpqKnU0Wl4snTXhEdoucstuDBUh96SDLvHKpf+2blMiRVH2KTY0NTL9cmu 7fDg== 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=xT5+RHaV8lJbYffD5b71+c1F6rsgkHI+a5HvXT+KXN4=; fh=5zVrSJ0FpNls2ESq8o7j6r4W8BJ4YBhCirN3GrG9Lvk=; b=hJKg0QUrOstvYGOgOa0TCbf2Lgjrbyp+NMK8ahDGOIY608QHLs1Lm91mewH8ILjVSP ffkWuVuBOaK1LJ4/73ufhjwJWiWzvu6jMkJQmvcQ2t4TAqJ3KMMeo1QuSmoet1Nx6hSH cCR6Q3xMwBLFpxmdEMqpw/PkbcXMC64MTaTalTwlQjE49xIH1Kfaa5sMMGo/LomJRake 3mkNQAQ8rmjvHm5jt93PSot2Y4UOES0Lxqn+9ic0UzrlwOCKVL6vsr3uUW47TmrwCHCx DRa7LXJSxmfqCaDsukcjmG7iF8zF9FdT17p6BVpz/0il6UMf4BZmmyfWuWfQKyZhBVCT VlOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iguv4xY+; 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-168234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168234-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 j22-20020a170906051600b00a599f0153a4si440872eja.315.2024.05.03.14.18.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:18:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-168234-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=iguv4xY+; 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-168234-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-168234-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 883DA1F22B71 for ; Fri, 3 May 2024 21:18:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADAF15103D; Fri, 3 May 2024 21:18:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iguv4xY+" Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) (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 4E2AF250F8 for ; Fri, 3 May 2024 21:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.183 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714771115; cv=none; b=eVvdANstNl2Y0ytFqgLnoE8ZSR1rRv+nnyEGGxYjSnBs4jF6nfHnbb/dQLCAIl7bxsV1erW6MibPsjF1gq8mlTiMxYIA/yoQLdGby2XnblloFnFJ+Pwx6Hst7pW72s5B2sKvc6/uM8bAGnxWxe6Z0N533CosXlgjW42akTEKJYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714771115; c=relaxed/simple; bh=AXXgXo4rUoTrzp4wanaBPPCJF/Cloe+G7j0+CWUlJ3A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uP0nozDYvNbCuhP5zB/AgVWifRd1VlUfC6qjZDgHJlaYwaqkIT134MEnSA9k9yY1iob05LKoxvxWzOo+z2OQ//ZCDrnbVONiAxtyMjg3/Od5BmX1suZdgO+Yt3I1mBjV2k9/5166IWobWOfni/kEEFco+O5J/47Xn/+kV0l12a8= 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=iguv4xY+; arc=none smtp.client-ip=95.215.58.183 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: Fri, 3 May 2024 14:18:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714771112; 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=xT5+RHaV8lJbYffD5b71+c1F6rsgkHI+a5HvXT+KXN4=; b=iguv4xY+X9y3LbAHrYmlYQ4CCe81hj+hATMgtNbLvxsXVxOAP0vB+qGk/0iXfHHeMqPCeX 7BuZMFBeQjl3pqpbfyffdEb/l4j1oCcMeu+u/w531AdW6YdoD+2z6HGyyVyTq3wk9tYGcT m04RDqDWguTtVNheBYxTg0W/p2Wq55w= 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 , Muchun Song , Johannes Weiner , Michal Hocko , Frank van der Linden , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 2/4] mm: memcg: merge multiple page_counters into a single structure Message-ID: References: <20240503201835.2969707-1-roman.gushchin@linux.dev> <20240503201835.2969707-3-roman.gushchin@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 Fri, May 03, 2024 at 02:11:17PM -0700, Shakeel Butt wrote: > On Fri, May 03, 2024 at 01:18:33PM -0700, Roman Gushchin wrote: > [...] > > enum mem_counter_type { > > +#ifdef CONFIG_MEMCG > > MCT_MEMORY, /* cgroup v1 and v2 */ > > MCT_SWAP, /* cgroup v2 only */ > > MCT_MEMSW = MCT_SWAP, /* cgroup v1 only */ > > MCT_KMEM, /* cgroup v1 only */ > > MCT_TCPMEM, /* cgroup v1 only */ > > +#endif > > +#ifdef CONFIG_CGROUP_HUGETLB > > + MCT_HUGETLB_MAX = __MCT_HUGETLB_MAX, > > +#endif > > + __MCT_NR_ITEMS, > > }; > > > > Thanks for the awesome work. I haven't gone through all the patches yet > but wanted to ask a quick question. In the above enum are you trying to > do a union between memcg and hugetlb? It gave me a big pause to > understand what you are trying to do. Yep, sort of. So the page_counter structure supports N independent counters, where N is sufficient enough for both memcg and hugetlb cases. MCT_MEMORY, MCT_SWAP etc are used directly in the memcontrol.c code, while hugetlb code just indexes. MCT_HUGETLB_MAX magic is needed to define N at the compile time. Thanks!