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 87CF5C369AB for ; Fri, 18 Apr 2025 23:08:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46EB56B0022; Fri, 18 Apr 2025 19:08:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41D5F6B0023; Fri, 18 Apr 2025 19:08:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 332496B0024; Fri, 18 Apr 2025 19:08:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 151706B0022 for ; Fri, 18 Apr 2025 19:08:53 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1DF87C1004 for ; Fri, 18 Apr 2025 23:08:53 +0000 (UTC) X-FDA: 83348706546.14.7A2AD8F Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) by imf20.hostedemail.com (Postfix) with ESMTP id 1745E1C0008 for ; Fri, 18 Apr 2025 23:08:50 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H63bmwYb; spf=pass (imf20.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.185 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=1745017731; 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=Gf1keAeswgSG6BC7E7LDJ6t02p3D0ki+aO0HlIuVQxI=; b=gD9clLEU6zNO7BusxCSMMw/HlNlGvippiqRKT50EcEl6pMP3csukTrbzEgR3sXQ/lJXLb+ cDu9aUUWV1SkgSv2z9bguN5XBy0NfNUilLl7IcIzHSLWLYPIIszetzb6dQ+bcjUpvg6q+w fnjt9lGaREXESrAVQHenVGTPdrPqoXw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=H63bmwYb; spf=pass (imf20.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1745017731; a=rsa-sha256; cv=none; b=N6S1RwBBylsIfxQinWcjiZen+bO2h3/LdVA76GpjoGj+E3M7Ef1moUGeP0yVH9oa5EWdTJ CEBBz2CqhFqPIs2xEtibHiGUEaqNJuUXC7qi+P8WEPR4H6aHXJxol3YT8h0CNu0UxC4gK7 Jn1iLLzpGIYy4Xy8i07+o3FQiUpiIfA= Date: Fri, 18 Apr 2025 16:08:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1745017728; 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=Gf1keAeswgSG6BC7E7LDJ6t02p3D0ki+aO0HlIuVQxI=; b=H63bmwYbhXemae7q7EikEthIJXRxKQaYO7H9zavs20LiGbVNHPM0zDLBgsE5npjdB/qXrJ 1XYi2FGnBmMmHZ+NffzkapWq/bH7BfkwydV1TLk8BzsBEdqcNPA3YmfMa10RPHq9N/umcL TW29XB5UmQeJd7nYE3xvkw+SE7+TnkQ= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Roman Gushchin Cc: Greg Thelen , Andrew Morton , Johannes Weiner , Michal Hocko , Muchun Song , Yosry Ahmed , Tejun Heo , Michal =?utf-8?Q?Koutn=C3=BD?= , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Meta kernel team Subject: Re: [PATCH] memcg: introduce non-blocking limit setting interfaces Message-ID: References: <20250418195956.64824-1-shakeel.butt@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 5wzh9fq8bhkij4hnc7jijpbgo8bx8wtr X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1745E1C0008 X-Rspam-User: X-HE-Tag: 1745017730-296580 X-HE-Meta: U2FsdGVkX1/KxEfFe1nio8lGJxDydCQ0eVxYAbzksh8OdmY7Qlm1C1TnPOqRx6lOpNn6fR/bbJjaWVX69MDWLgaK4jDRgZdfnkr3o3Ih3dbQn/7c7jGPoBnsFnLLRWJGGsGG1o8T4pjRbX9KVMnL1zRJh80Mo3Iof4tJPtu3iFgLreqI4qjX+6MegSvfn4LOQF1N/21Wh8rO7ktGLN+PU1jofOcxSSQ+0VsDDy6mW9fTcfz1P+5IrnKXCQ1kxzmcSA09Ox/Io93L9Sl19Kh5oYEqTSmLj61p7uAHPtebLIJtZvaGPHwMdP7fPnSJeuvL1NRjkSsSjOdAywXWIDtlBgUC2zXKMoZKewP9Y29/ruM+uFgidPAHIx65yoBDOn4Jzn6wIlGogrIDb+KjT3ifLUFZMNay/gCxuJjsT8dsRvH7IgKL4ftNfgsDwPHOiAR9wJv6ggn8nG0UVw9hSt8MzfzjGq06WtB6uADRhEIaWa7M0TfGpWBw7iPO6fACkk4IGCBd8Heg71/aH5ubHCZkgl+UYjbapHKn2kNLaWG5n0rqYzkTsnSjBZRRhmBGhquuiDqfMYV84e4uN35oIgSK82ZW2eKjBApC5+hW7fWM6smWh817GUp5TgcTkoV55hZ12zKA+TM1d/+EmsDPvRuRld2PgV8g/9SqYOUutLfB17+RvsPCf3PcXiMKvoIifQ/o8nqphknDEiWX0Pq/ddzSeYZmBBXyjRqOii20aTd/0MCuA8LWqHnoFElkz1zEdJZxnozTx5qUQfrmjrcveGpnvjNewMTtvO/i9jFv5uJy03uWjLFD5GIwHQdfabHmQpRi7xcR9m3GxnzZqs6+tN+vr11Do/1/EkScpKrz35PZ14wSTgMdqO6dHN0CJHPHlD3pvJQ8hp4P6zMzRiPy7zTXQpgF448QqksDPsQk9mlwYDR588Nxu8ZdfxViQ8HTywEu7nqV8/lAXeKHmpkoUFP pehw4t5t gyg65MyuV0xSldTvasUmqkptRoaxuzIGUrjZyyl+iZVHGw2uEBVNAN7HjRZMU74N4U7TceMU4E8WTNZH71PYo/n6zzuhM3qUcyV4yAWcl7IyPE1RpTA6/qqOPTJ7vF3us0xDVKgZWVSGj9oJjEHN6uO1Mo6SpIUXFSr6dZPcaq0bkxikFtZeLzPngKmvcskS2GeA3H+3M2MSwETM= 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 Fri, Apr 18, 2025 at 10:07:29PM +0000, Roman Gushchin wrote: > On Fri, Apr 18, 2025 at 01:30:03PM -0700, Shakeel Butt wrote: > > On Fri, Apr 18, 2025 at 01:18:53PM -0700, Greg Thelen wrote: > > > On Fri, Apr 18, 2025 at 1:00 PM 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 interfaces 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. > > > > > > Would opening the typical synchronous files (e.g. memory.max) with > > > O_NONBLOCK be a more general way to tell the kernel that the user > > > space controller doesn't want to wait? It's not quite consistent with > > > traditional use of O_NONBLOCK, which would make operations to > > > fully succeed or fail, rather than altering the operation being requested. > > > But O_NONBLOCK would allow for a semantics of non-blocking > > > reclaim, if that's fast enough for your controller. > > +1 > Any reasons to prefer one over the other? To me having separate files/interfaces seem more clean and are more script friendly. Also let's see what others have to say or prefer.