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 A87D5C0218A for ; Thu, 30 Jan 2025 17:32:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BCF5280299; Thu, 30 Jan 2025 12:32:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 045F7280293; Thu, 30 Jan 2025 12:32:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E339F280299; Thu, 30 Jan 2025 12:32:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BFE8B280293 for ; Thu, 30 Jan 2025 12:32:28 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7666BAEE0C for ; Thu, 30 Jan 2025 17:32:28 +0000 (UTC) X-FDA: 83064812376.17.9F366A9 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by imf06.hostedemail.com (Postfix) with ESMTP id 7F65B180011 for ; Thu, 30 Jan 2025 17:32:26 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kbx8wAkW; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1738258346; 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=oWFaS3UTJxiWqFEp5gwjlr0r8i+ewsDGNS92rk/uZf0=; b=mWiVDZOveCBJekR/yTYr80uibucjoXkSr/038E1z/mLftDjLLm4fZ6B20vjw0pRA3IOBS2 er65LHFfM36UaT4b/obG466Tc2BWKvaR5N0TPIJQJYlIyZwyCEtd+YBVZLck/ssebyqsV8 zcaAeZrAQBy4KpSYoAQyrVAbhvugJhw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1738258346; a=rsa-sha256; cv=none; b=GbLF+eVXj90NZJ5Lyc370utWeSY42AHcjXjwR6COPhMVrVyFKHRzJpUTaI1H7F2iR5M0M0 O+05KcMaxRR9PGkwJTjs4YT2G3WfL44w/wlfb0rakU7DtRkLYBoA2G4ewfOCKTupsRAuDZ GnBrKs9qGejxSaai21vvDCqZ1ZTIQDA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kbx8wAkW; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev Date: Thu, 30 Jan 2025 09:32:15 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1738258342; 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=oWFaS3UTJxiWqFEp5gwjlr0r8i+ewsDGNS92rk/uZf0=; b=Kbx8wAkWixPZU0LONO1qz11C4y1+8LqtNQVTHWGPGBlLqUlyH/AjkP1v5TRjhuo23YWViK s+aJ5xZ0GJ8yzS5ToOmWOkGFBSCfnkev+wQ+ce/4FclhMAo1PxCwJoHsB95oIN2K89r8RJ ZbLK3VUPtFQDSQwCvNhMcavHYv2jIMQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Waiman Long Cc: Roman Gushchin , Michal Hocko , Tejun Heo , Johannes Weiner , Michal =?utf-8?Q?Koutn=C3=BD?= , Jonathan Corbet , Muchun Song , Andrew Morton , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Peter Hunt Subject: Re: [RFC PATCH] mm, memcg: introduce memory.high.throttle Message-ID: References: <20250129191204.368199-1-longman@redhat.com> <211b394b-3b9a-4872-8c07-b185386487d3@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: gr664uqy5sezyth4xjd4baqmfok7a6yw X-Rspam-User: X-Rspamd-Queue-Id: 7F65B180011 X-Rspamd-Server: rspam03 X-HE-Tag: 1738258346-599856 X-HE-Meta: U2FsdGVkX19VIetxghYnUT9h6btITkQY22izwLHpMC0t7yyWrRdY6AWUlrCIkc+3ql0F0inrvmU2rA+VqqPUZUpAx8jghF7ilh9CP+j/jTnyzn5wObK3Dqe0hEaShnj7lEcIx8iWvO8QMQmD6+sDwtAdAcICqDk+IXWiIr69ip+QnwdTaW/ZIz0iktAePcLKIX28m0ZDOFNZheshK3UE+5uMFFPFANWCWcqM3D9XLvIwIxqSNwjw0r8f4AbUqvp/s+LvnTv3jT0RkBCpH7GJ3zDWPydo9/12FYIt29NdnrULkdAHtQ+nQIkVCUzB1YnKxYUtxqVl5Y8o4qgsLKNRfxQN83ikHV1jIXWtEAKjVDNUYSzHuhuzN6+gggUpVtmwW6F7nmhcw3dcrPrftHJ+IMgfwfIbxv2VoZ1P1H8GW5uN/5BnyRWjZXkZPgPoAi0ShnRo/hbsSmLUwc0m3GnF1y+p+5PKNGpz2rrA6QkPHVw6Bxk0rVQye/Ng4OBvKRSKwgc12SBj0HMSI0YXlknDPxMTegCgSlMkbnM3UTeOo5PWfqJCZ4vMe1pNcdvM8akcDwZBsQ97yysTRlJIKdD2Z8P980rrgMQRLeX5JE6gBsFIAY2rXMz6x8ObuvBtA5qK/PUueKy8cadTPg9ZD8GC33sD3QvhgU5T9/Cd2bfMoZAxDUS1ZHTrOmSQOfHTTEIkw+Ai3ODhFQUGyO6YtQnKtkQIkOHOb8VzymVitljgn1fbyE5GKHLO7rnJCkWbqoS8Uf4MkLh3aTcir8DAB8lGUgWmr6clZfg7Fz5xzJqDxqZRakxmDtqqlCJ0sIo7+rJ0V4bkKVTlccymiDtLn5uVqNxM61q9zoA3ET64zvu1dOgeUEq5mB3wfVcYx4/F1Mm2GfxqbtvRia02rODFert3SKN+A52AI2hAY7pDV4tHj9b9/Fk7cRq1G3DF6ydKlMu5fFEPadwmEggbMFO9Ewl rElUfN5U k+rMWnSQk4mhObcwiDSrR7ymwLFfzzL9EF3DgxmDGoI+zwQLeFP2h+hSnILDUYA97iIu62aHV2yW08obcjgmpGKYhc20xjOG2dcs28lRB+ipoSgvskLiby2afissJW88dFw1s5i/lAscG/fblSpZAk+h0kuhm9IPYEamG9QJsgQAVtH5hA7Fyz10fwA== 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 Thu, Jan 30, 2025 at 12:19:38PM -0500, Waiman Long wrote: > 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? I wouldn't call it a proactive reclaim as reclaim will happen synchronously in allocating thread. > > 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. > So, what happens if reclaim can not reduce usage below memory.target? Infinite reclaim cycles or just give up? > Cheers, > Longman >