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 56A7FD7360C for ; Sun, 1 Dec 2024 06:52:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C04EA6B0082; Sun, 1 Dec 2024 01:52:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB44A6B0083; Sun, 1 Dec 2024 01:52:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA2F46B0085; Sun, 1 Dec 2024 01:52:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8BB7E6B0082 for ; Sun, 1 Dec 2024 01:52:21 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3056C12194A for ; Sun, 1 Dec 2024 06:52:21 +0000 (UTC) X-FDA: 82845470946.26.4511429 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 07BE91C0004 for ; Sun, 1 Dec 2024 06:52:07 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=rIh2oIaQ; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733035934; a=rsa-sha256; cv=none; b=MNnzgpU472RkSkNOo8xvvmfZICJe35WYMCdXf8PPq0rcdX8BNV4ajdMGOWsfuv+1xJmSAE H9L/9dcYG5L8d/SjuR/U0UwcJFrxhONXqouNNrjmJn5+WRRNZdFnUQbC35tJwwINECxWDl 8U8Vjh3DwGtlQvkkEi3QCQcy+mB9CM4= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=rIh2oIaQ; dmarc=none; spf=pass (imf20.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733035934; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3R/UP4uL1qm8G2ox4OweS2eydYpdvhvr+pIkpNgeK24=; b=MK38RasStP/aW6rITUQ6GmGBh3Ajwtrq4I+OWDgzR8AgMR8MlShfMfy7orVBHS6rUPiQHM K4isXTu/W/U1tHaqD2Yfk+mbkL/aCXqxjgKF14Sxe/A5YDO5iC7mVOIUlkS3+brqlAgPIt kRaPe4BbpRb01/JSWgLgc4xV1dZ9GMg= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 5CD475C5D95; Sun, 1 Dec 2024 06:51:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA0AFC4CECF; Sun, 1 Dec 2024 06:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1733035938; bh=LlAIxB8N/0m2snCylgWlUAAyLHpPp5k+nBPFKFA41Ic=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rIh2oIaQhCt58+TnxD62w8JKisKb9VciI8ivfsm7Sxm4DZpIFD5vY5ITRmpO89vQ9 KZLjISKRT7drej/nBlQj+2ESs/ndpOFv0ZtyQklHxwXxv5zyvwjasB78cBM2uOIu02 jZPIuDNXi3imwpVWMfIVn2gBgDVsTqqk1H8TN8OU= Date: Sat, 30 Nov 2024 22:52:17 -0800 From: Andrew Morton To: Xiu Jianfeng Cc: , , , , , , , Subject: Re: [PATCH -next] mm/hugetlb_cgroup: introduce peak and rsvd.peak to v2 Message-Id: <20241130225217.6949f9f87d3f7fbbc1748948@linux-foundation.org> In-Reply-To: <20240702125728.2743143-1-xiujianfeng@huawei.com> References: <20240702125728.2743143-1-xiujianfeng@huawei.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 07BE91C0004 X-Stat-Signature: ew7wsdm9ui3qsbyye8zo8ou5wgn8iypg X-HE-Tag: 1733035927-738405 X-HE-Meta: U2FsdGVkX18C4cJ4Z59cYboUev53S/6maLLs35wyTTJFO13OFN04QgpA/EDKmEP747aa6yW0TN2zPA/W/RztOjDxpelHaHOKslWUX5PHHB++cGGVPI3QhOE2OZ/ceCb0gG7L5OAob5k5LzoUSFtEHQYedQblVz1ZdA3jG1G9z3XsD2vPmvwwimufzjaF3zT0OaDFH3qCoidRX3vNkqjbG9+7Pv9FrGztY3pR5pW3dWX9YBuW/aPmQP0aOYRXRfobIZfNjsZo2j5t8qGmkAE2BF34D36BgoIpxUXarsKOomNAgcbcgRdK/aUgZCqfkawhqLP0he/recgyK33x79smcZf3PBNyXrw5GmD52EzqZE07Il7YolIHNR+PunjJEmX7I+nWlwUwnb77gjik7uhif3hE/eIqoG2myDJVoASzJPVfdWHsDCBkvFl9ke8TD4+9DNmGhjPM2GJpQ+KPCc5ahOVuVjLPFp8HBjU+Q/oXlHHhdAPTkYjR7nMOqrYvihkgwiX9EqXtbxKBcygfMI1UX5sMpHf4mQK/Bb7dVFQf4aSpWCdzsJ6pYOLEUv+ljTV+fMFYFL79GOpzLzqVspyfOTWt6do7686rHLQ2RYCNCjqhswbEeftP8Gha6mVQmnHWdvXQxoce6kIj5HdGFq9FW2PkdvK73jIzQQq1EdR2txMZIrWZhmGvNA3uYn445oOQDUi7Ek0eilrNrdsdidrAGAagSy3CWiZLNwX+NjlSWc0PH11l5dTdmQHC4xALwdWH7Antlinu/WzCHAZtIQCddFX989D864RLw414fG8tCt/xhqkqdhq9OR3Y8Yy8lnwhKtHwqHTbIvesHk49jwudBMSLw6TKMpbRDtrdz86pSYwlvzbnd5MC465JPXnHyAkDulWBhb9eRJpW0VeFlxGcPaDsCjiImZ7/CM/00VTe9O43mJSNSLUeX5VSQhHlt5w4t649N8rbj+oAyxgwnOm IOM9dodH Tojo/ttDKX52LkROSq5oj/g6DjJayhnLW5IKJzbnTaqbjkSXCXVpEfmMNNObhdRHHf0JzQwg8y95TcT9sTVWJRW4UQxBabECbM4eAbIjsHybfOKdVgUl3NpHHR+6AVyVfBif8Cg5LPnqFvRzh2p6pGIKZ3SUzW33q/Z3G/ccu+/dOC7yQcuUjs7+TV3gyzSLPmd7xaK6zH7zTf8mgoXvWFnP95CGfncKgsmebpC/GAxWP/PFmRkIDZxgOPVe0Lngqkd26M5Oi+zaqPgW4w4zqYDxfLNN43M5GMTnMXhdXeBDhGh7NoZUn5TrsFj32krbkW6Td3c7CWz5bopjAQhkPL4KK3iwZmZE8EmnQ2C3NaHqeraiYjVJ/5lw/jW+Mbjcbn0QLaoVB+bSwNhtiRiNA/Bgd1wcr49ffiAzKb2tRQYYoUw+pgRkma5TdccM99vRCyVTMiqrYEwHLICptG9cismVmxtxLZyT7a7hDX2ta+4n5f4+gJRfpBEakeMuCFBrbgCQwAeiOcrdKK/5h7IS9MocrsiIYiEjpo3hx6tHWZZxOXPpI90whoQPYK9GefbwF5q6OIZqivyBAOkLmdijjJji4/w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 Tue, 2 Jul 2024 12:57:28 +0000 Xiu Jianfeng wrote: > Introduce peak and rsvd.peak to v2 to show the historical maximum > usage of resources, as in some scenarios it is necessary to configure > the value of max/rsvd.max based on the peak usage of resources. > The review for this patch was not compelling, so I'll drop this copy for now. If you continue to believe that we should add this to Linux, please resend, perhaps with additional changelog details to help convince others. From: Xiu Jianfeng Subject: mm/hugetlb_cgroup: introduce peak and rsvd.peak to v2 Date: Tue, 2 Jul 2024 12:57:28 +0000 Introduce peak and rsvd.peak to v2 to show the historical maximum usage of resources, as in some scenarios it is necessary to configure the value of max/rsvd.max based on the peak usage of resources. Since HugeTLB doesn't support page reclaim, enforcing the limit at page fault time implies that, the application will get SIGBUS signal if it tries to fault in HugeTLB pages beyond its limit. Therefore the application needs to know exactly how many HugeTLB pages it uses before hand, and the sysadmin needs to make sure that there are enough available on the machine for all the users to avoid processes getting SIGBUS. When running some open-source software, it may not be possible to know the exact amount of hugetlb it consumes, so cannot correctly configure the max value. If there is a peak metric, we can run the open-source software first and then configure the max based on the peak value. In cgroup v1, the hugetlb controller provides the max_usage_in_bytes and rsvd.max_usage_in_bytes interface to display the historical maximum usage, so introduce peak and rsvd.peak to v2 to address this issue. Link: https://lkml.kernel.org/r/20240702125728.2743143-1-xiujianfeng@huawei.com Signed-off-by: Xiu Jianfeng Cc: Baolin Wang Cc: Johannes Weiner Cc: Jonathan Corbet Cc: Miaohe Lin Cc: Sidhartha Kumar Cc: Tejun Heo Cc: Zefan Li Signed-off-by: Andrew Morton --- Documentation/admin-guide/cgroup-v2.rst | 8 ++++++++ mm/hugetlb_cgroup.c | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+) --- a/Documentation/admin-guide/cgroup-v2.rst~mm-hugetlb_cgroup-introduce-peak-and-rsvdpeak-to-v2 +++ a/Documentation/admin-guide/cgroup-v2.rst @@ -2659,6 +2659,14 @@ HugeTLB Interface Files hugetlb pages of in this cgroup. Only active in use hugetlb pages are included. The per-node values are in bytes. + hugetlb..peak + Show historical maximum usage for "hugepagesize" hugetlb. It exists + for all the cgroup except root. + + hugetlb..rsvd.peak + Show historical maximum usage for "hugepagesize" hugetlb reservations. + It exists for all the cgroup except root. + Misc ---- --- a/mm/hugetlb_cgroup.c~mm-hugetlb_cgroup-introduce-peak-and-rsvdpeak-to-v2 +++ a/mm/hugetlb_cgroup.c @@ -583,6 +583,13 @@ static int hugetlb_cgroup_read_u64_max(s else seq_printf(seq, "%llu\n", val * PAGE_SIZE); break; + case RES_RSVD_MAX_USAGE: + counter = &h_cg->rsvd_hugepage[idx]; + fallthrough; + case RES_MAX_USAGE: + val = (u64)counter->watermark; + seq_printf(seq, "%llu\n", val * PAGE_SIZE); + break; default: BUG(); } @@ -739,6 +746,18 @@ static struct cftype hugetlb_dfl_tmpl[] .seq_show = hugetlb_cgroup_read_u64_max, .flags = CFTYPE_NOT_ON_ROOT, }, + { + .name = "peak", + .private = RES_MAX_USAGE, + .seq_show = hugetlb_cgroup_read_u64_max, + .flags = CFTYPE_NOT_ON_ROOT, + }, + { + .name = "rsvd.peak", + .private = RES_RSVD_MAX_USAGE, + .seq_show = hugetlb_cgroup_read_u64_max, + .flags = CFTYPE_NOT_ON_ROOT, + }, { .name = "events", .seq_show = hugetlb_events_show, _