From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9809CD2AB15 for ; Tue, 29 Oct 2024 20:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0766B0089; Tue, 29 Oct 2024 16:48:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A0966B008A; Tue, 29 Oct 2024 16:48:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E82FA6B0092; Tue, 29 Oct 2024 16:48:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CB00F6B0089 for ; Tue, 29 Oct 2024 16:48:54 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 752B3160608 for ; Tue, 29 Oct 2024 20:48:54 +0000 (UTC) X-FDA: 82727828694.02.CE2D997 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) by imf20.hostedemail.com (Postfix) with ESMTP id 7C8E21C0009 for ; Tue, 29 Oct 2024 20:48:21 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=x3CeDau9; spf=pass (imf20.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.161.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730234852; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Lz+fam73nTglMEn1ntwtV0+tn+WJ+jMNoRjEuTQ5sUc=; b=e4AR2gvJ1q2MeYG5Ttiu5zuB5+TbCQB/ngry1OroUS67DNVNGs1BkBefPNxxyH/QcD4PZW d4T/Qo8xdh1n9rpKkuTVhZbvJYvPtru7iT5way5D6t77xaosrBFfTzmGvprujKHHUJZpyx Cpiv4M7zBEodwmMOCLz0ZIP2tPYWg1c= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=x3CeDau9; spf=pass (imf20.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.161.43 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org; dmarc=pass (policy=none) header.from=cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730234852; a=rsa-sha256; cv=none; b=pnjR2ztMTZGeD3i0rYkfKf8WT8Cfk0LVuarC5yGJ6u05q83USFFR6QxIbGv4icPfcCJluu x8bLSHuiI50R3LHfEMDWQmsg0vsN4Is6Jm48wn3Cu5u24JUYgVoSyCTbTexxQg7VNVCle2 aVI4qiEyDBBil8FAGoXIMZNgVceyRBw= Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-5ebc05007daso3279645eaf.1 for ; Tue, 29 Oct 2024 13:48:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1730234931; x=1730839731; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Lz+fam73nTglMEn1ntwtV0+tn+WJ+jMNoRjEuTQ5sUc=; b=x3CeDau9i/idgVxGMSmOLWMU16AxXmFrRTyAlYxPhumyep3mwn589TUFRXYYEje8et w8RjJnG9CvemaBTZwZ8/EFQP6mlgXCcMVdZ9gFNSTwc4N4RgnUoWeOj3r0v0JI+N5xQR 9lSgqm2TLvZUpK9lDQzKffrWSUQwC2l1SkcpVVIKghI6k1amog9ja3hUElniFEgFIuOp rqG4jU7T9HRJ6i0oUkNmedn+pGKfSNNMyO2Q29JyMdmgX08hxwQmNIplpWtSzPlRtrX+ V52/ysgFhwaoVB6J4fW2zRJMVjW0FBGrwcewSG/EYwutSP4cDzs6DAjKvtURpuD+IdX8 GsFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730234931; x=1730839731; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Lz+fam73nTglMEn1ntwtV0+tn+WJ+jMNoRjEuTQ5sUc=; b=rBAeTdjTq+lT5Ed0LltHqcTvdN2TcZwNLI5Sz5vR3jjXqiI2xXfpxKVbTOWX2rvhWd YFCg+upY+Iz6kXjBdnA4nUkUMeGXLdwY1Kzz3q12dYh9K0cGw/QNuaO8Ml5ybSQVcOLH 7/B5llA3TuieN5dZyRv+czSRBlZS3pKlD6CC/QoAwS6EtTtongRGM6IllJtkxzvBhJVe s7Hm8m7ksL4Fa8e9oR/k2fCre4b1szE81AK0YeRPW9urSLjKwSEc5Tt/yZAaF2k6ewPN HKaSbU/b8zhnnlgYpsvqYsYfZ0wa7YPJYHQDauX1nFjpDin9wyciJ3CBxtDBSxbd4eiu BK7Q== X-Forwarded-Encrypted: i=1; AJvYcCU2R3CAIIzOrQpnEG7pWSBtO+H72H+3xzacaiPVaYREQvtUDq7GkBJGXS33Or4TUw5pcOj/hfi5zw==@kvack.org X-Gm-Message-State: AOJu0YzY9YoF67fr6c4AK+1JCfLsXN83AOFhqu7OlkLDunUBxk15WEVx 5svAxGSzq1zk3nJjRiDc6w3bfE9JkgerkL9s/aLCDOZn6YheU5DxamQGNgVKO+M= X-Google-Smtp-Source: AGHT+IEk+xZmWM8WKpt5tWtQhDCJGSjpzhCeDTFcsgf8Se6KNsxb5wHR97kIMZ66xEGKYHUW/E2EDQ== X-Received: by 2002:a05:6358:6f17:b0:1c3:7b8e:c35b with SMTP id e5c5f4694b2df-1c3f9f5be1cmr617877555d.19.1730234931163; Tue, 29 Oct 2024 13:48:51 -0700 (PDT) Received: from localhost ([2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d179a2ce60sm45153996d6.108.2024.10.29.13.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Oct 2024 13:48:50 -0700 (PDT) Date: Tue, 29 Oct 2024 16:48:46 -0400 From: Johannes Weiner To: Joshua Hahn Cc: nphamcs@gmail.com, shakeel.butt@linux.dev, mhocko@kernel.org, roman.gushchin@linux.dev, muchun.song@linux.dev, tj@kernel.org, lizefan.x@bytedance.com, mkoutny@suse.com, corbet@lwn.net, lnyng@meta.com, akpm@linux-foundation.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH v3 1/1] memcg/hugetlb: Adding hugeTLB counters to memcg Message-ID: <20241029204846.GB636494@cmpxchg.org> References: <20241028210505.1950884-1-joshua.hahnjy@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241028210505.1950884-1-joshua.hahnjy@gmail.com> X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 7C8E21C0009 X-Stat-Signature: 8qm8xoh69to37b1noc1zsfr4bx6dabjr X-HE-Tag: 1730234901-492457 X-HE-Meta: U2FsdGVkX19QnrKo0TQ8RPunwAbi+WaXOhWitV6YhR/j78LSptofS8t4ZoB25KwOoIpHhvzxhyEFhYkDAkwrNl6gYaijnfemX+/vMRt/RvHfKeBuJ3f2/Uv3e48v8+KQDy3Sze1ex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VekMNeowU1YGhBDVJSqBM3xbMfqfl0QAYKcocgZSuuadmDXcXZ8guhUnzcUuT+s6DQtCBGdQSqMyJ8AXg/8YntbRmnkUYRwOXQmJJnmojrKgS64uycgkEhqrTHY8nrUXBDJ5+jCJeP02lLtjldnxsYP0TN+2Krx3yuZINsDo2alanbYd39uCvMQBdYw8sP6pUYfEf+xMtJQOmhQ2hYo+g8wo+0gg6Iqtuw+hfNWMJ2yycv6JCshG2gUbnK+WbG0UkZewwzDL9slP63Ld7MDT6qLGQfurFcoWhjpF7GXgIGDdPqnPMPbrB4WarMDK1DrEs0zglBCZ7/dMccw2aZgUtGWqQEX9y1EIVofkdhdFgjN+dvJ5kle9vTnFNcv+9+/LoMLPUr+oH X-Bogosity: Ham, tests=bogofilter, spamicity=0.002850, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Oct 28, 2024 at 02:05:05PM -0700, Joshua Hahn wrote: > This patch introduces a new counter to memory.stat that tracks hugeTLB > usage, only if hugeTLB accounting is done to memory.current. This > feature is enabled the same way hugeTLB accounting is enabled, via > the memory_hugetlb_accounting mount flag for cgroupsv2. > > 1. Why is this patch necessary? > Currently, memcg hugeTLB accounting is an opt-in feature [1] that adds > hugeTLB usage to memory.current. However, the metric is not reported in > memory.stat. Given that users often interpret memory.stat as a breakdown > of the value reported in memory.current, the disparity between the two > reports can be confusing. This patch solves this problem by including > the metric in memory.stat as well, but only if it is also reported in > memory.current (it would also be confusing if the value was reported in > memory.stat, but not in memory.current) > > Aside from the consistency between the two files, we also see benefits > in observability. Userspace might be interested in the hugeTLB footprint > of cgroups for many reasons. For instance, system admins might want to > verify that hugeTLB usage is distributed as expected across tasks: i.e. > memory-intensive tasks are using more hugeTLB pages than tasks that > don't consume a lot of memory, or are seen to fault frequently. Note that > this is separate from wanting to inspect the distribution for limiting > purposes (in which case, hugeTLB controller makes more sense). > > 2. We already have a hugeTLB controller. Why not use that? > It is true that hugeTLB tracks the exact value that we want. In fact, by > enabling the hugeTLB controller, we get all of the observability > benefits that I mentioned above, and users can check the total hugeTLB > usage, verify if it is distributed as expected, etc. > > With this said, there are 2 problems: > (a) They are still not reported in memory.stat, which means the > disparity between the memcg reports are still there. > (b) We cannot reasonably expect users to enable the hugeTLB controller > just for the sake of hugeTLB usage reporting, especially since > they don't have any use for hugeTLB usage enforcing [2]. > > [1] https://lore.kernel.org/all/20231006184629.155543-1-nphamcs@gmail.com/ > [2] Of course, we can't make a new patch for every feature that can be > duplicated. However, since the existing solution of enabling the > hugeTLB controller is an imperfect solution that still leaves a > discrepancy between memory.stat and memory.curent, I think that it > is reasonable to isolate the feature in this case. > > Suggested-by: Nhat Pham > Suggested-by: Shakeel Butt > Signed-off-by: Joshua Hahn Suggested-by: Johannes Weiner Acked-by: Johannes Weiner