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 755FDC2D0D1 for ; Mon, 24 Jun 2024 16:33:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A199B6B0391; Mon, 24 Jun 2024 12:33:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C8E56B0393; Mon, 24 Jun 2024 12:33:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8693D6B0394; Mon, 24 Jun 2024 12:33:41 -0400 (EDT) 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 6AA896B0391 for ; Mon, 24 Jun 2024 12:33:41 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0C75C1C0600 for ; Mon, 24 Jun 2024 16:33:41 +0000 (UTC) X-FDA: 82266328242.22.18BD468 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 00CF24001E for ; Mon, 24 Jun 2024 16:33:38 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bb+Wql1u; spf=pass (imf01.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@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=1719246812; 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=dgN0dBgy6sR0oAWnnFjEXlGg9ErnyA+uGyeQrtdxBG8=; b=544pptBIC/4W3dtMqD/mygm5aD0rpkX+SxG4EDcIe3vjwhCq+pyD5gGaoP3AWJdzbw/Yb5 57uBs5Dja3n0rXG9GIKY0m1KNeHUC1X++vtSrbtAogfhPkELKmp/IkDSvBVdOibwKE4pWj 5M5LsnyTsJfuk1uXlm8VqAkKjxe08Rc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=bb+Wql1u; spf=pass (imf01.hostedemail.com: domain of longman@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=longman@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719246812; a=rsa-sha256; cv=none; b=x+RtCUXfmGr1oe2tjNYgoq0usX/g6aypEqbIH+HeY01yHUADTX6RrAubO3yxyH1jbwu2gm oUv98ACAStny849Gkp3LncFiJZjv4dnUdGvR0Qj7tk5lT8p3rgULqK6LTtslXI1Rp8DKcR c7O+muW1sjxdKmJlewn5scgHk0fYzJs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719246818; 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=dgN0dBgy6sR0oAWnnFjEXlGg9ErnyA+uGyeQrtdxBG8=; b=bb+Wql1uJarYltQOh74HayYoqmHzuyn1ofCBCvg4MdfYUPZ+K9m6WHNIAaMcNOql7e6PWa WikBkAYb2T2IEK0h3tp0IuvWm0uB2Jm7bnvsI2YPo3qVyqZYtIi8++VRPycoRW+HPQh07q YaxAktBB3AmhET91y1xENX5hdOApPOo= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-106-hyTBx4oRNMyFE2NshUZ6sw-1; Mon, 24 Jun 2024 12:33:34 -0400 X-MC-Unique: hyTBx4oRNMyFE2NshUZ6sw-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA53F1955E82; Mon, 24 Jun 2024 16:33:31 +0000 (UTC) Received: from [10.22.17.135] (unknown [10.22.17.135]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC0AB19560BF; Mon, 24 Jun 2024 16:33:28 +0000 (UTC) Message-ID: Date: Mon, 24 Jun 2024 12:33:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] memcg: Add a new sysctl parameter for automatically setting memory.high To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Muchun Song , Andrew Morton , Jonathan Corbet , Shakeel Butt , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Alex Kalenyuk , Peter Hunt , linux-doc@vger.kernel.org References: <20240623204514.1032662-1-longman@redhat.com> <77d4299e-e1ee-4471-9b53-90957daa984d@redhat.com> Content-Language: en-US From: Waiman Long In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 00CF24001E X-Stat-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emR8NB7lGA5fN9StUV5b5+ZDxx5yY42SgFhkvq0qumTRadqGvTWib6MSmKf7wZSvuAOdInpiGm9Of39ODUAyP1JrjDuIW5RCaMJ8jFY+619oX1ZA2kuyUr7fI0GevFKJzY1o1FX1RuK31CAS/lXCk8Mifkfsl8bFT6Ug03VP3jIDA9W804QkeOctL9REFlABXJE3HiBuvrT8dDK7zZffNj6NWDxpTb12ytap6++eary98I633Lgj8Dodrge6w= 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 6/24/24 11:21, Roman Gushchin wrote: > On Sun, Jun 23, 2024 at 04:52:00PM -0400, Waiman Long wrote: >> Correct some email addresses. >> >> On 6/23/24 16:45, Waiman Long wrote: >>> With memory cgroup v1, there is only a single "memory.limit_in_bytes" >>> to be set to specify the maximum amount of memory that is allowed to >>> be used. So a lot of memory cgroup using tools and applications allow >>> users to specify a single memory limit. When they migrate to cgroup >>> v2, they use the given memory limit to set memory.max and disregard >>> memory.high for the time being. >>> >>> Without properly setting memory.high, these user space applications >>> cannot make use of the memory cgroup v2 ability to further reduce the >>> chance of OOM kills by throttling and early memory reclaim. >>> >>> This patch adds a new sysctl parameter "vm/memory_high_autoset_ratio" >>> to enable setting "memory.high" automatically whenever "memory.max" is >>> set as long as "memory.high" hasn't been explicitly set before. This >>> will allow a system administrator or a middleware layer to greatly >>> reduce the chance of memory cgroup OOM kills without worrying about >>> how to properly set memory.high. >>> >>> The new sysctl parameter will allow a range of 0-100. The default value >>> of 0 will disable memory.high auto setting. For any non-zero value "n", >>> the actual ratio used will be "n/(n+1)". A user cannot set a fraction >>> less than 1/2. > Hi Waiman, > > I'm not sure that setting memory.high is always a good idea (it comes > with a certain cost, e.g. can increase latency), but even if it is, > why systemd or similar userspace tools can't do this? We actually have a OOM problem with OpenShift which is based on Kubernetes. AFAIK, the setting of memory.high is still in alpha for Kubernetes. So a memory cgroup is set up just by setting memory.max at the moment. I also trace back the OOM problem to commit 14aa8b2d5c2e ("mm/mglru: don't sync disk for each aging cycle") in the MGLRU code. So setting memory.high automatically is one way to avoid premature OOM. That is the motivation behind this patch. > > I wonder what's special about your case if you do see a lot of OOMs > which can be avoided by setting memory.high? Do you have a bursty workload? In our case, the OOM kill can be triggered by writing a large data file that exceeds memory.max to a NFS mounted filesystem as long as there is enough free pages that the dirty_bytes/dirty_background_bytes mechanism isn't triggered. Regards, Longman