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 2E081C3ABB6 for ; Wed, 7 May 2025 07:30:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 67DF46B000A; Wed, 7 May 2025 03:30:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6382A6B0083; Wed, 7 May 2025 03:30:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CB3C6B0085; Wed, 7 May 2025 03:30:18 -0400 (EDT) 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 2E0A06B000A for ; Wed, 7 May 2025 03:30:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D243B5F93E for ; Wed, 7 May 2025 07:30:19 +0000 (UTC) X-FDA: 83415288558.22.57BE87C Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by imf13.hostedemail.com (Postfix) with ESMTP id B8FFA20003 for ; Wed, 7 May 2025 07:30:17 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=PeRvCydH; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746603017; a=rsa-sha256; cv=none; b=nIIF8eg9b3mebfEAEmPLX+3V0irxbdE9jSoy4gyRtX+dPM1/3jW1cwFymECSbP5+gKrTJk vvUP4cZBIpYFBhyKw0Fw5bSjyoa5/YpWNoixWANIzDOMwUlNEoFsmUovmCP3aqlq1vJMY5 unrZ7j9gTYQzPYk4Jc4+YhVekpJeaDY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=PeRvCydH; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf13.hostedemail.com: domain of mhocko@suse.com designates 209.85.218.41 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746603017; 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=FUcSqGima0N93ktxJzZwEEa+6e2a/wBilAPnrzIPDEg=; b=63bBuzVXx532nmvnv0qxz/vcM8KRGvwonW1DdCHLNfN1Ez694/8DDIK0oXnHZNOp35jNG+ H+I7bNpiheR/MfAh02Bq0isH6eUxIj0it5ws3uMuivnC4/CrLwExK6+aHPfags251qRzFe bMWw/6XHV+TFVX7641tfdhjzDboDx5g= Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-ac2dfdf3c38so1190662766b.3 for ; Wed, 07 May 2025 00:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1746603016; x=1747207816; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=FUcSqGima0N93ktxJzZwEEa+6e2a/wBilAPnrzIPDEg=; b=PeRvCydHJx+XVzXtd2w7A7uOK9fbu40tlP5qLIu/8izenjlx1UjgwNkG1LZ0wLAoe2 jQ7cbILeE8gnJsR8N4S1hoC8ykmEe0ydNFLIdBF77kjwgYi7i0N0HmIrteXn52EY3Bye dOl7ygGerTl5ubNvLo7t30HygRYVHfySj035M4RWZRMpB15y7/iMRPDZmKwVyYbpm+V9 skloV3pYNAUrmJFHAc8OqUImHoenbuPy0rBU2Rn3j5f8G857RtW5h8MgdVV6ZVfa3QnB VkeGtf7anRFdtgYrgzKuVzTa8CJgzlxKJB1KzHOtjZ3ky+oqmSwFDbzpvXy4go4KfC3T ETIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746603016; x=1747207816; h=in-reply-to:content-transfer-encoding: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=FUcSqGima0N93ktxJzZwEEa+6e2a/wBilAPnrzIPDEg=; b=ggPr1fprTkIoP5cJ92wjMimb9NCbmRi27yTZ1fVJQcFC1oYwOJuMgn9/1bHQ27kE+/ NuEL2ipDZmGYPLYqNDVVHHV2g3QK94hjUFZEq0Qtqsn01ePf2g2bhFBOUdeXuBuS7tsu BJrh5uc3KHrlpQI/XRrqoNnyYcebCObudMHja1XW45Q4wNlTiyqdYKZPc0yp3eIm+ARs YEK9HkYUYifBdeohlQAcKgN2xyX7DSyUTzjJwvfq++zbYaCDk2LWXLuTp/qd8C3iHdqa jhMmoYi3EEgBZGZkyKFwJnrGT4VHSX7xtScR5A++FGtqPlPI3nABocb5pjDlXY7y50Nm Ejlw== X-Forwarded-Encrypted: i=1; AJvYcCUP7NqFdjtsralr1gkdjofIgnGtAd2NxZulet7ftLyG9QbE8ru0k7J5XxobRN9q/nm3/UO/K193Vw==@kvack.org X-Gm-Message-State: AOJu0YzOANjO+FGdFJLWuTZV6E1AEW0mncd00vCrfzY9WUC7pIRVDyJN uX6BJpzSeuk8gM+rQ70PcYwX8PlrkLQvIzVIu+rTWGFPPUAM6EZ0hLNNRToGNeo= X-Gm-Gg: ASbGnctTww5P+bNVX0T6h4yiR9HU+IavA7spPGMDPbAWG7kV4pfD1u16XVo1S9tSnD6 gC0gieQgSvn6d8qCmbXyVQ0Wp9tMQQT5FwG4HHFLj19GDXkD8FNmfINErBqpEJXSL/rDJqF7JlG psFOh86T4yH3xTPg6YQlGE0qV/gwqAwimDq1OMrkd/1tzl5/RCqD4fTchGyGyq3pdCcAAj4D8Um 5Ij1SnyDpV0m5OPsM9jVtDmyCK758DXACUswdrPUHu/zwWjef3p3DaINoKQLRS0PGClarTJFXkB 4up4Oc+66Ui5d7W1mHBM99fnNSn97hw= X-Google-Smtp-Source: AGHT+IHqKJq02AuZsFAg2B/0m60918EK+9L4EdzuO2FhU+iMmip8U73qvmZiflX/x/5tz03zWRyg4g== X-Received: by 2002:a17:907:8d85:b0:aca:cac8:1cf9 with SMTP id a640c23a62f3a-ad1e8ce4638mr216327466b.33.1746603016054; Wed, 07 May 2025 00:30:16 -0700 (PDT) Received: from localhost ([193.86.92.181]) by smtp.gmail.com with UTF8SMTPSA id a640c23a62f3a-ad1891a2515sm862828966b.39.2025.05.07.00.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 May 2025 00:30:15 -0700 (PDT) Date: Wed, 7 May 2025 09:30:15 +0200 From: Michal Hocko To: Shakeel Butt Cc: Andrew Morton , Johannes Weiner , Roman Gushchin , Muchun Song , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team , Greg Thelen , Michal =?iso-8859-1?Q?Koutn=FD?= , Tejun Heo , Yosry Ahmed , Christian Brauner Subject: Re: [PATCH v3] memcg: introduce non-blocking limit setting option Message-ID: References: <20250506232833.3109790-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20250506232833.3109790-1-shakeel.butt@linux.dev> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: B8FFA20003 X-Stat-Signature: q6sq6gz6rg9orr1cbdyr93srdojqy1ax X-Rspam-User: X-HE-Tag: 1746603017-370959 X-HE-Meta: U2FsdG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57xNg4tXE8CtUtJnuOusTuKz3rgPclDsHobbUuCyiWbXnEykUshzK5jAeq3WxATNUPO6jyeSerHm1ZDoQQ40jbPBIoQ7KnjnZcGyl/8XQWnQc64HDKdGQHCaUPLbx+WoZ8CoCjC1W6tK56Or6KvbmZn0YK/EAe8x4d+lKb8idnzDfFqC0uvJmQr+hLENvNzBmOc5kaA/ZP80w2tAZQEt1lTXF9Y2JI1tVOXhiDi/PowvkRGxUaCm4DTjG8phZMpVJkjovUlZ8zt5CjSbicSwnsJRfMwU+C7fmg1ZZtgOUX6T1YIS34p5s3WPsatxF86xdrRv+FB7KTBr+J3TrA8bCxSh9UZwRBPCyMmBoXwWygTJkF5TQ/QHsfQVQpAhpsTrHhIWUFT6ODf+9SuVwRbhQhCZZxhwXP8yzteJQ/2+T3FM8bAKHe6bzbjkaToi/CFnwK1iilHQ65r9qA7j+tINOXdmuwM/tS2Gt6eKEpx5yk6D5vAgDODTo 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 06-05-25 16:28:33, Shakeel Butt wrote: > Setting the max and high limits can trigger synchronous reclaim and/or > oom-kill if the usage is higher than the given limit. This behavior is > fine for newly created cgroups but it can cause issues for the node > controller while setting limits for existing cgroups. > > In our production multi-tenant and overcommitted environment, we are > seeing priority inversion when the node controller dynamically adjusts the > limits of running jobs of different priorities. Based on the system > situation, the node controller may reduce the limits of lower priority > jobs and increase the limits of higher priority jobs. However we are > seeing node controller getting stuck for long period of time while > reclaiming from lower priority jobs while setting their limits and also > spends a lot of its own CPU. > > One of the workaround we are trying is to fork a new process which sets > the limit of the lower priority job along with setting an alarm to get > itself killed if it get stuck in the reclaim for lower priority job. > However we are finding it very unreliable and costly. Either we need a > good enough time buffer for the alarm to be delivered after setting limit > and potentialy spend a lot of CPU in the reclaim or be unreliable in > setting the limit for much shorter but cheaper (less reclaim) alarms. > > Let's introduce new limit setting option which does not trigger reclaim > and/or oom-kill and let the processes in the target cgroup to trigger > reclaim and/or throttling and/or oom-kill in their next charge request. > This will make the node controller on multi-tenant overcommitted > environment much more reliable. I would say this is a bit creative way to go about kernel interfaces. I am not aware of any other precedence like that but I recognize this is likely better than a new set of non-blocking interface. It is a bit unfortunate that we haven't explicitly excluded O_NONBLOCK previously so we cannot really add this functionality correctly without risking breaking any existing users. Sure it hasn't made sense to write to these files with O_NONBLOCK until now but there is the hope. > Explanation from Johannes on side-effects of O_NONBLOCK limit change: > It's usually the allocating tasks inside the group bearing the cost of > limit enforcement and reclaim. This allows a (privileged) updater from > outside the group to keep that cost in there - instead of having to > help, from a context that doesn't necessarily make sense. > > I suppose the tradeoff with that - and the reason why this was doing > sync reclaim in the first place - is that, if the group is idle and > not trying to allocate more, it can take indefinitely for the new > limit to actually be met. > > It should be okay in most scenarios in practice. As the capacity is > reallocated from group A to B, B will exert pressure on A once it > tries to claim it and thereby shrink it down. If A is idle, that > shouldn't be hard. If A is running, it's likely to fault/allocate > soon-ish and then join the effort. > > It does leave a (malicious) corner case where A is just busy-hitting > its memory to interfere with the clawback. This is comparable to > reclaiming memory.low overage from the outside, though, which is an > acceptable risk. Users of O_NONBLOCK just need to be aware. Good and useful clarification. Thx! > Signed-off-by: Shakeel Butt > Acked-by: Roman Gushchin > Acked-by: Johannes Weiner > Cc: Greg Thelen > Cc: Michal Hocko > Cc: Michal Koutný > Cc: Muchun Song > Cc: Tejun Heo > Cc: Yosry Ahmed > Cc: Christian Brauner > Cc: Andrew Morton Acked-by: Michal Hocko Thanks! -- Michal Hocko SUSE Labs