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 X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 43A3DC433E0 for ; Fri, 19 Mar 2021 05:49:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8C6E064F33 for ; Fri, 19 Mar 2021 05:49:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C6E064F33 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DECAD6B0072; Fri, 19 Mar 2021 01:49:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D9D258D0005; Fri, 19 Mar 2021 01:49:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9FA48D0003; Fri, 19 Mar 2021 01:49:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0097.hostedemail.com [216.40.44.97]) by kanga.kvack.org (Postfix) with ESMTP id 902B46B0072 for ; Fri, 19 Mar 2021 01:49:48 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3EFF64DBC for ; Fri, 19 Mar 2021 05:49:48 +0000 (UTC) X-FDA: 77935547214.10.24E359A Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) by imf03.hostedemail.com (Postfix) with ESMTP id 96799C0007C0 for ; Fri, 19 Mar 2021 05:49:47 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id f12so5960163qtq.4 for ; Thu, 18 Mar 2021 22:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=E7sBW4F64Yeve4G2OY61bXlD1TuI/N6BQ+ZyRs716mU=; b=Uw2Df0gIpwjHNj5AE/FM1E3j6A+McyZDaI9/AZSvt4/fBU8yA7/d+g65kqPA8DTIRW 525xTirccAohk84UcAcpgfo5SDWcMkshV8Uyrti+6ruWraAZrwYMScMxV/zB243sjJXu zwEvOh46e6ByKkAUj0c1bI8BgU8cNi09Q78uzv3AZ9QcIWlf9Pwf6v8tsThRCby9a53e ejzazOL1i0VIMlHJW2bBIwGC9P9QoK2UJaQL5DcmJU4BlUNpjaRzJucseTscKoL21+ju YYWL7ycdaB4uYAYFUB6rUv5LzrRDzC2TvNWMPx+VV3zKHPX+P9MbV+7bjMaPSUpYET2q Isyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E7sBW4F64Yeve4G2OY61bXlD1TuI/N6BQ+ZyRs716mU=; b=U7pdsikyTW0Bu/D22822cy0HJUD+n25e1fR4rvytXmTanKfSs6x+5HTIV0AZ9mVvG5 ssPGVuZMhhSIvi2YsQVUJ0TPkeHoeD+bvnjvSSdikyjPttFULsD6LdgG4dV3GIeMVxw6 eLSZWxTIIVCJEYUYDm0PJSi6D7uEcpIUfpQO65FBTdkCVbMciOz0zwU3jaOQLO9zt+pW U3ZX5qUndqPjX/lYYK62HJGfRBOT1k+orTzd63hrcN0xB82eblrxOQ0S8FHM+K+NMcs2 onHnSjB6SS2h6KO5vUfpCZC3U+GLNdjzJxKrOUbEwIRGAymkJOANwlx+LdOFqvaK5IGS tiYg== X-Gm-Message-State: AOAM530OpiNDqkDVUGErc7jQ/L87FDyjBWIwo0OM2sZ2fOeFGjfdZ3Jy AnIZX0A8Yq/picVIQ8AHzo6d7A== X-Google-Smtp-Source: ABdhPJzGaqeKaoMUQXHUiDHdbU1sE21wdc1l3wPfQg7E/datRYgqmqaDFTyTsSJSOXxtFyASSxijXw== X-Received: by 2002:ac8:5a46:: with SMTP id o6mr6860454qta.289.1616132986941; Thu, 18 Mar 2021 22:49:46 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id e3sm3734259qkn.39.2021.03.18.22.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 22:49:46 -0700 (PDT) From: Johannes Weiner To: Andrew Morton Cc: Hugh Dickins , Shakeel Butt , Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 2/2] mm: memcontrol: deprecate swapaccounting=0 mode Date: Fri, 19 Mar 2021 01:49:44 -0400 Message-Id: <20210319054944.50048-2-hannes@cmpxchg.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210319054944.50048-1-hannes@cmpxchg.org> References: <20210319054944.50048-1-hannes@cmpxchg.org> MIME-Version: 1.0 X-Stat-Signature: zfnjo1xrsoizewkywa4ow8z1n5abk891 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 96799C0007C0 Received-SPF: none (cmpxchg.org>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-qt1-f176.google.com; client-ip=209.85.160.176 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616132987-294850 Content-Transfer-Encoding: quoted-printable 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=3D 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 stragegy. 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 --- .../admin-guide/kernel-parameters.txt | 5 -- include/linux/memcontrol.h | 4 -- mm/memcontrol.c | 48 ++++++------------- 3 files changed, 15 insertions(+), 42 deletions(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentat= ion/admin-guide/kernel-parameters.txt index 942bbef8f128..986d45dd8c37 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5322,11 +5322,6 @@ This parameter controls use of the Protected Execution Facility on pSeries. =20 - swapaccount=3D[0|1] - [KNL] 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=3D [ARM,IA-64,PPC,MIPS,X86] Format: { | force | noforce } -- Number of I/O TLB slabs diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 4064c9dda534..ef9613538d36 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -874,10 +874,6 @@ struct mem_cgroup *mem_cgroup_get_oom_group(struct t= ask_struct *victim, struct mem_cgroup *oom_domain); void mem_cgroup_print_oom_group(struct mem_cgroup *memcg); =20 -#ifdef CONFIG_MEMCG_SWAP -extern bool cgroup_memory_noswap; -#endif - void lock_page_memcg(struct page *page); void unlock_page_memcg(struct page *page); =20 diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 49bdcf603af1..b036c4fb0fa7 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -85,13 +85,6 @@ static bool cgroup_memory_nosocket; /* Kernel memory accounting disabled? */ static bool cgroup_memory_nokmem; =20 -/* Whether the swap controller is active */ -#ifdef CONFIG_MEMCG_SWAP -bool cgroup_memory_noswap __read_mostly; -#else -#define cgroup_memory_noswap 1 -#endif - #ifdef CONFIG_CGROUP_WRITEBACK static DECLARE_WAIT_QUEUE_HEAD(memcg_cgwb_frn_waitq); #endif @@ -99,7 +92,11 @@ 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) && !cgroup_memory_nosw= ap; + /* cgroup2 doesn't do mem+swap accounting */ + if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) + return false; + + return true; } =20 #define THRESHOLDS_EVENTS_TARGET 128 @@ -7019,7 +7016,7 @@ void mem_cgroup_swapout(struct page *page, swp_entr= y_t entry) if (!mem_cgroup_is_root(memcg)) page_counter_uncharge(&memcg->memory, nr_entries); =20 - if (!cgroup_memory_noswap && memcg !=3D swap_memcg) { + if (memcg !=3D swap_memcg) { if (!mem_cgroup_is_root(swap_memcg)) page_counter_charge(&swap_memcg->memsw, nr_entries); page_counter_uncharge(&memcg->memsw, nr_entries); @@ -7073,7 +7070,7 @@ int mem_cgroup_try_charge_swap(struct page *page, s= wp_entry_t entry) =20 memcg =3D mem_cgroup_id_get_online(memcg); =20 - if (!cgroup_memory_noswap && !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); @@ -7108,7 +7105,7 @@ void mem_cgroup_uncharge_swap(swp_entry_t entry, un= signed int nr_pages) rcu_read_lock(); memcg =3D mem_cgroup_from_id(id); if (memcg) { - if (!cgroup_memory_noswap && !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 @@ -7124,7 +7121,7 @@ long mem_cgroup_get_nr_swap_pages(struct mem_cgroup= *memcg) { long nr_swap_pages =3D get_nr_swap_pages(); =20 - if (cgroup_memory_noswap || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) return nr_swap_pages; for (; memcg !=3D root_mem_cgroup; memcg =3D parent_mem_cgroup(memcg)) nr_swap_pages =3D min_t(long, nr_swap_pages, @@ -7141,7 +7138,7 @@ bool mem_cgroup_swap_full(struct page *page) =20 if (vm_swap_full()) return true; - if (cgroup_memory_noswap || !cgroup_subsys_on_dfl(memory_cgrp_subsys)) + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) return false; =20 memcg =3D page_memcg(page); @@ -7161,11 +7158,10 @@ bool mem_cgroup_swap_full(struct page *page) =20 static int __init setup_swap_account(char *s) { - if (!strcmp(s, "1")) - cgroup_memory_noswap =3D false; - else if (!strcmp(s, "0")) - cgroup_memory_noswap =3D true; - return 1; + pr_warn_once("The swapaccount=3D commandline option is deprecated. " + "Please report your usecase to linux-mm@kvack.org if you " + "depend on this functionality.\n"); + return 0; } __setup("swapaccount=3D", setup_swap_account); =20 @@ -7291,27 +7287,13 @@ static struct cftype memsw_files[] =3D { { }, /* terminate */ }; =20 -/* - * If mem_cgroup_swap_init() is implemented as a subsys_initcall() - * instead of a core_initcall(), this could mean cgroup_memory_noswap st= ill - * remains set to false even when memcg is disabled via "cgroup_disable=3D= 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 =3D true; - - if (cgroup_memory_noswap) - return 0; - WARN_ON(cgroup_add_dfl_cftypes(&memory_cgrp_subsys, swap_files)); WARN_ON(cgroup_add_legacy_cftypes(&memory_cgrp_subsys, memsw_files)); =20 return 0; } -core_initcall(mem_cgroup_swap_init); +subsys_initcall(mem_cgroup_swap_init); =20 #endif /* CONFIG_MEMCG_SWAP */ --=20 2.30.1