From patchwork Thu Mar 30 20:22:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaun Tancheff X-Patchwork-Id: 13194828 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 1FADFC6FD1D for ; Thu, 30 Mar 2023 20:22:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 972296B0081; Thu, 30 Mar 2023 16:22:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 921C36B0082; Thu, 30 Mar 2023 16:22:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E999900002; Thu, 30 Mar 2023 16:22:53 -0400 (EDT) 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 6F08D6B0081 for ; Thu, 30 Mar 2023 16:22:53 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3D48F16028E for ; Thu, 30 Mar 2023 20:22:53 +0000 (UTC) X-FDA: 80626688226.01.452E0AB Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) by imf19.hostedemail.com (Postfix) with ESMTP id 6BF661A0004 for ; Thu, 30 Mar 2023 20:22:51 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ze1fJTTr; spf=pass (imf19.hostedemail.com: domain of shaun.tancheff@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=shaun.tancheff@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680207771; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=OBkq6KxCtXfKvlem/Zb/2GDPHcnhhSsCCkCs5rwvqhw=; b=X2D4BLUykgMUYVhP69wnky+6jNpAbpl6rmoWx27SPKGP2UXgPC/CMjeXS2pLR7hZ/WfZtW 66sEanZTirbclwNYW4bME4QSmdpj9sh8Z4frRadlsmmnpzViJQqu1Zm3yb2XtwR8v7y1Y7 UMVUN7KXTmN9vyzYpszY0n9qWqpCM30= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Ze1fJTTr; spf=pass (imf19.hostedemail.com: domain of shaun.tancheff@gmail.com designates 209.85.215.182 as permitted sender) smtp.mailfrom=shaun.tancheff@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680207771; a=rsa-sha256; cv=none; b=dWtsz2d0xPkhLeNuWFDVqVpoHT2zUoW4vb+yoAJPzu4cRBjb1SgVlR85MEUTTMywL8jSK6 cQYiL4CsdM1QoYw5shcpX0HXz49sNWQ1RDlAteDEfF9qATbf9ymqmGC3n+2lcE1LYwmJkv kSe2NL+kNHxoob7lPwR1wgxCaPoDcm8= Received: by mail-pg1-f182.google.com with SMTP id s19so12148121pgi.0 for ; Thu, 30 Mar 2023 13:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680207770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OBkq6KxCtXfKvlem/Zb/2GDPHcnhhSsCCkCs5rwvqhw=; b=Ze1fJTTrAjpXdOhtpMZb/pWrc+OxYU0E2dF3+BqmPVjzlrkpBGMbVVwlILNlZ/qbnv mjaMFzag7RBRmgw0vQCsufH1JIGiRw7v2iYCClFpCDlDLUrU4Gswed1vjjTf2551B2t1 y1KP+9T+SgP7GxAskck2N2B38gAgeP1h8RqHlYUanT4Tw9NI9VV37kqbYbk8tYCZyIDs wsJyTGiTuvI7HhK6m3Frln7sAMRGFQy5OYDvRxyd+y6Pt5PZs+MaAH06PlqCym4ehpQF eb2c6pzclizqej8lG5CHoN5ppB5BHUhjjXI3SqPMD1NHXZxMgzz3d4SwNuVISbEIS9K6 2xMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680207770; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OBkq6KxCtXfKvlem/Zb/2GDPHcnhhSsCCkCs5rwvqhw=; b=x9NJLJ4dA7d3cdMJQicW0cud4m3xjSvIJ5bGJLn/HONVY8zXGsRYfSU9WDkv++8fPm hAdSkwexS7fUBfwePpT6kks4JzedVwULTM+zGXsuJm1bEB8m/L25tZ8UzUM/kLq9fVvy WCqIwXLcGeenfBEeggLWU2v/s9xip2twDynEwlukX9nN9Cw8f5dOIGAauYbIXhUaEbGL A6v6KyqGHdqU2lkjX/Vz0u+SAwEZWRoAUxjulDru+ViWLqIwj5gopk0uMIRxXMmRN9jS +An86eYyIwnyHElK28Rdjk1NefMeYeFV3BJV/CjFufLmdkOHLGCfXE0urtVsd2R7nTGu 6wZg== X-Gm-Message-State: AAQBX9f80cJaKJXtbVLGk6Om8XEIO8a3sFiF3jk2eWadh9XXiSF6qH68 JEBdpQCPVOuOF7ScToHKxC4= X-Google-Smtp-Source: AKy350a/3LDVNunLU+X2jx+/r8XTGQn4nCYK32oghDWPolROcLXTb+Xmjs+x/CZAAmduRrhpeGJD8w== X-Received: by 2002:a62:5246:0:b0:628:87f:6b5d with SMTP id g67-20020a625246000000b00628087f6b5dmr21039787pfb.11.1680207770173; Thu, 30 Mar 2023 13:22:50 -0700 (PDT) Received: from lunar.aeonazure.com ([158.140.180.109]) by smtp.gmail.com with ESMTPSA id x22-20020aa784d6000000b0062505afff9fsm266987pfn.126.2023.03.30.13.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 13:22:49 -0700 (PDT) From: Shaun Tancheff To: Johannes Weiner , Michal Hocko , Vladimir Davydov Cc: Shaun Tancheff , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, "stable @ vger . kernel . org . Shaun Tancheff" Subject: [PATCH] memcg: Set memory min, low, high values along with max Date: Fri, 31 Mar 2023 03:22:32 +0700 Message-Id: <20230330202232.355471-1-shaun.tancheff@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6BF661A0004 X-Stat-Signature: axwiua9o9nhxc18xugh9agzwwsn1yr7a X-Rspam-User: X-HE-Tag: 1680207771-431343 X-HE-Meta: U2FsdGVkX1+Lre0bkOCWEMiXrLefXYJr/Bxp26qS3MDZ9kHAwO74RzjRsPRHP3hXY/00oYwV01dYPMvfYL+sZDe2VNJq8At9tP/p8C/PybEppnv7fCTk5t6mJTJzpPC7caAMiOGLiNrLgbl6gkLXVmW2WBDmcRptWULjIn/RVsZrXCPGTZTQAbC6PMbI3E6TDWdBRw1X1vmMaH1+6YEVc3yeC/1rtl1XO8u8vNDoo4L8eUJgWHbEqHuz4jm+L1FROiYkXU4zifpJpLtzS+a0RHT3wPbD89Wyl0b/FU1L8bb30NKx7w78+S2akYTbRVNUZsIk+7tpZmc+Y73hRT26I4Mr3/0FKpIO9qjXM3UPxtgvHq18Jh4r+0N2Qrx60Ku1gUvP5Hrid9MdJR0AbSHQIImTvTJIvDZhbzCe4cPFhb7jAsxVlDL4BK2ZMHFppZSEYYKGT5O3HbINWiBCbk8djz0JtYc4Q7gfNj+r65FKOJ2MSOqOayU6MArynMODT17U5o1+E/yg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f8VdXy/r7e1n9MIx6B5IIoYs9wOGKbd6iDNmwGK/NYpbw== 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: From: Shaun Tancheff memcg-v1 does not expose memory min, low, and high. These values should to be set to reasonable non-zero values when max is set. This patch sets them to 10%, 20% and 80% respective to max. This fixes an issue with memory pressure with file systems do an unbounded high rate of I/O hitting oom. Signed-off-by: Shaun Tancheff Nacked-by: Michal Hocko --- mm/memcontrol.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2eee092f8f11..0f5918d9dd2a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3491,6 +3491,15 @@ static int mem_cgroup_resize_max(struct mem_cgroup *memcg, if (max > counter->max) enlarge = true; ret = page_counter_set_max(counter, max); + if (!ret && !memsw) { + unsigned long min = (max / 10) + 1; + unsigned long low = min * 2; + unsigned long high = max - low; + + page_counter_set_min(counter, min); + page_counter_set_low(counter, low); + page_counter_set_high(counter, high); + } mutex_unlock(&memcg_max_mutex); if (!ret)