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 4747AC0218A for ; Thu, 30 Jan 2025 14:52:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C7311440152; Thu, 30 Jan 2025 09:52:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C225C440151; Thu, 30 Jan 2025 09:52:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC381440152; Thu, 30 Jan 2025 09:52:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8F0CA440151 for ; Thu, 30 Jan 2025 09:52:40 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 391E2A0F74 for ; Thu, 30 Jan 2025 14:52:40 +0000 (UTC) X-FDA: 83064409680.26.8EEF9C7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 9EBFF180011 for ; Thu, 30 Jan 2025 14:52:37 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PiobeH3y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of llong@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=llong@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738248757; a=rsa-sha256; cv=none; b=aN9tPRsLFSTzog+4+AnOWFXqHH5W/UdCGuBxQJ3yTMj29jnmfyZ5KjzBFmnDMUtEi2ueT2 wmyFRhw0Ui0o4TmlftF0eIa7wmkRmt9iSQLWwLXPkKCCN9T6POvDYWvhR1vPllq5+JPfLZ ko+xxpJm0ZrPfOuxPKzp8AfJ+v3xWFM= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PiobeH3y; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of llong@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=llong@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738248757; 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=SGz1ZibS2GfwUDvWQSD0jo0W5/+6emzlakirCqtq8vk=; b=xuOWEr7IZgSVhCd2zXz0uzYCNq9IAfBpNUcAcX7sXwp9W+uIvLHKoj0GDEQwRuUfc7Wg5Y BSTdjLfYHxZN3CKLDQeMGZ0AuKPnco6vGrvdK7Lw0KBZbeaHpnUSpNmVzeDYbYsH2bRgsR Qf36+fPIefHN0Ss4/g6QWwQtCx4t084= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738248757; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SGz1ZibS2GfwUDvWQSD0jo0W5/+6emzlakirCqtq8vk=; b=PiobeH3yDF8TMm79Wq5Rwp2n156sTeuIqT7PSKtwI6279xGfivfU9wOp0kTPUabn2uZyAy SyzNe+PhY3Y1N2W842icA+5IaXy6up6UudcnuzsDF+I0REid5zvWvIq6PQdgfFFaK0dTYr qDgZbEKaRPIMOxwrFBBxKm0+EsW0UPU= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-519-cA1nBqWoNcSK3XaT9uHG3Q-1; Thu, 30 Jan 2025 09:52:33 -0500 X-MC-Unique: cA1nBqWoNcSK3XaT9uHG3Q-1 X-Mimecast-MFC-AGG-ID: cA1nBqWoNcSK3XaT9uHG3Q Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-46791423fc9so17626241cf.2 for ; Thu, 30 Jan 2025 06:52:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738248753; x=1738853553; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:user-agent:mime-version:date:message-id:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SGz1ZibS2GfwUDvWQSD0jo0W5/+6emzlakirCqtq8vk=; b=g/dHt+DNWSf3ST/gJUF8M/KboHa3f1sX3noZfNe9VBO+FCbHvH+vEmiw03zY9yPza3 nGK86Rzz9BBWGKjvy/m+FOUXaFKB8v+Ep64tvmDtU9fRfCmU3eUcX9UV8vGer8wpyhab 4tqePhQTmSwQttg/JI0i5rSkjpe59N8pVlykwBhHNJMe37HS+fVW4wfFdfqeNlGm1+qQ LDGhqBbDddq7uJ+IE2Snf3i7k3Uw4IFG4lz/gBUmAjTguXPW27bzbE1borzJAvg4j+ld l0KNp+GecnZnYGn3/DofIvJhl8kMr4pCPwu0l6DRsnBBhrPZ8BNYz8rvwAHdRk/c2KU7 Z5lA== X-Forwarded-Encrypted: i=1; AJvYcCXV+/9SuzQuME3MLuAH1JxjhqKgGimYYNFVPUFdO6MBKlohJ+/KpywVAWGhT79WBzinhMySxtCCjw==@kvack.org X-Gm-Message-State: AOJu0YyMgdcqPbWCP07jgiImYEDvPEfF4HdEMGaBh5Oe4JfezwoatC9p E5H8RpiWzTGWnKWXGKz40O8uK/enS3mFOJJ4QujMhNWy5iZKeKHdOhc/TM7AhzXpXItfb7Um/MO 9U+keASAwgMfLyb8ZzZoMQllvklS8Vt5sOnVccaIOu9UmfoAP X-Gm-Gg: ASbGncsOm+ejAdYjyLDqzAcH/IhYqsgJ3sShf7LUTtnILq1kEfRX3BBTrx+M1Yz6Iu0 xQ+ANUrsr3vsrhKvnetXHOTOYO/iKrSyeRnu4+pbyOaXF5IeN5DGP4Vwc4EGD0dl0VjBYjZqDsT XyU53b2nrGMhO3GW0MRFm/p6NUBOANs04nyJSVSKBmvsDVAhijVOuKlb4TuXiJcU2dIn3ntwU0N 6470wHJ9z1VPpFS6DvXbGmPdrmQ0MVM+zhWI2/gesLaQxNbqTEUcS1Whjpa1B5Num/RQHMSSi+I rTk+BfE6wAiCY/LqSfjXBHOENH0yPQWpqAI9fCuVBN7DVSS6VF4= X-Received: by 2002:ac8:6f17:0:b0:467:53c8:7570 with SMTP id d75a77b69052e-46fd0a1e874mr145317921cf.13.1738248753180; Thu, 30 Jan 2025 06:52:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZtczFOZdXZZrzAnnTtypYwYu2MEl/wAI3+p6VGOBUkFWHhZm0Tir+2iIoGGAmsnU1RVk9pA== X-Received: by 2002:ac8:6f17:0:b0:467:53c8:7570 with SMTP id d75a77b69052e-46fd0a1e874mr145317521cf.13.1738248752831; Thu, 30 Jan 2025 06:52:32 -0800 (PST) Received: from ?IPV6:2601:408:c101:1d00:6621:a07c:fed4:cbba? ([2601:408:c101:1d00:6621:a07c:fed4:cbba]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46fdf0c7e5esm7550941cf.24.2025.01.30.06.52.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jan 2025 06:52:32 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: <366fd30f-033d-48d6-92b4-ac67c44d0d9b@redhat.com> Date: Thu, 30 Jan 2025 09:52:29 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm, memcg: introduce memory.high.throttle To: Yosry Ahmed Cc: Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jonathan Corbet , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Peter Hunt References: <20250129191204.368199-1-longman@redhat.com> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vP2fG6LFrw-flw4oDFbJq7osY9LJEKNS3I_iNbKp1xA_1738248753 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9EBFF180011 X-Stat-Signature: sf6s9g7pwqqaemdzgbu5kxbrfe7qwos4 X-HE-Tag: 1738248757-817917 X-HE-Meta: U2FsdGVkX1/aWL3UhjVh4ojJcF8juLbHtxkNMjkfAIDSA6t0Q/E+CiUfGj0YD98QPHWqJtkppoove2LtCEeHcSCpTTcn8+V+9CwaOnUD+sRBWTHsQPVXkSRStg+l1VolQD9GfxrwxLIPO7FrmSV8lU+jelWV0f4RRYM3xw3wkumoqimB4SweoXmO9mqn1gSbRh4nVWY2xf6Q0hSEaqrHYeG9FpVeijIylqDRVGOsV26Pq7cwpdD/jYF41huHXXgXEPtzngKLIoV4ity5Ly+8qr/2nuWao8+1dFlp4/8bbQj5duvvtuDq5VRjKoSqqosQ8D4znkX5jDZGevD03IXIBGiPCBJtVaf/sak747nANUx7K5h7Qrxy59IM7y/9AIQSqrxVJIgiagK4yO0NKXCviVp2YpsX9HfHGDfckdQ/qkS1WZqCc/29oIRAp+XvNp6QR4jQg9TEVDj65ZPGd/9HAQp8+pEg8zXUNn4/VGtHxRMy2hxsJJnJ41hW9khUfofupVOJAfOfneAQkbs6eoVCC7gNN8M+hwgL1eZdSBTMGnTP7n49XqTOKcVlBeFL66HbJU29dkl8Wjt+QIbIncNKIEav/ChCS25AQ7Po0E5TEjaS1azhW8cuUQvIOfH1THxy+B04DnDs7Kr6szU5A58wJzfWujD0Me99eTgE88Y5bX5fKa3MFgOiqrehulyPQsXipLW+iCgbusR+qd+sk2FIEyQYkwOV+8+AHLySySxvBgfc6eOdyV9QQHRbDYLY0xeyaLv1biUM7XEp4XutjvW874VcbeWQEDn+iGptqwIAZeT8GzgpkaQHli3yZZhpJnu0VhTJDbiNLHxYFPP8MkRP6tkyjXcVlEw3XJhAyRmmpCLbgcWVk91qBJkSGYqin8jBLZK9DBWFs6pP20fVuEmPya9gnS9xWbEwFPzaw+FSt0dls1BQplLyjBGTXEkM5Z/NmNYC6ruliQ3pkVeVrB3 ZWPi1w+4 mX2M1+GdT332P6U3zOI33Hjcb/rwYKLV9Etlr/Jm/P+GSEI4OsNFc0C2JDml+1DtECnRzFPpgnnTOs0VwL0x4N2ZL3Y6EKnQ9+rYSOL0ecAGIwUIEZKQKgIhqGufaXpjJekvs3bCArAaqlUEt+OD+KExtl4H6MUstATPe4ukbQZm5mW6qsP8D/iiIFkXCzSt9ctsSafuljaRtxzCoX1c3Uo8dW75HHSjJ+qjD9cObnG8F7v8dETqKqp3dBGF/+ltGnLbb5vzPF3SMMGaJv2R2GLNf7Y5TYwGsiid0Gdvppy990kMYl1M5O2WnTtfzOlCy5tNrkqiEuZn1t5G2mk+MDqA1f+pyFpN1bGO63LWR1tjM5eG0h6oSrKd+fuBNiHZNZUtlDbn9QSJFxIP/qv9wxd1GlDFnnkEIGy28LmVgtScAxYneij49+DtmDQ== 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 1/29/25 3:10 PM, Yosry Ahmed wrote: > On Wed, Jan 29, 2025 at 02:12:04PM -0500, Waiman Long wrote: >> Since commit 0e4b01df8659 ("mm, memcg: throttle allocators when failing >> reclaim over memory.high"), the amount of allocator throttling had >> increased substantially. As a result, it could be difficult for a >> misbehaving application that consumes increasing amount of memory from >> being OOM-killed if memory.high is set. Instead, the application may >> just be crawling along holding close to the allowed memory.high memory >> for the current memory cgroup for a very long time especially those >> that do a lot of memcg charging and uncharging operations. >> >> This behavior makes the upstream Kubernetes community hesitate to >> use memory.high. Instead, they use only memory.max for memory control >> similar to what is being done for cgroup v1 [1]. >> >> To allow better control of the amount of throttling and hence the >> speed that a misbehving task can be OOM killed, a new single-value >> memory.high.throttle control file is now added. The allowable range >> is 0-32. By default, it has a value of 0 which means maximum throttling >> like before. Any non-zero positive value represents the corresponding >> power of 2 reduction of throttling and makes OOM kills easier to happen. >> >> System administrators can now use this parameter to determine how easy >> they want OOM kills to happen for applications that tend to consume >> a lot of memory without the need to run a special userspace memory >> management tool to monitor memory consumption when memory.high is set. >> >> Below are the test results of a simple program showing how different >> values of memory.high.throttle can affect its run time (in secs) until >> it gets OOM killed. This test program allocates pages from kernel >> continuously. There are some run-to-run variations and the results >> are just one possible set of samples. >> >> # systemd-run -p MemoryHigh=10M -p MemoryMax=20M -p MemorySwapMax=10M \ >> --wait -t timeout 300 /tmp/mmap-oom >> >> memory.high.throttle service runtime >> -------------------- --------------- >> 0 120.521 >> 1 103.376 >> 2 85.881 >> 3 69.698 >> 4 42.668 >> 5 45.782 >> 6 22.179 >> 7 9.909 >> 8 5.347 >> 9 3.100 >> 10 1.757 >> 11 1.084 >> 12 0.919 >> 13 0.650 >> 14 0.650 >> 15 0.655 >> >> [1] https://docs.google.com/document/d/1mY0MTT34P-Eyv5G1t_Pqs4OWyIH-cg9caRKWmqYlSbI/edit?tab=t.0 >> >> Signed-off-by: Waiman Long >> --- >> Documentation/admin-guide/cgroup-v2.rst | 16 ++++++++-- >> include/linux/memcontrol.h | 2 ++ >> mm/memcontrol.c | 41 +++++++++++++++++++++++++ >> 3 files changed, 57 insertions(+), 2 deletions(-) >> >> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst >> index cb1b4e759b7e..df9410ad8b3b 100644 >> --- a/Documentation/admin-guide/cgroup-v2.rst >> +++ b/Documentation/admin-guide/cgroup-v2.rst >> @@ -1291,8 +1291,20 @@ PAGE_SIZE multiple when read back. >> Going over the high limit never invokes the OOM killer and >> under extreme conditions the limit may be breached. The high >> limit should be used in scenarios where an external process >> - monitors the limited cgroup to alleviate heavy reclaim >> - pressure. >> + monitors the limited cgroup to alleviate heavy reclaim pressure >> + unless a high enough value is set in "memory.high.throttle". >> + >> + memory.high.throttle >> + A read-write single value file which exists on non-root >> + cgroups. The default is 0. >> + >> + Memory usage throttle control. This value controls the amount >> + of throttling that will be applied when memory consumption >> + exceeds the "memory.high" limit. The larger the value is, >> + the smaller the amount of throttling will be and the easier an >> + offending application may get OOM killed. > memory.high is supposed to never invoke the OOM killer (see above). It's > unclear to me if you are referring to OOM kills from the kernel or > userspace in the commit message. If the latter, I think it shouldn't be > in kernel docs. I am sorry for not being clear. What I meant is that if an application is consuming more memory than what can be recovered by memory reclaim, it will reach memory.max faster, if set, and get OOM killed. Will clarify that in the next version. Cheers, Longman