From patchwork Wed Nov 18 17:57:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 11915527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02ADAC6369E for ; Wed, 18 Nov 2020 17:57:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D0BA246DD for ; Wed, 18 Nov 2020 17:57:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="OGRSdH36" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D0BA246DD Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A8B26B0092; Wed, 18 Nov 2020 12:57:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 25B026B0098; Wed, 18 Nov 2020 12:57:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D3FF6B0099; Wed, 18 Nov 2020 12:57:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id D48936B0092 for ; Wed, 18 Nov 2020 12:57:31 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 60CDB3632 for ; Wed, 18 Nov 2020 17:57:31 +0000 (UTC) X-FDA: 77498296302.15.thing48_1c132012733c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 407541814B0C8 for ; Wed, 18 Nov 2020 17:57:31 +0000 (UTC) X-HE-Tag: thing48_1c132012733c X-Filterd-Recvd-Size: 6501 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 18 Nov 2020 17:57:30 +0000 (UTC) Received: by mail-pl1-f202.google.com with SMTP id x11so1639714plv.7 for ; Wed, 18 Nov 2020 09:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=bsCN5N4JAInCrP+YslG6n3+5vM/Uc6NYHq4aIGZzdzI=; b=OGRSdH36h0ql+bIlfx/9tGobraLomjaMP/OGf7xW5gcwYX/S+wGFedmGUIuhxC0LSR hKh+6e2I/P/ivkmCMV69IPmrpjif2Ee1Qbd4bBoJSwf3dYAbZJYnAgcn0UOQks0sDsu0 c4u4eFtfKg3wDQU/FXPU3e2Ai8Hn4c45tOv5CGexd5fJRohaQe0eZDQy5PhSlMm25KvC /LszuxocTrAvMgTq6qnAaJN4zBeBR9svkTdmnf+Qf21ndZE5kmVEd0mhclsv3+swrjB9 BXkn/ihkNkSyShamgRdPhCvShPte1OaDz9gILzY6uLxXnU/qrb0SyR3Z+ZV6pRVFItSK lIMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=bsCN5N4JAInCrP+YslG6n3+5vM/Uc6NYHq4aIGZzdzI=; b=uRKiR0nWvG9PKQPJTQKTIKi//4IIgYKMeTvsGyrjqS+bWaRi9z1kKjiYGJnld6ZWAp uBPdb0WXaTanzWR3RpK1tKmZM0l9BBftsMm/JsS5KqKJdgjjoA6m+Rl6ga8bSZNSNBZB hFYA8MmyXDI3IDvHsPcW7G3TPXkLo5kywSaMLmx2KYGtVlA5vwtnserwd9gZnrKVeL1G f+qzoKnm8UiPZJbN/2o/CQsfC3wybCpAOg/2gSUUs3tNPyiyiX9LzENjVgTzlxAUgMNb AtjWw0o8kuHweVU/3P7Sb0Eto1gGr7vVTz77RLkUG2yV+V2p8asrpBxy9h5FGr8shUBl 9DNA== X-Gm-Message-State: AOAM5312LA1xJymFAP/uVuH+4dM18kO1aeBQD5o/2QUwKiF01OZAgzAB kNugXUk7Lhuw/CA5G+HuQHnv4ajH6KSyyw== X-Google-Smtp-Source: ABdhPJx00ige9yBV83xg5Lg2I5cK9a2WIVrg3dF4PjKIbJbAgldyXx0PiGCaJRFgGCNymksPSdS/KbohifO0IA== X-Received: from shakeelb.svl.corp.google.com ([100.116.77.44]) (user=shakeelb job=sendgmr) by 2002:a17:90a:f0c7:: with SMTP id fa7mr235213pjb.3.1605722249509; Wed, 18 Nov 2020 09:57:29 -0800 (PST) Date: Wed, 18 Nov 2020 09:57:26 -0800 Message-Id: <20201118175726.2453120-1-shakeelb@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH] memcg, kmem: further deprecate kmem.limit_in_bytes From: Shakeel Butt To: Roman Gushchin , Johannes Weiner , Michal Hocko Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt 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: The deprecation process of kmem.limit_in_bytes started with the commit 0158115f702 ("memcg, kmem: deprecate kmem.limit_in_bytes") which also explains in detail the motivation behind the deprecation. To summarize, it is the unexpected behavior on hitting the kmem limit. This patch moves the deprecation process to the next stage by disallowing to set the kmem limit. In future we might just remove the kmem.limit_in_bytes file completely. Signed-off-by: Shakeel Butt Acked-by: Roman Gushchin Acked-by: Michal Hocko --- .../admin-guide/cgroup-v1/memory.rst | 6 ++-- mm/memcontrol.c | 35 +++---------------- 2 files changed, 6 insertions(+), 35 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index 52688ae34461..cb993d80194d 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -87,10 +87,8 @@ Brief summary of control files. memory.oom_control set/show oom controls. memory.numa_stat show the number of memory usage per numa node - memory.kmem.limit_in_bytes set/show hard limit for kernel memory - This knob is deprecated and shouldn't be - used. It is planned that this be removed in - the foreseeable future. + memory.kmem.limit_in_bytes This knob is deprecated and writing to + it will return -EINVAL. memory.kmem.usage_in_bytes show current kernel memory allocation memory.kmem.failcnt show the number of kernel memory usage hits limits diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 45465c03a8d7..78d17b3181ad 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3075,28 +3075,14 @@ static void memcg_free_cache_id(int id) int __memcg_kmem_charge(struct mem_cgroup *memcg, gfp_t gfp, unsigned int nr_pages) { - struct page_counter *counter; int ret; ret = try_charge(memcg, gfp, nr_pages); if (ret) return ret; - if (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && - !page_counter_try_charge(&memcg->kmem, nr_pages, &counter)) { - - /* - * Enforce __GFP_NOFAIL allocation because callers are not - * prepared to see failures and likely do not have any failure - * handling code. - */ - if (gfp & __GFP_NOFAIL) { - page_counter_charge(&memcg->kmem, nr_pages); - return 0; - } - cancel_charge(memcg, nr_pages); - return -ENOMEM; - } + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) + page_counter_charge(&memcg->kmem, nr_pages); return 0; } @@ -3769,17 +3755,6 @@ static void memcg_free_kmem(struct mem_cgroup *memcg) } #endif /* CONFIG_MEMCG_KMEM */ -static int memcg_update_kmem_max(struct mem_cgroup *memcg, - unsigned long max) -{ - int ret; - - mutex_lock(&memcg_max_mutex); - ret = page_counter_set_max(&memcg->kmem, max); - mutex_unlock(&memcg_max_mutex); - return ret; -} - static int memcg_update_tcp_max(struct mem_cgroup *memcg, unsigned long max) { int ret; @@ -3845,10 +3820,8 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of, ret = mem_cgroup_resize_max(memcg, nr_pages, true); break; case _KMEM: - pr_warn_once("kmem.limit_in_bytes is deprecated and will be removed. " - "Please report your usecase to linux-mm@kvack.org if you " - "depend on this functionality.\n"); - ret = memcg_update_kmem_max(memcg, nr_pages); + /* kmem.limit_in_bytes is deprecated. */ + ret = -EINVAL; break; case _TCP: ret = memcg_update_tcp_max(memcg, nr_pages);