From patchwork Fri Oct 25 01:22:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13849917 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 C5556D1038E for ; Fri, 25 Oct 2024 01:23:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 517466B009C; Thu, 24 Oct 2024 21:23:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4C8006B009D; Thu, 24 Oct 2024 21:23:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 390106B009E; Thu, 24 Oct 2024 21:23:34 -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 1BD656B009C for ; Thu, 24 Oct 2024 21:23:34 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7F6744028B for ; Fri, 25 Oct 2024 01:23:23 +0000 (UTC) X-FDA: 82710376560.22.891D479 Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf24.hostedemail.com (Postfix) with ESMTP id 32638180013 for ; Fri, 25 Oct 2024 01:23:28 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BYHipPaw; spf=pass (imf24.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729819259; 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=l+J9jIglENq8jzu02bF8vylZNSZPLddTn6u8mh0nWUU=; b=sEKEcpG6vkZeKnA7DiIlgGPNRztI5Gze2dIB15IK0gxIu4Dxu9J+NMyaVO4hc2THCzHI9m b0FIbCROdWzUNFAGNaQiho6NlLI4q35GdToCYNfw9N4gMYA8LvFOZa73vmjLF5TDv42WqX 61zPHcnhJXOaqs1QJD5IwvjHeB2aXq4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729819259; a=rsa-sha256; cv=none; b=LRmzYrCddiYtdpDkIfL7WYieRNSawFPLbVPkxCXxIAJfwbS8kO+XDAiNVsoqTgkKyJNttF AxwpBgQzslfxp8TpcM1e/CXsPsnX0KtxM4G9+SGF6MPlcNUXANCStOP0D6PK9lH61mnhgL 8I0r6q1rS6VCApcrMa1xjQVS+vFTwGs= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=BYHipPaw; spf=pass (imf24.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.186 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1729819409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l+J9jIglENq8jzu02bF8vylZNSZPLddTn6u8mh0nWUU=; b=BYHipPawJUMMW2Grb3IgGNBGyd/tCAEj58t9TYe6oWoiC8107S9853GwmSzHeSpldFUmVs 0f1Xrr4JjMdvp9qn3yoUAkWW5btgPv7xCsKVEDAThJjkmP4IKr9HmyQMwtGeytNs1l9ZA2 NN38hBDw18D1pA94B4nYiBsxI9LGTnA= From: Shakeel Butt To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Hugh Dickins , Yosry Ahmed , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, Meta kernel team Subject: [PATCH v1 1/6] memcg-v1: fully deprecate move_charge_at_immigrate Date: Thu, 24 Oct 2024 18:22:58 -0700 Message-ID: <20241025012304.2473312-2-shakeel.butt@linux.dev> In-Reply-To: <20241025012304.2473312-1-shakeel.butt@linux.dev> References: <20241025012304.2473312-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 32638180013 X-Stat-Signature: rpo7xwxn3o74t5xaofq6kcjgjb8whybh X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729819408-112275 X-HE-Meta: U2FsdGVkX1+XFJpTmbqj0FuFryL8/qGPFS5fO9RN1zIzYnnn97vQ4IU73r21FT2bB753+AFSrTI54+DJ4MzjHOtfreQARApu5EPpdHrJmCKxFWNDOUa0+LaAp/lJp9YHqgcSyrd0hcwvH+VwgFYHvHwIbr7dlmM2pD0HQ3kRH0Qz8VE+6dq+feNQT+xiiJbsPxQdVxqf98pCZqWkcBTIxIJsSK9x2QmFGf1ybKoGFMrPYW8D5cNwIzdFfRAvwsIE7CFNNAYWNCNDhLb0qogmgbmwCYHQfqWV3BbiSt3QCwp+R5vA4j4pUHOCm1x3kggAln/IKC1quORQn4z57T8S8TKdHdWup7/byK1tX+NUv0MVHcfC3kFBvKzpmt3MgIE8k1gCRSk/EUjdq/ZBzpSaApLT7ey4dI6QPUAsIzrI+vx6imd7gLDGzSGYwZniHllFo/PtL+lJkhhh6OxIzt7ecxSrq7uyb+fVD1gdaE98/4IKZTDqUtYpt/LCX3gdvuboa/DQNkUiiyjtK5vEQM6h/nRmcNpk3N0otvhevzaq8KstNtc04LXmjcWKtqVa5Jaus/5M6uncb4IrMDv3DlnSYOzw458J0RxbXw+Nc1XS2iPMwJYCvMrlR7f/qo7W3D1/J5y73eRv7CXvhIhj0xsUrMgAJiydz9zDFtaVUXUGL8ue794gly3SaRGn8mP4hIAIz0nBSH/TmJ25XnbPCtJJqP4Yo90lu9OZiYFgcKx31JGvaCN+y2HpqjTPwOlhJIRsHZwTPXWOZMZEuNPAU3EdMd6BQzpvOKlUu89EfSZnM35LzAM/Spe8p4tbx+bc0Dp0U+9Pajmg2lYVd6I+kaJjpvQPSZLxKEUmJyFwf8+33ep92p6+oHg5zsQsfOlyt+sXPQIg2iLWuUZAHHjfoqA0425ToO2Gv+nHQPAfuNlC/XE4VZPYgieJ/YCMOZ406TUtCFwyjY/l5j2ffLy1Q0I Hh3weeoC g0QHRhJls8UNatvvraK4b8JJRhL+H2KVTDUcyLhHK90519/iukRNlJ1bBd3nfp4X9MRHVsVR8TtfvcAoZ+UDuJKKN/MiuUx9FgpDmzrVydu/7V9Iq2jTliNsNW0bVBXGYUXu16kdV7gk59cT02xZ+9HczJQKvcELtUXD9nauw1/N69oNmIm1/NQS02gwUBNBbu/xnhfgXY9NPrFRe7YQGqwqabjomUxeiVRS4f0wg1NTLFJ7nFMRvvwwW/Q== 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: Proceed with the complete deprecation of memcg v1's charge moving feature. The deprecation warning has been in the kernel for almost two years and has been ported to all stable kernel since. Now is the time to fully deprecate this feature. Signed-off-by: Shakeel Butt Reviewed-by: Roman Gushchin Acked-by: Michal Hocko Acked-by: Johannes Weiner --- Changes since RFC: - Writing 0 to memory.move_charge_at_immigrate is allowed. .../admin-guide/cgroup-v1/memory.rst | 82 +------------------ mm/memcontrol-v1.c | 14 +--- 2 files changed, 5 insertions(+), 91 deletions(-) diff --git a/Documentation/admin-guide/cgroup-v1/memory.rst b/Documentation/admin-guide/cgroup-v1/memory.rst index 270501db9f4e..286d16fc22eb 100644 --- a/Documentation/admin-guide/cgroup-v1/memory.rst +++ b/Documentation/admin-guide/cgroup-v1/memory.rst @@ -90,9 +90,7 @@ Brief summary of control files. used. memory.swappiness set/show swappiness parameter of vmscan (See sysctl's vm.swappiness) - memory.move_charge_at_immigrate set/show controls of moving charges - This knob is deprecated and shouldn't be - used. + memory.move_charge_at_immigrate This knob is deprecated. memory.oom_control set/show oom controls. This knob is deprecated and shouldn't be used. @@ -243,10 +241,6 @@ behind this approach is that a cgroup that aggressively uses a shared page will eventually get charged for it (once it is uncharged from the cgroup that brought it in -- this will happen on memory pressure). -But see :ref:`section 8.2 ` when moving a -task to another cgroup, its pages may be recharged to the new cgroup, if -move_charge_at_immigrate has been chosen. - 2.4 Swap Extension -------------------------------------- @@ -756,78 +750,8 @@ If we want to change this to 1G, we can at any time use:: THIS IS DEPRECATED! -It's expensive and unreliable! It's better practice to launch workload -tasks directly from inside their target cgroup. Use dedicated workload -cgroups to allow fine-grained policy adjustments without having to -move physical pages between control domains. - -Users can move charges associated with a task along with task migration, that -is, uncharge task's pages from the old cgroup and charge them to the new cgroup. -This feature is not supported in !CONFIG_MMU environments because of lack of -page tables. - -8.1 Interface -------------- - -This feature is disabled by default. It can be enabled (and disabled again) by -writing to memory.move_charge_at_immigrate of the destination cgroup. - -If you want to enable it:: - - # echo (some positive value) > memory.move_charge_at_immigrate - -.. note:: - Each bits of move_charge_at_immigrate has its own meaning about what type - of charges should be moved. See :ref:`section 8.2 - ` for details. - -.. note:: - Charges are moved only when you move mm->owner, in other words, - a leader of a thread group. - -.. note:: - If we cannot find enough space for the task in the destination cgroup, we - try to make space by reclaiming memory. Task migration may fail if we - cannot make enough space. - -.. note:: - It can take several seconds if you move charges much. - -And if you want disable it again:: - - # echo 0 > memory.move_charge_at_immigrate - -.. _cgroup-v1-memory-movable-charges: - -8.2 Type of charges which can be moved --------------------------------------- - -Each bit in move_charge_at_immigrate has its own meaning about what type of -charges should be moved. But in any case, it must be noted that an account of -a page or a swap can be moved only when it is charged to the task's current -(old) memory cgroup. - -+---+--------------------------------------------------------------------------+ -|bit| what type of charges would be moved ? | -+===+==========================================================================+ -| 0 | A charge of an anonymous page (or swap of it) used by the target task. | -| | You must enable Swap Extension (see 2.4) to enable move of swap charges. | -+---+--------------------------------------------------------------------------+ -| 1 | A charge of file pages (normal file, tmpfs file (e.g. ipc shared memory) | -| | and swaps of tmpfs file) mmapped by the target task. Unlike the case of | -| | anonymous pages, file pages (and swaps) in the range mmapped by the task | -| | will be moved even if the task hasn't done page fault, i.e. they might | -| | not be the task's "RSS", but other task's "RSS" that maps the same file. | -| | The mapcount of the page is ignored (the page can be moved independent | -| | of the mapcount). You must enable Swap Extension (see 2.4) to | -| | enable move of swap charges. | -+---+--------------------------------------------------------------------------+ - -8.3 TODO --------- - -- All of moving charge operations are done under cgroup_mutex. It's not good - behavior to hold the mutex too long, so we may need some trick. +Reading memory.move_charge_at_immigrate will always return 0 and writing +to it will always return -EINVAL. 9. Memory thresholds ==================== diff --git a/mm/memcontrol-v1.c b/mm/memcontrol-v1.c index 81d8819f13cd..9b3b1a446c65 100644 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -593,29 +593,19 @@ static inline int mem_cgroup_move_swap_account(swp_entry_t entry, static u64 mem_cgroup_move_charge_read(struct cgroup_subsys_state *css, struct cftype *cft) { - return mem_cgroup_from_css(css)->move_charge_at_immigrate; + return 0; } #ifdef CONFIG_MMU static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css, struct cftype *cft, u64 val) { - struct mem_cgroup *memcg = mem_cgroup_from_css(css); - pr_warn_once("Cgroup memory moving (move_charge_at_immigrate) is deprecated. " "Please report your usecase to linux-mm@kvack.org if you " "depend on this functionality.\n"); - if (val & ~MOVE_MASK) + if (val != 0) return -EINVAL; - - /* - * No kind of locking is needed in here, because ->can_attach() will - * check this value once in the beginning of the process, and then carry - * on with stale data. This means that changes to this value will only - * affect task migrations starting after the change. - */ - memcg->move_charge_at_immigrate = val; return 0; } #else