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 13850C0218F for ; Thu, 30 Jan 2025 17:19:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 991152802A6; Thu, 30 Jan 2025 12:19:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 919B82802A5; Thu, 30 Jan 2025 12:19:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7929B2802A6; Thu, 30 Jan 2025 12:19:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 57D942802A5 for ; Thu, 30 Jan 2025 12:19:58 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 35732A0449 for ; Thu, 30 Jan 2025 17:19:48 +0000 (UTC) X-FDA: 83064780456.30.74EBD9C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id A969A1C0004 for ; Thu, 30 Jan 2025 17:19:45 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ecCjZEFu; spf=pass (imf18.hostedemail.com: domain of llong@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=llong@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738257585; 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=0Fa6Fgsa1RBhChBXyZSptjF+ocBVY25XthbUA+IR9Lc=; b=Va74L1ifu+TbXQq6LkYM4hOl0jnybY3hW0WEXIZScQMTuYyKlR3TCAqUGgWhjP9oy4qFZL a4ONRXPb5WZtgxvYP6rUiEpaa2zLXgPS0cK2JOARpfpODgwFzd4Vp0mwUoINcpXFgc3tkF aqjn7+8oPbUvllqWwMgPjnK+Cc9qYXA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ecCjZEFu; spf=pass (imf18.hostedemail.com: domain of llong@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=llong@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738257585; a=rsa-sha256; cv=none; b=a3Ls0ZAHg3ZNT6kz9ZYDX3y0z2OTdvcH8QDom+8ab4B2hJTy6G5mlEYarn3bIHvQ2IOgFc NlHPdanurFRrMC+dPytyFYf3bA+nTpCH+yjHiejSrLFy+kwfzda+A1CbAVNWomYMNEKnd6 8+E+sRNOVcSpsBGSjuiqFMBmhSfdXAg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738257584; 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=0Fa6Fgsa1RBhChBXyZSptjF+ocBVY25XthbUA+IR9Lc=; b=ecCjZEFuaxne/mPr5QTzB0bfCUYBn4a6c8Zh2DH4EWknTQn4MS+8TUQ2yoCNsy1iOzrhNw OpXrSqf+OQphY0a+UTB+k+yPpgRISluXxZdU4hpc/KpBXSThS6etWFKrEr9wX1ErapZre4 JwhDey0ygBIAcCNbUGsJUGTBZDuD5GY= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-47-jYNHTXHUNX2wIfUoLkMDwQ-1; Thu, 30 Jan 2025 12:19:41 -0500 X-MC-Unique: jYNHTXHUNX2wIfUoLkMDwQ-1 X-Mimecast-MFC-AGG-ID: jYNHTXHUNX2wIfUoLkMDwQ Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6d88ccf14aeso16448876d6.1 for ; Thu, 30 Jan 2025 09:19:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738257581; x=1738862381; 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=0Fa6Fgsa1RBhChBXyZSptjF+ocBVY25XthbUA+IR9Lc=; b=DI43s9fTFuw8sG7I8mkRIWrdYmMY5Ez9SN4fusCYV4i6Ev4acRfDxhXQKYLZR7lSfh f6InE3NGn6ZsTHwpiPBOXb2uoAF84JDyYozJ+fCwHj0UjuZHE0ty6YMG6hqem/6OxQgT CUueYmatciuQbGyZkAwXiecgZGL9W88hEFggR0kOy7uCpj9HpMsBXNDBuJB4Le/R1256 R+OsL5VJydwsEviRDOktbr7MGNU9RCQCr2vqgL9eiPcuVV38TRMiL/hpkDEdHX/ET59h E/aXnrpWXmwWpg3j82dVsKWcZDosLBy5V/UF/ejgQTVtx+hbn0M9K5MkB7lomweNlKZS 0UVg== X-Forwarded-Encrypted: i=1; AJvYcCXjWbmseL8lY87Fsut1nDAYzCo47Cs41IGSGYJnN4F8GRUYv3XcgyU2b2yARc9mJ7UL+7RRFFN0sQ==@kvack.org X-Gm-Message-State: AOJu0YzG3bdPGRIl2Ip9zwJAxYncE4slLE8KAA8RvhnrzAI/FB3fEBJC 433yvDKPQiWYWEq1iksi2mF1FR6BGDqIarjwUGqre/hNRyR2ajm4LTb9dqAWNHuMUfBJ7+GuuXW nZ/gt+VXgb08QAzv4TsRZhZrAo104oQ/iKrzKhhM6lQ7Q1I6C X-Gm-Gg: ASbGnctSI0b2VI2KBjV6LIb30p0U4aGF0q5kvCSPLmkDMHDhQPWFY3y7jKUXYIICxrx KGr4HeRzpUm4/CrhDRKny7KeOVNG9u7OYRJpHUt4OF3iMTd/odBSz8j0TIKLE6xKo+fQAXbBdoa EXfzKprURDUNsNXJScVl+bWc6aIyDCzCvrJ1j0tNoOaHsh41GUYf8wZYpE+U01TbC8B1ieSSx85 DgxrbQvoCj4clinsS2sepaBr7+SHw9Z7OWpdqNcj4Q+FPzMLU3VIz0LZDjWQ1OwNvTBr13OzVvT abHtxYbHURxufHvoNrEOLS/zYXXhnVAiYx/pXkQyMuOdjnCwYfA= X-Received: by 2002:a05:6214:4603:b0:6d4:215d:91c3 with SMTP id 6a1803df08f44-6e243c62dddmr131733476d6.28.1738257581140; Thu, 30 Jan 2025 09:19:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8ypqrhL6idza3miOhUWJjRsaz1USTPrfph2cDh2w5Kr5q2g9rBY4V4Gt+j9lmXVuYoB025g== X-Received: by 2002:a05:6214:4603:b0:6d4:215d:91c3 with SMTP id 6a1803df08f44-6e243c62dddmr131733076d6.28.1738257580864; Thu, 30 Jan 2025 09:19:40 -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 6a1803df08f44-6e25495e76bsm8107936d6.125.2025.01.30.09.19.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Jan 2025 09:19:40 -0800 (PST) From: Waiman Long X-Google-Original-From: Waiman Long Message-ID: Date: Thu, 30 Jan 2025 12:19:38 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] mm, memcg: introduce memory.high.throttle To: Roman Gushchin , Waiman Long Cc: Michal Hocko , Tejun Heo , Johannes Weiner , =?UTF-8?Q?Michal_Koutn=C3=BD?= , Jonathan Corbet , 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> <211b394b-3b9a-4872-8c07-b185386487d3@redhat.com> In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ccnlZhue7EmGWJ89SV13wVrFMbjyudcjO9-qOxF0fd4_1738257581 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: A969A1C0004 X-Stat-Signature: 1p894ms39ikquua9wyriwbwyy4yct434 X-Rspam-User: X-HE-Tag: 1738257585-924698 X-HE-Meta: U2FsdGVkX1+AS13VG4pPahaUBe58r78XBomYaF0k5n1yBgRs+ajSvymZ+LVgVR/Da87gOKmuFaMLYD6fiEOfJoyr13Iuse9oYr9ZM6qEdhHn3M972cT94FtviEa31L4pcmr5moRjbCDVnwLqX/Tuy0akPjuYCVfPys5+GedoFGC8m88eyDhFyYMsv8cm78934Ncm7+ItvQuuyG5uC0a50LkPymXx4aUW8eKsM0qyhvUK9iQ8kLrOpyQ/mY9wL325rZWF9wCOcDeOP1ksPzQ0xrvNXk4iEADBza7tN/xMLeTbCcF89h1kmThv4JK/kjum0ejvDdoJdQkFVnkCN34Ewq8OaU0TBXY8xbvAsVlXmL9WZWR+d5Au/+jrbHBmpHMOuaDxF84ENQ4thbnDOIP6TF5T1XeGYJ33Shw4cZL8KpYElebtWx9yyGy4Y72NNqC4EvhQ/q/eHOvrJqZ0z8WE6GX1zT3dOePBa3J3iWwdChwwFAjkoRYt3qZhhGCv9ghtkjUpOcYhBHXH/FxaWf/KLymC1oQUc0R+U5pzCWwzmNWczebK3r5PZhqAEorwyi2IbUGZ5XGWlU41GwP/ZCvrNcDv/PCp5w1ERwa2yC/dFSNmnpB+x7ZvvVtDxJnzYKDu1sEorOFdkNpqS6CD0zLaz0HgkjHdoB1f0JFR/Srhjr7wm7Xa8gl/AQMjHhhIYjbNu26/KOs5dqmR5Fl0bRI3xaqPc4OM/UFiaXYhIgFeLgwwgKNMGZ/1aNJ+0VD1qvlVAZInPCxuYwJuPn836CUvwEo5I5FHXsjk6f4ThyYWLSwdBYVxJDVcxZm5y/BTDAqHYL29nt/XsjrEkwpjxZePMtG/+NjPfrUt6RBuXpU4kTOQI0YASm0qwPpf0jjGYzRcb0me37B1R13JXwpvOmPuKKqi1hds53uPfa9o4T8gpsnuhXvrvFjxwdC/I+2u1Ik1fVD94OLYfWCnl25GKgk xNUSQYyM tcu+mvR2O9GFpOQdegNNaHqn7R6PB+989FM6cXK4PdgKwb2Itfjo9jefUNUQ83iclPzDYCs6PeLjehPZoMbKBMe7YmZ5R3/E4bIYi1F3Pr7cxREOjBPeZe/UwGRqJ52YeLT6tvtxWlgOSbfx0K2kW4ey7/a5Em/V3VuYefk8dOyePq74jduRQ5jK3oyUq+DfqKyPbavPfqPFnAhEOwchhh7h5BO5XrKpElyoqlRXcBf88766naWUGpygymmF/eMm4CygsYXX6+oXNVSK/OHhubFph1Oqi9N7uUpS0nk3b/wvD5iazWAJm0xZoykTiqenO7oQQ/9bfV3s2VGrRSBz6bqTkvGtNd4k/VYztjRFmnO/DVPm4gMUok3jDwa6btctQjLhoJdU0kF0zG8a0/FkYjw4pu7LbrjjZq5x6rQpXcKsuyqQ= 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/30/25 12:05 PM, Roman Gushchin wrote: > On Thu, Jan 30, 2025 at 10:05:34AM -0500, Waiman Long wrote: >> On 1/30/25 3:15 AM, Michal Hocko wrote: >>> On Wed 29-01-25 14:12:04, 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]. >>> Why is this a problem for them? >> My understanding is that a mishaving container will hold up memory.high >> amount of memory for a long time instead of getting OOM killed sooner and be >> more productively used elsewhere. >>>> 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. >>> I do not like the interface to be honest. It exposes an implementation >>> detail and casts it into a user API. If we ever need to change the way >>> how the throttling is implemented this will stand in the way because >>> there will be applications depending on a behavior they were carefuly >>> tuned to. >>> >>> It is also not entirely sure how is this supposed to be used in >>> practice? How do people what kind of value they should use? >> Yes, I agree that a user may need to run some trial runs to find a proper >> value. Perhaps a simpler binary interface of "off" and "on" may be easier to >> understand and use. >>>> 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. >>> Why cannot they achieve the same with the existing events/metrics we >>> already do provide? Most notably PSI which is properly accounted when >>> a task is throttled due to memory.high throttling. >> That will require the use of a userspace management agent that looks for >> these stalling conditions and make the kill, if necessary. There are >> certainly users out there that want to get some benefit of using memory.high >> like early memory reclaim without the trouble of handling these kind of >> stalling conditions. > So you basically want to force the workload into some sort of a proactive > reclaim but without an artificial slow down? > It makes some sense to me, but > 1) Idk if it deserves a new API, because it can be relatively easy implemented > in userspace by a daemon which monitors cgroups usage and reclaims the memory > if necessarily. No kernel changes are needed. > 2) If new API is introduced, I think it's better to introduce a new limit, > e.g. memory.target, keeping memory.high semantics intact. Yes, you are right about that. Introducing a new "memory.target" without disturbing the existing "memory.high" semantics will work for me too. Cheers, Longman