From patchwork Mon Sep 26 13:57:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12988720 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 CE514C32771 for ; Mon, 26 Sep 2022 13:57:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5725F8E0052; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FA628E0047; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34D738E0052; Mon, 26 Sep 2022 09:57:16 -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 26A3C8E0047 for ; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EE7EB140264 for ; Mon, 26 Sep 2022 13:57:15 +0000 (UTC) X-FDA: 79954388430.02.4B9D7A2 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf03.hostedemail.com (Postfix) with ESMTP id 9896520004 for ; Mon, 26 Sep 2022 13:57:14 +0000 (UTC) Received: by mail-qv1-f53.google.com with SMTP id g4so4351004qvo.3 for ; Mon, 26 Sep 2022 06:57:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=+6iJEmxp4bl9ohblP/ldB8IdtUPtHQigooDS1dl/Wc4=; b=etTRTh75O0L4i1MKIV2WPz590yQ569uvsT2rLsbPXxXGZXz2RBYFV5wchPr7zQK5tL oKGHX2usHRR86OnURr2MSY5OsLn+FPSGi0cWEjYbrBecrnPDlDdIsXtPuhTteUv6OR3a j1i0QT1+oNdpUtMM/f4xY4B9BSZJNunaqZhsqJn+WVGvKfDDTfgT/MCt1pQVZ+y3Ehma DketzHiCsnHYz+XZLjsvaxacOFveJcQ5rSZm/TZuvbXYyQtmkhekX4aNfwoyTdpAqF0J d0qnwZlfllTz+GnXoV8iFQtjUTzGkfeExjCA+2BCn5FZUQiquYNkxnmPLs4fEq73CRFc SvGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=+6iJEmxp4bl9ohblP/ldB8IdtUPtHQigooDS1dl/Wc4=; b=Hv4QohTyCZdRCFlCIlsRo5VWsxR1gzxAuVld6vEKbUE6h8mVLj9cHB/UUjLQE1BIo7 OIsSM44ZT0J2W8O+3SMKjtdrRD3DalXF9nP+RhkP0H9BlulFEYrEVLvBErGf4oU67uMR JVEJR7M3F26jlYLncYvtExEC84axhUUBp2Ekrd/d2zvOdCaD+viJTgR+RQ7v2Zs/VN9z 4UgXRg8TIpLpKbafZ+HZ428HB0/F5peVTCgeZ1IdA9gQYuP62jUPhmaaat+LPwggodH9 oc8gQeEBm6dkT0FHgjrziNt+w3JPYeWAqBCVTK8u61XfP2thhUcDH43fo0y/5S9oeKp8 bpNg== X-Gm-Message-State: ACrzQf3/TSPAxi+QMtdMyased3zo7TXsvNxwmN0D9967/0+APMhnBUch 9oZiteFljrSda4KZIegnVPbWPA== X-Google-Smtp-Source: AMsMyM5bOx93hkMCNRDGZm4BGsvx4b//fZgec4uv6OS22XlPPvI7A2qmMP0JLkBjQPe7FgcA5u1bqQ== X-Received: by 2002:a05:6214:27c6:b0:4ac:94f9:c727 with SMTP id ge6-20020a05621427c600b004ac94f9c727mr17339942qvb.51.1664200633825; Mon, 26 Sep 2022 06:57:13 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-9175-2920-760a-79fa.res6.spectrum.com. [2603:7000:c01:2716:9175:2920:760a:79fa]) by smtp.gmail.com with ESMTPSA id h7-20020ac85047000000b0035d0520db17sm10745315qtm.49.2022.09.26.06.57.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:57:13 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Shakeel Butt , Michal Hocko , Roman Gushchin , Hugh Dickins , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mm: memcontrol: don't allocate cgroup swap arrays when memcg is disabled Date: Mon, 26 Sep 2022 09:57:01 -0400 Message-Id: <20220926135704.400818-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926135704.400818-1-hannes@cmpxchg.org> References: <20220926135704.400818-1-hannes@cmpxchg.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664200634; 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:in-reply-to:references:references:dkim-signature; bh=+6iJEmxp4bl9ohblP/ldB8IdtUPtHQigooDS1dl/Wc4=; b=CPHdSTdOstEp16cglGkBtKGOc2O0ZaxdkP9EwjPCXJXmBri4JMfOTt54UA3S+LuD+Y7VhF 9aRpFw38lfx6wTUy+NE+j9nnWujx4BeHw75DdvY7O6iLzIFXccLwQhEBlWQgG6s0Bv4VvM rsu37sfguY4EHZSDYqmfBk1uWIlkr2Y= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=etTRTh75; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf03.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.53 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664200634; a=rsa-sha256; cv=none; b=MUnYDwlATiuklOFqstW2UbZ2QTcxcm77mO9nPa4lBdPHCGZ92Gb/39QWzOUV6Ymxk7/BCL Q9P6EwPK8J9SzJcICs0gyPAgKf6UEq4AzL5sI5jZyMKu3urXNmLAowpy+oRxhWS0hfXJ0E GBM1x7TlWMTQQcGXAhYWlUwvHrOM/r0= X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=etTRTh75; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf03.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.53 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 9896520004 X-Stat-Signature: uwggyhhm385d3cqxfpp3wwrymosgoqke X-HE-Tag: 1664200634-40827 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: Since commit 2d1c498072de ("mm: memcontrol: make swap tracking an integral part of memory control"), the cgroup swap arrays are used to track memory ownership at the time of swap readahead and swapoff, even if swap space *accounting* has been turned off by the user via swapaccount=0 (which sets cgroup_memory_noswap). However, the patch was overzealous: by simply dropping the cgroup_memory_noswap conditionals in the swapon, swapoff and uncharge path, it caused the cgroup arrays being allocated even when the memory controller as a whole is disabled. This is a waste of that memory. Restore mem_cgroup_disabled() checks, implied previously by cgroup_memory_noswap, in the swapon, swapoff, and swap_entry_free callbacks. Fixes: 2d1c498072de ("mm: memcontrol: make swap tracking an integral part of memory control") Reported-by: Hugh Dickins Signed-off-by: Johannes Weiner Reviewed-by: Shakeel Butt Acked-by: Hugh Dickins Acked-by: Michal Hocko --- mm/memcontrol.c | 3 +++ mm/swap_cgroup.c | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 6b74bbdc2659..9e3c010ca676 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7459,6 +7459,9 @@ void __mem_cgroup_uncharge_swap(swp_entry_t entry, unsigned int nr_pages) struct mem_cgroup *memcg; unsigned short id; + if (mem_cgroup_disabled()) + return; + id = swap_cgroup_record(entry, 0, nr_pages); rcu_read_lock(); memcg = mem_cgroup_from_id(id); diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c index 5a9442979a18..db6c4a26cf59 100644 --- a/mm/swap_cgroup.c +++ b/mm/swap_cgroup.c @@ -170,6 +170,9 @@ int swap_cgroup_swapon(int type, unsigned long max_pages) unsigned long length; struct swap_cgroup_ctrl *ctrl; + if (mem_cgroup_disabled()) + return 0; + length = DIV_ROUND_UP(max_pages, SC_PER_PAGE); array = vcalloc(length, sizeof(void *)); @@ -204,6 +207,9 @@ void swap_cgroup_swapoff(int type) unsigned long i, length; struct swap_cgroup_ctrl *ctrl; + if (mem_cgroup_disabled()) + return; + mutex_lock(&swap_cgroup_mutex); ctrl = &swap_cgroup_ctrl[type]; map = ctrl->map; From patchwork Mon Sep 26 13:57:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12988721 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 0A580C07E9D for ; Mon, 26 Sep 2022 13:57:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 991C78E0053; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 940888E0047; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76D828E0054; Mon, 26 Sep 2022 09:57:16 -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 66E498E0053 for ; Mon, 26 Sep 2022 09:57:16 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 46F7B1A01DB for ; Mon, 26 Sep 2022 13:57:16 +0000 (UTC) X-FDA: 79954388472.30.8D59B91 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by imf09.hostedemail.com (Postfix) with ESMTP id DD15E140013 for ; Mon, 26 Sep 2022 13:57:15 +0000 (UTC) Received: by mail-qv1-f44.google.com with SMTP id c6so4323399qvn.6 for ; Mon, 26 Sep 2022 06:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=HeJ4YaLZeye7K1WDyF1k6x7DVspo4c+vBec349uMCXA=; b=0d/wItGXbtug7zpturg/zxUG+IZarNXHxgNZ2X8AOYRuE9PfYFwwS5l6CL131XGwvT F22e4LAZG3MD/PUwEN6sr7Hw9S+5Apeqx+qfbFw+GDau4kqS3lvpdGgY7KuJRn9M1UNX puNO1MgLzrzXTx3MVyb9aIZlat2aM4gNqTkE+wAjMl1rgTbDL0vKg99D8WL8zytzSMcj 4ZlKV/xY9ZUNiuX0Q1ZadfGHe9gXSROaEQHpHK1V3wiKZqnHy/DLWNDSpW/HE/Vk0U+u +otTACZTiF+2iS//DQyG7gsLLmfOuSzIlyfQ2A4Zfohjsbr2RxOOaJ3JHrv3EgWTASFH B6SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=HeJ4YaLZeye7K1WDyF1k6x7DVspo4c+vBec349uMCXA=; b=XA3BlF041Tl6dbLlXeMfMdtimpAKF2loGM1XOyqKXW+fBBgwVUIl56xCQyI0pdNlpJ o9qozyqgq+2M02E+ax2+fS7tJXl9vsWtd4fuSYg9U3dYSJOOlnu0NHD+g9Q4G20DKzzo 5y2sAgq3lAGhO1EHCIqhEIDbRXssM/f76bdCsHZsMVMhVTJbsf/vUpeUOIkQ1LGYWPLN FyQPfeigFTAsi4RglUV3i02HDyJKJ56O9oHT0ChMIU5+plZfPBMh86MoYhvfHrk2PcDa D92TD5hL8pUpyo10grJW0oBIy3EdYj1tnWTM8XqwLChd7JFg+f4CXBIBCIejdDb82aaz l7mw== X-Gm-Message-State: ACrzQf3RRJPOVgekZh4RgeTxEnPwS9qrnloD3sti1h6lF1FGhUYNozEB YFLg2kZroHAwGLKfD3je2N72hQ== X-Google-Smtp-Source: AMsMyM6FFcCCA0OAWsPzQLrlbPjXWThgUurSXOP/ecbenkipkttwdl4PhN2O8Tv+RF7syCrQiz1dEA== X-Received: by 2002:a0c:abc8:0:b0:4ac:d471:7b83 with SMTP id k8-20020a0cabc8000000b004acd4717b83mr17310086qvb.102.1664200635053; Mon, 26 Sep 2022 06:57:15 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-9175-2920-760a-79fa.res6.spectrum.com. [2603:7000:c01:2716:9175:2920:760a:79fa]) by smtp.gmail.com with ESMTPSA id fg21-20020a05622a581500b00342f8d4d0basm10991554qtb.43.2022.09.26.06.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:57:14 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Shakeel Butt , Michal Hocko , Roman Gushchin , Hugh Dickins , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mm: memcontrol: deprecate swapaccounting=0 mode Date: Mon, 26 Sep 2022 09:57:02 -0400 Message-Id: <20220926135704.400818-3-hannes@cmpxchg.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926135704.400818-1-hannes@cmpxchg.org> References: <20220926135704.400818-1-hannes@cmpxchg.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664200635; 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:in-reply-to:references:references:dkim-signature; bh=HeJ4YaLZeye7K1WDyF1k6x7DVspo4c+vBec349uMCXA=; b=YSTkGqF8xbM+uNBGXv7IZsrMIXWJ4kmF93bOZIa5F6evmiEgZCBjsIiHHRaTINdIvsgTaI H1qrWW2m0uSHmhA37J7soZJyNuHGNQsEDpvQwZRzKdQQa8H+weP6a91nolYKBbcs5jEFHm wDmeWESFp92dVBnfjRvfa5U5SofsbYE= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="0d/wItGX"; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf09.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.44 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664200635; a=rsa-sha256; cv=none; b=P9ywrvGh3V0IpmzbIE6FBqjnor11fOwOw8N192LRApp30mr3SG66QhMwHEoZg6AecTQOYY PuK2/NauEZbwqkehfP5AsgcJfiTL9IR4EmZPvX87iPFL5KxYVYwD72EX95+eP17YnNs1fg IaxznUXoJWlbC3fAMnYQSYQb8x+EKtg= X-Rspam-User: X-Rspamd-Queue-Id: DD15E140013 X-Rspamd-Server: rspam01 X-Stat-Signature: jbt36ju75ortrhg3hnny1jupb6ea4upp Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b="0d/wItGX"; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf09.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.44 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-HE-Tag: 1664200635-973910 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 swapaccounting= commandline option already does very little today. To close a trivial containment failure case, the swap ownership tracking part of the swap controller has recently become mandatory (see commit 2d1c498072de ("mm: memcontrol: make swap tracking an integral part of memory control") for details), which makes up the majority of the work during swapout, swapin, and the swap slot map. The only thing left under this flag is the page_counter operations and the visibility of the swap control files in the first place, which are rather meager savings. There also aren't many scenarios, if any, where controlling the memory of a cgroup while allowing it unlimited access to a global swap space is a workable resource isolation strategy. On the other hand, there have been several bugs and confusion around the many possible swap controller states (cgroup1 vs cgroup2 behavior, memory accounting without swap accounting, memcg runtime disabled). This puts the maintenance overhead of retaining the toggle above its practical benefits. Deprecate it. Suggested-by: Shakeel Butt Signed-off-by: Johannes Weiner Reviewed-by: Shakeel Butt --- .../admin-guide/kernel-parameters.txt | 6 --- mm/memcontrol.c | 50 ++++--------------- 2 files changed, 10 insertions(+), 46 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 3b95f65bafe2..99a13f2be2ef 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6036,12 +6036,6 @@ This parameter controls use of the Protected Execution Facility on pSeries. - swapaccount= [KNL] - Format: [0|1] - Enable accounting of swap in memory resource - controller if no parameter or 1 is given or disable - it if 0 is given (See Documentation/admin-guide/cgroup-v1/memory.rst) - swiotlb= [ARM,IA-64,PPC,MIPS,X86] Format: { [,] | force | noforce } -- Number of I/O TLB slabs diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9e3c010ca676..4be1b48b9659 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -88,22 +88,6 @@ static bool cgroup_memory_nosocket __ro_after_init; /* Kernel memory accounting disabled? */ static bool cgroup_memory_nokmem __ro_after_init; -/* Whether the swap controller is active */ -#ifdef CONFIG_MEMCG_SWAP -static bool cgroup_memory_noswap __initdata; - -static DEFINE_STATIC_KEY_FALSE(memcg_swap_enabled_key); -static inline bool memcg_swap_enabled(void) -{ - return static_branch_likely(&memcg_swap_enabled_key); -} -#else -static inline bool memcg_swap_enabled(void) -{ - return false; -} -#endif - #ifdef CONFIG_CGROUP_WRITEBACK static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq); #endif @@ -111,7 +95,7 @@ static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq); /* Whether legacy memory+swap accounting is active */ static bool do_memsw_account(void) { - return !cgroup_subsys_on_dfl(memory_cgrp_subsys) && memcg_swap_enabled(); + return !cgroup_subsys_on_dfl(memory_cgrp_subsys); } #define THRESHOLDS_EVENTS_TARGET 128 @@ -7379,7 +7363,7 @@ void mem_cgroup_swapout(struct folio *folio, swp_entry_t entry) if (!mem_cgroup_is_root(memcg)) page_counter_uncharge(&memcg->memory, nr_entries); - if (memcg_swap_enabled() && memcg != swap_memcg) { + if (memcg != swap_memcg) { if (!mem_cgroup_is_root(swap_memcg)) page_counter_charge(&swap_memcg->memsw, nr_entries); page_counter_uncharge(&memcg->memsw, nr_entries); @@ -7431,7 +7415,7 @@ int __mem_cgroup_try_charge_swap(struct folio *folio, swp_entry_t entry) memcg = mem_cgroup_id_get_online(memcg); - if (memcg_swap_enabled() && !mem_cgroup_is_root(memcg) && + if (!mem_cgroup_is_root(memcg) && !page_counter_try_charge(&memcg->swap, nr_pages, &counter)) { memcg_memory_event(memcg, MEMCG_SWAP_MAX); memcg_memory_event(memcg, MEMCG_SWAP_FAIL); @@ -7466,7 +7450,7 @@ void __mem_cgroup_uncharge_swap(swp_entry_t entry, unsigned int nr_pages) rcu_read_lock(); memcg = mem_cgroup_from_id(id); if (memcg) { - if (memcg_swap_enabled() && !mem_cgroup_is_root(memcg)) { + if (!mem_cgroup_is_root(memcg)) { if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) page_counter_uncharge(&memcg->swap, nr_pages); else @@ -7482,7 +7466,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup *memcg) { long nr_swap_pages = get_nr_swap_pages(); - if (!memcg_swap_enabled() || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (mem_cgroup_disabled() || do_memsw_account()) return nr_swap_pages; for (; memcg != root_mem_cgroup; memcg = parent_mem_cgroup(memcg)) nr_swap_pages = min_t(long, nr_swap_pages, @@ -7499,7 +7483,7 @@ bool mem_cgroup_swap_full(struct folio *folio) if (vm_swap_full()) return true; - if (!memcg_swap_enabled() || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (do_memsw_account()) return false; memcg = folio_memcg(folio); @@ -7519,10 +7503,9 @@ bool mem_cgroup_swap_full(struct folio *folio) static int __init setup_swap_account(char *s) { - bool res; - - if (!kstrtobool(s, &res)) - cgroup_memory_noswap = !res; + pr_warn_once("The swapaccount= commandline option is deprecated. " + "Please report your usecase to linux-mm@kvack.org if you " + "depend on this functionality.\n"); return 1; } __setup("swapaccount=", setup_swap_account); @@ -7791,24 +7774,11 @@ static struct cftype zswap_files[] = { }; #endif /* CONFIG_MEMCG_KMEM && CONFIG_ZSWAP */ -/* - * If mem_cgroup_swap_init() is implemented as a subsys_initcall() - * instead of a core_initcall(), this could mean cgroup_memory_noswap still - * remains set to false even when memcg is disabled via "cgroup_disable=memory" - * boot parameter. This may result in premature OOPS inside - * mem_cgroup_get_nr_swap_pages() function in corner cases. - */ static int __init mem_cgroup_swap_init(void) { - /* No memory control -> no swap control */ if (mem_cgroup_disabled()) - cgroup_memory_noswap = true; - - if (cgroup_memory_noswap) return 0; - static_branch_enable(&memcg_swap_enabled_key); - WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files)); WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, memsw_files)); #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_ZSWAP) @@ -7816,6 +7786,6 @@ static int __init mem_cgroup_swap_init(void) #endif return 0; } -core_initcall(mem_cgroup_swap_init); +subsys_initcall(mem_cgroup_swap_init); #endif /* CONFIG_MEMCG_SWAP */ From patchwork Mon Sep 26 13:57:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12988722 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 79CDAC6FA83 for ; Mon, 26 Sep 2022 13:57:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDC058E0054; Mon, 26 Sep 2022 09:57:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3DE98E0047; Mon, 26 Sep 2022 09:57:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 941B88E0054; Mon, 26 Sep 2022 09:57:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 865C58E0047 for ; Mon, 26 Sep 2022 09:57:17 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6170F12048D for ; Mon, 26 Sep 2022 13:57:17 +0000 (UTC) X-FDA: 79954388514.04.5E3D6DD Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by imf16.hostedemail.com (Postfix) with ESMTP id 1697218000A for ; Mon, 26 Sep 2022 13:57:16 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id i3so4112063qkl.3 for ; Mon, 26 Sep 2022 06:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nxWlvz8nHKxF79bLiRXoWvFCmNni5yV7mxHmCxzwA1c=; b=Pm8S7GcSFRJWTzik7LhbfogyC+//ZqsABilFvcQgI1rbJfqhpFRdanL1+GHXzprwnB rX2IGIitEbL0wUDSi9cTNbod47SaPSyBy1s2M/5H5oBEUnarJed+X2kV8S+NiGjcxDM2 vyiCvtjy2NTBluE9HJcH16mhvyA2bKbIXJVu1otPRo9tqdUIPRMnydMZ/oIzuoWf11ut +nM6kLfw8XCbjB5tY3+nupim51GjwAgoM6PbDihvDKfLcwrDvb6/cuOqvgB8YzwSaOsa psRi+d0w+GC+hRxyaO6MjNfx63poKtPW1lqwUQp53OOsA/8Eh8fpODIaU+m2krXZThHf NCJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=nxWlvz8nHKxF79bLiRXoWvFCmNni5yV7mxHmCxzwA1c=; b=RaJHhqiZG61j9dVbBRWuxGBpQi8CJ+BbX10nZ3qUnbVXgQQ0mTiJ4Grl1LPnEl4Ce7 HJwv4y+550YWJrMw1Ytxjs8z9VpqSIcWFL1r2lp1ql+ca32ZFhRpXWIGAv5eBUXxQzms Rm038EqZsHYicHem5cwueV7uNXQRukEMe+hNHXZ6nq783jECiMgDMRpByiwcWVSzJFqR HViYNY1kCC5QS+bT7JJ0ls9d2X6dcq7fqRFMK0KQx3SL9qaEzklax+YHInmYWCSW6cce ZhjkAoLDsLYwpvNN0bh6Cz/y0KdzHqYckXGWI4vkNqd+Yfdb0z55ZdFn09ul1oYb8CTq qPxg== X-Gm-Message-State: ACrzQf1NNR8wtQ5O4/c0E0RI+nwP4WW+KWyGKNA7w7xEC/x8R6PO0trm 6T0tyO9/OS8bh/qAeUk0xFGpNA== X-Google-Smtp-Source: AMsMyM5O56YPOTRdHT3lUuv+iV2e4l+65dldttI4qaDrt0US4VeJH9VyMv8TwUNBtUP9qPXPOLlhbA== X-Received: by 2002:a05:620a:1b9b:b0:6cf:3c66:8e47 with SMTP id dv27-20020a05620a1b9b00b006cf3c668e47mr14337449qkb.478.1664200636452; Mon, 26 Sep 2022 06:57:16 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-9175-2920-760a-79fa.res6.spectrum.com. [2603:7000:c01:2716:9175:2920:760a:79fa]) by smtp.gmail.com with ESMTPSA id k15-20020a05620a0b8f00b006cf3592cc20sm10804639qkh.55.2022.09.26.06.57.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:57:16 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Shakeel Butt , Michal Hocko , Roman Gushchin , Hugh Dickins , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mm: memcontrol: use do_memsw_account() in a few more places Date: Mon, 26 Sep 2022 09:57:03 -0400 Message-Id: <20220926135704.400818-4-hannes@cmpxchg.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926135704.400818-1-hannes@cmpxchg.org> References: <20220926135704.400818-1-hannes@cmpxchg.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664200637; 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:in-reply-to:references:references:dkim-signature; bh=nxWlvz8nHKxF79bLiRXoWvFCmNni5yV7mxHmCxzwA1c=; b=pexBpqd94Yi5EYV8S0eRTgqfgdAaOSXZYgOzXhMPzkskzaO4RalE+22CXmpjj7vUtwSVoJ oCdWsls/Mj3Odd3wDYxObOm1Fs9jSm6OJpMG3Esce11YcpCdEEkdqeo7LN3bxgYddyqrtw O0u2uS49Qcd2nRencWpw9hcyP+gMiUA= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=Pm8S7GcS; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf16.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664200637; a=rsa-sha256; cv=none; b=Qhg43knEqTtPYwTLhKU57csaajhG1KvgVmcVwwjDmBgac64CI7FDBA7SqI/TQfCcKxf156 Gu57vjFjpMcODWGrdZVShDMSQN9dXJQqwozW5niLh8GyQ5Izb3dqhQTwRfG8N+hchyi37A X8T3+IRcW0ynSjuqr01BSBz/15+T/m0= X-Rspam-User: Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=Pm8S7GcS; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf16.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.222.176 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1697218000A X-Stat-Signature: zfmjxztmzjftt3cff7ou7pm76sag3155 X-HE-Tag: 1664200636-575640 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: It's slightly more descriptive and consistent with other places that distinguish cgroup1's combined memory+swap accounting scheme from cgroup2's dedicated swap accounting. Signed-off-by: Johannes Weiner Acked-by: Shakeel Butt --- mm/memcontrol.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4be1b48b9659..76bb0a18a2f3 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1667,17 +1667,17 @@ unsigned long mem_cgroup_get_max(struct mem_cgroup *memcg) { unsigned long max = READ_ONCE(memcg->memory.max); - if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) { - if (mem_cgroup_swappiness(memcg)) - max += min(READ_ONCE(memcg->swap.max), - (unsigned long)total_swap_pages); - } else { /* v1 */ + if (do_memsw_account()) { if (mem_cgroup_swappiness(memcg)) { /* Calculate swap excess capacity from memsw limit */ unsigned long swap = READ_ONCE(memcg->memsw.max) - max; max += min(swap, (unsigned long)total_swap_pages); } + } else { + if (mem_cgroup_swappiness(memcg)) + max += min(READ_ONCE(memcg->swap.max), + (unsigned long)total_swap_pages); } return max; } @@ -7334,7 +7334,7 @@ void mem_cgroup_swapout(struct folio *folio, swp_entry_t entry) if (mem_cgroup_disabled()) return; - if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (!do_memsw_account()) return; memcg = folio_memcg(folio); @@ -7399,7 +7399,7 @@ int __mem_cgroup_try_charge_swap(struct folio *folio, swp_entry_t entry) struct mem_cgroup *memcg; unsigned short oldid; - if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (do_memsw_account()) return 0; memcg = folio_memcg(folio); @@ -7451,10 +7451,10 @@ void __mem_cgroup_uncharge_swap(swp_entry_t entry, unsigned int nr_pages) memcg = mem_cgroup_from_id(id); if (memcg) { if (!mem_cgroup_is_root(memcg)) { - if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) - page_counter_uncharge(&memcg->swap, nr_pages); - else + if (do_memsw_account()) page_counter_uncharge(&memcg->memsw, nr_pages); + else + page_counter_uncharge(&memcg->swap, nr_pages); } mod_memcg_state(memcg, MEMCG_SWAP, -nr_pages); mem_cgroup_id_put_many(memcg, nr_pages); From patchwork Mon Sep 26 13:57:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Weiner X-Patchwork-Id: 12988723 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 569F2C32771 for ; Mon, 26 Sep 2022 13:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 68FDE8E0055; Mon, 26 Sep 2022 09:57:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60E768E0047; Mon, 26 Sep 2022 09:57:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3EA868E0055; Mon, 26 Sep 2022 09:57:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2F9838E0047 for ; Mon, 26 Sep 2022 09:57:19 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 08B91C09D9 for ; Mon, 26 Sep 2022 13:57:19 +0000 (UTC) X-FDA: 79954388598.30.16F9C97 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by imf20.hostedemail.com (Postfix) with ESMTP id 9025C1C0019 for ; Mon, 26 Sep 2022 13:57:18 +0000 (UTC) Received: by mail-qt1-f172.google.com with SMTP id g12so4126609qts.1 for ; Mon, 26 Sep 2022 06:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=X0S0bdsMSZwjlbQsv+GYht3cMFqf9TlaOrFi2tt0ZUE=; b=ivgKMYEx6KKFhpp8wNE19iM09oj8t0G7ajjdlApXiV8dHxl6sdRPZlL3sNkFlSDNwy rnXLGG7lYYJAxGKw1r/ekzCIehnIVG05fD84xOZnCYJ98uQr0VSqu4gi3uFUuh/7uMYt odr+evVu3To0Y90IeM8RLSdC8kXkAJV9dsY3cmFWEcyVPtDrJuPsRKaLmE6gFZ28BSIc ovC/udwIpbLSyiJdrqlUZu9ncSBsbrTC2ca1wRvfr87LNGa+OY4lP8zmbXErXnQCfk08 t9y3dA2dkaXRSH3P2RHybF9daxj+aOSeam6tQeY7J+TPfzO+K56S2MduhvUdrFpDD51K xVsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=X0S0bdsMSZwjlbQsv+GYht3cMFqf9TlaOrFi2tt0ZUE=; b=to4AqoEfWMVcuspYlnEGQcwS4aCeIjbvgubxW91qoU/Gc1B0OfZCjLZPmFF6h34jRW ZHvFRTvefb9d6Aq3YS2LmDHUER3jzAtWB/dSrq+m61pXEAkStwrqEUKWh/xZsWAD5xpA wtDJCRNPPQl1DsHBJYmQTP+FJu41ZVCQZNIgLRBKz8K9V8bmmJByOoLpKtCvCMHgLyjQ gjiwC61B2WBXJh7+uLLLSz1YsI8BfMZVmP/fMeOVFRiBAKGoubno6quYeW2FYFEfLqgo 3p26qqd6DVwyWX4t3dHpSA23Pa44uactgGKuhynBX+3Y3pZcS0ojSy3N7DRF9rcrn/kx w2gA== X-Gm-Message-State: ACrzQf2kHXN/lUyjbQcSxct/nzy65cvtNRss7rSjikZNGBDUNqKNKUfG nHLAPwwUvuhoTztzbFJkc2cXeg== X-Google-Smtp-Source: AMsMyM7Ul5O43S3u/fkDoFtmHr+YA4o1q3LjljR0Uy16ObfFPlUp15Qpp7LaXeGU4Il4nCoBD2Oe0A== X-Received: by 2002:ac8:7d4c:0:b0:35c:c979:dc17 with SMTP id h12-20020ac87d4c000000b0035cc979dc17mr18455434qtb.271.1664200637789; Mon, 26 Sep 2022 06:57:17 -0700 (PDT) Received: from localhost (2603-7000-0c01-2716-9175-2920-760a-79fa.res6.spectrum.com. [2603:7000:c01:2716:9175:2920:760a:79fa]) by smtp.gmail.com with ESMTPSA id az35-20020a05620a172300b0069fe1dfbeffsm11925212qkb.92.2022.09.26.06.57.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Sep 2022 06:57:17 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Shakeel Butt , Michal Hocko , Roman Gushchin , Hugh Dickins , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mm: memcontrol: drop dead CONFIG_MEMCG_SWAP config symbol Date: Mon, 26 Sep 2022 09:57:04 -0400 Message-Id: <20220926135704.400818-5-hannes@cmpxchg.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926135704.400818-1-hannes@cmpxchg.org> References: <20220926135704.400818-1-hannes@cmpxchg.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664200638; 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:in-reply-to:references:references:dkim-signature; bh=X0S0bdsMSZwjlbQsv+GYht3cMFqf9TlaOrFi2tt0ZUE=; b=6B3k9nomKiEuo0o3PVYt3uISGupCIfyUesa/1xdBcUcx7QOh5h+cPHXfNTIaQgsoR1KYp0 /fiMRqXPHNwJstpYMcCPZ3PqDoSVxMoGNNVmaHmtuCQuSmm5tEto75liuhfcpPXU5thZ5f BDWvR+R5e5xHfS/782jDDjjuefRn/FI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=ivgKMYEx; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf20.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.172 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664200638; a=rsa-sha256; cv=none; b=SysR5f72ZcDHdqRnWEAsVQfUYJTbAsJs+Y1b5TbJ34zSzG4HlO8Qen6LFZZ/UA6Y+cq26o nIw7GyFiVzJZa1x6YiB92RQxzxLst0okB+LRxNytLtQFhci+ws7Vut2Wv0QO03/S2T2r1N OlEKVUmOhEmEjglnIcrG1mWiozaF4nk= X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=ivgKMYEx; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf20.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.172 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 9025C1C0019 X-Stat-Signature: 6q4k43hefbfb41fdgxa9cpbuk9hay3zf X-HE-Tag: 1664200638-507316 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: Since 2d1c498072de ("mm: memcontrol: make swap tracking an integral part of memory control"), CONFIG_MEMCG_SWAP hasn't been a user-visible config option anymore, it just means CONFIG_MEMCG && CONFIG_SWAP. Update the sites accordingly and drop the symbol. [ While touching the docs, remove two references to CONFIG_MEMCG_KMEM, which hasn't been a user-visible symbol for over half a decade. ] Signed-off-by: Johannes Weiner Acked-by: Shakeel Butt --- Documentation/admin-guide/cgroup-v1/memory.rst | 4 +--- arch/mips/configs/db1xxx_defconfig | 1 - arch/mips/configs/generic_defconfig | 1 - arch/powerpc/configs/powernv_defconfig | 1 - arch/powerpc/configs/pseries_defconfig | 1 - arch/sh/configs/sdk7786_defconfig | 1 - arch/sh/configs/urquell_defconfig | 1 - include/linux/swap.h | 2 +- include/linux/swap_cgroup.h | 4 ++-- init/Kconfig | 5 ----- mm/Makefile | 4 +++- mm/memcontrol.c | 6 +++--- tools/testing/selftests/cgroup/config | 1 - 13 files changed, 10 insertions(+), 22 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index 2cc502a75ef6..5b86245450bd 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -299,7 +299,7 @@ Per-node-per-memcgroup LRU (cgroup's private LRU) is guarded by lruvec->lru_lock; PG_lru bit of page->flags is cleared before isolating a page from its LRU under lruvec->lru_lock. -2.7 Kernel Memory Extension (CONFIG_MEMCG_KMEM) +2.7 Kernel Memory Extension ----------------------------------------------- With the Kernel memory extension, the Memory Controller is able to limit @@ -386,8 +386,6 @@ limit, and "K" the kernel limit. There are three possible ways limits can be a. Enable CONFIG_CGROUPS b. Enable CONFIG_MEMCG -c. Enable CONFIG_MEMCG_SWAP (to use swap extension) -d. Enable CONFIG_MEMCG_KMEM (to use kmem extension) 3.1. Prepare the cgroups (see cgroups.txt, Why are cgroups needed?) ------------------------------------------------------------------- diff --git a/arch/mips/configs/db1xxx_defconfig b/arch/mips/configs/db1xxx_defconfig index b8bd66300996..83cbdecb27e6 100644 --- a/arch/mips/configs/db1xxx_defconfig +++ b/arch/mips/configs/db1xxx_defconfig @@ -9,7 +9,6 @@ CONFIG_HIGH_RES_TIMERS=y CONFIG_LOG_BUF_SHIFT=16 CONFIG_CGROUPS=y CONFIG_MEMCG=y -CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y CONFIG_CGROUP_SCHED=y CONFIG_CFS_BANDWIDTH=y diff --git a/arch/mips/configs/generic_defconfig b/arch/mips/configs/generic_defconfig index 714169e411cf..48e4e251779b 100644 --- a/arch/mips/configs/generic_defconfig +++ b/arch/mips/configs/generic_defconfig @@ -3,7 +3,6 @@ CONFIG_NO_HZ_IDLE=y CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y CONFIG_MEMCG=y -CONFIG_MEMCG_SWAP=y CONFIG_BLK_CGROUP=y CONFIG_CFS_BANDWIDTH=y CONFIG_RT_GROUP_SCHED=y diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig index 49f49c263935..4acca5263404 100644 --- a/arch/powerpc/configs/powernv_defconfig +++ b/arch/powerpc/configs/powernv_defconfig @@ -17,7 +17,6 @@ CONFIG_LOG_CPU_MAX_BUF_SHIFT=13 CONFIG_NUMA_BALANCING=y CONFIG_CGROUPS=y CONFIG_MEMCG=y -CONFIG_MEMCG_SWAP=y CONFIG_CGROUP_SCHED=y CONFIG_CGROUP_FREEZER=y CONFIG_CPUSETS=y diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig index b571d084c148..fead14ebb1fc 100644 --- a/arch/powerpc/configs/pseries_defconfig +++ b/arch/powerpc/configs/pseries_defconfig @@ -16,7 +16,6 @@ CONFIG_LOG_CPU_MAX_BUF_SHIFT=13 CONFIG_NUMA_BALANCING=y CONFIG_CGROUPS=y CONFIG_MEMCG=y -CONFIG_MEMCG_SWAP=y CONFIG_CGROUP_SCHED=y CONFIG_CGROUP_FREEZER=y CONFIG_CPUSETS=y diff --git a/arch/sh/configs/sdk7786_defconfig b/arch/sh/configs/sdk7786_defconfig index a8662b6927ec..97b7356639ed 100644 --- a/arch/sh/configs/sdk7786_defconfig +++ b/arch/sh/configs/sdk7786_defconfig @@ -16,7 +16,6 @@ CONFIG_CPUSETS=y # CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y -CONFIG_CGROUP_MEMCG_SWAP=y CONFIG_CGROUP_SCHED=y CONFIG_RT_GROUP_SCHED=y CONFIG_BLK_CGROUP=y diff --git a/arch/sh/configs/urquell_defconfig b/arch/sh/configs/urquell_defconfig index cb2f56468fe0..be478f3148f2 100644 --- a/arch/sh/configs/urquell_defconfig +++ b/arch/sh/configs/urquell_defconfig @@ -14,7 +14,6 @@ CONFIG_CPUSETS=y # CONFIG_PROC_PID_CPUSET is not set CONFIG_CGROUP_CPUACCT=y CONFIG_CGROUP_MEMCG=y -CONFIG_CGROUP_MEMCG_SWAP=y CONFIG_CGROUP_SCHED=y CONFIG_RT_GROUP_SCHED=y CONFIG_BLK_DEV_INITRD=y diff --git a/include/linux/swap.h b/include/linux/swap.h index fc8d98660326..a18cf4b7c724 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -666,7 +666,7 @@ static inline void folio_throttle_swaprate(struct folio *folio, gfp_t gfp) cgroup_throttle_swaprate(&folio->page, gfp); } -#ifdef CONFIG_MEMCG_SWAP +#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP) void mem_cgroup_swapout(struct folio *folio, swp_entry_t entry); int __mem_cgroup_try_charge_swap(struct folio *folio, swp_entry_t entry); static inline int mem_cgroup_try_charge_swap(struct folio *folio, diff --git a/include/linux/swap_cgroup.h b/include/linux/swap_cgroup.h index a12dd1c3966c..ae73a87775b3 100644 --- a/include/linux/swap_cgroup.h +++ b/include/linux/swap_cgroup.h @@ -4,7 +4,7 @@ #include -#ifdef CONFIG_MEMCG_SWAP +#if defined(CONFIG_MEMCG) && defined(CONFIG_SWAP) extern unsigned short swap_cgroup_cmpxchg(swp_entry_t ent, unsigned short old, unsigned short new); @@ -40,6 +40,6 @@ static inline void swap_cgroup_swapoff(int type) return; } -#endif /* CONFIG_MEMCG_SWAP */ +#endif #endif /* __LINUX_SWAP_CGROUP_H */ diff --git a/init/Kconfig b/init/Kconfig index 532362fcfe31..7d86cf6b3012 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -958,11 +958,6 @@ config MEMCG help Provides control over the memory footprint of tasks in a cgroup. -config MEMCG_SWAP - bool - depends on MEMCG && SWAP - default y - config MEMCG_KMEM bool depends on MEMCG && !SLOB diff --git a/mm/Makefile b/mm/Makefile index cc23b0052584..8e105e5b3e29 100644 --- a/mm/Makefile +++ b/mm/Makefile @@ -98,7 +98,9 @@ obj-$(CONFIG_DEVICE_MIGRATION) += migrate_device.o obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += huge_memory.o khugepaged.o obj-$(CONFIG_PAGE_COUNTER) += page_counter.o obj-$(CONFIG_MEMCG) += memcontrol.o vmpressure.o -obj-$(CONFIG_MEMCG_SWAP) += swap_cgroup.o +ifdef CONFIG_SWAP +obj-$(CONFIG_MEMCG) += swap_cgroup.o +endif obj-$(CONFIG_CGROUP_HUGETLB) += hugetlb_cgroup.o obj-$(CONFIG_GUP_TEST) += gup_test.o obj-$(CONFIG_MEMORY_FAILURE) += memory-failure.o diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 76bb0a18a2f3..61e05fc281fb 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3423,7 +3423,7 @@ void split_page_memcg(struct page *head, unsigned int nr) css_get_many(&memcg->css, nr - 1); } -#ifdef CONFIG_MEMCG_SWAP +#ifdef CONFIG_SWAP /** * mem_cgroup_move_swap_account - move swap charge and swap_cgroup's record. * @entry: swap entry to be moved @@ -7296,7 +7296,7 @@ static int __init mem_cgroup_init(void) } subsys_initcall(mem_cgroup_init); -#ifdef CONFIG_MEMCG_SWAP +#ifdef CONFIG_SWAP static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) { while (!refcount_inc_not_zero(&memcg->id.ref)) { @@ -7788,4 +7788,4 @@ static int __init mem_cgroup_swap_init(void) } subsys_initcall(mem_cgroup_swap_init); -#endif /* CONFIG_MEMCG_SWAP */ +#endif /* CONFIG_SWAP */ diff --git a/tools/testing/selftests/cgroup/config b/tools/testing/selftests/cgroup/config index 84fe884fad86..97d549ee894f 100644 --- a/tools/testing/selftests/cgroup/config +++ b/tools/testing/selftests/cgroup/config @@ -4,5 +4,4 @@ CONFIG_CGROUP_FREEZER=y CONFIG_CGROUP_SCHED=y CONFIG_MEMCG=y CONFIG_MEMCG_KMEM=y -CONFIG_MEMCG_SWAP=y CONFIG_PAGE_COUNTER=y