From patchwork Thu Oct 24 06:57:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13848402 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 39DCDD0BB69 for ; Thu, 24 Oct 2024 06:57:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB78B6B0085; Thu, 24 Oct 2024 02:57:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B67CF6B0089; Thu, 24 Oct 2024 02:57:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0A986B008A; Thu, 24 Oct 2024 02:57:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 803446B0085 for ; Thu, 24 Oct 2024 02:57:29 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 150AF141181 for ; Thu, 24 Oct 2024 06:57:10 +0000 (UTC) X-FDA: 82707588852.09.47461DC Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) by imf23.hostedemail.com (Postfix) with ESMTP id B3E7814000A for ; Thu, 24 Oct 2024 06:57:15 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kjf84Jp7; spf=pass (imf23.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729752969; a=rsa-sha256; cv=none; b=IrPjgULPPeyMZ7XqtWeLeUm6NkVmmN4MOVhezfxXUSrWlhUfCNsuNcKKg04ofVF0Qy3oZd z3L2Ilefk44ZIjbxN9L7+UAQBWlf8wn9FjoA6BaQXT1YFR3AeqC1RHp8ao8GEEL2Jj48sb oZVl/do/qKpypxK6BOeousDRyOiUEXw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Kjf84Jp7; spf=pass (imf23.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.185 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=1729752969; 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=Mgr83r2IKcrYLJOy8T73HRhPqfYNucsjFTt8Ge3VU38=; b=JlPz88ax32dnejcL2CuwbtKNbwo6jfZRQ7hWzeyVS1izBa5iOMvok3lbICxb8YOOU6M6xc t9DHohfgIU87Gfl0YQNVZOfLVHHjJ2PvwOae7pmmYEhExD2eB5DtBaddHEYRZOvM8MiHwD 9fv5KYdOJOHzPo2BqbR85EAbJtOQ6/Y= 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=1729753046; 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=Mgr83r2IKcrYLJOy8T73HRhPqfYNucsjFTt8Ge3VU38=; b=Kjf84Jp7OIqdpzZVceEWDUi0+bwEUOmndVPpmZE1fiaOTfTCdfeHWmTPGRpku1xwgY8bp8 U60q2aXQgrip6fBZ1ZVJImWWEZbroG3Iwi8NEQxuJGcqyR2Kvar9Vp7hYbCR8eFZY9lXDT grcTd/KAaZVZ1samkosAq9DTt8eUDtA= From: Shakeel Butt To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Hugh Dickins , 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: [RFC PATCH 1/3] memcg-v1: fully deprecate move_charge_at_immigrate Date: Wed, 23 Oct 2024 23:57:10 -0700 Message-ID: <20241024065712.1274481-2-shakeel.butt@linux.dev> In-Reply-To: <20241024065712.1274481-1-shakeel.butt@linux.dev> References: <20241024065712.1274481-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: w3ixbwkgcpqyowp3c7dnf7yy47c5h9qz X-Rspamd-Queue-Id: B3E7814000A X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729753035-586583 X-HE-Meta: U2FsdGVkX19dbKAh1jyiHnV/vjUiBEBE18dwD1T6Q7tacWMaKIExxt54Oo1bm/KQ0Wjh9Jft0OqcIEKWK8Do6x5KxsgRfbogLY/9lNGItxSqARIjFQOs2MV/F2RvqxaRn2fodjM3CjCgjfxYO324dQoz+CtFhDYMG10MbKkk0MbsoEEQ84cpJecYZThi0/K+jMJn4abKUidlzUb1VgYsBMCPtqBVIChHUTP0OZN4wETnEssqpqiXuvWxHyyVobJMHFe0cGF7C2q631jvxh9DBrQa7Kue+S6OLj3shsPN4eAR5egR7Qqq2U9Y5pVaGFUQmwLaL18TThZahBS046qZrj09VmSac4SnjaDpqi1yRQ6Zf15bFT+HITczkL96waYVLpOQ1xtRtIWB2OGaO9dWIyfDFMI7+YQPD+Q5qJy8Qh5lXapC0EqVVx7jYk94T0Ti2Y6Fg/YaRqo9YIqZfB+QxhDrcmvX4ByJUI81tfeWR7efXFYOB1LHv1kIgHUoI7M3D3196RxyLIuT7qQ7lt1rYiQamoLZYHbxy/Lo3PXd10jhj7VpHZmTOXUQxWKxEsWRPB7pFgh1r1tUq1KyqW5drJymI5GT+G0XSIkhueOEQwgBGMD/rOuvhhHfDMfeThajytia18jiDFEBJOgCktU8pPBjMs4BB/5x9N2z1R3dfcfrH0KlbrX3fvTW+VFzka/5PLhWJAPhLy7VYVro1VSXx9ZCKMtRZ/s5APaw+3Qw83VIykxFTSttN2PGCFjBGqsReOHpTfut5fBG7jTcFWk8WH5ytoA+KRpvGdpcOVGB8IMJ9B/ePp3CVEurBKOvLlx09KTrDFTuwZG6W714WX3t4pC7xfet5F4E6ST/EcCC6dvsVZY/ss8kMnTevgHaagy2znHDlNd8++YVrBIvUtsdcPk7FYEHVxlYYJaQKXAlIosAhuoMQf9m50nfDmO0lDqOrZsn2KhKiisJvi8dESw /52NueSL dk30KeBVkQZ0ex1Qe8VWiXG+4YCVdnQuaX/vUKzZ3JUtz+b6Sn8G6VuYrdLw9ZEqE+CMX7oDIaAMGw7cgUsCZxZLdWEBBi0E/1vJs2VhIZ/SjJhu3C0J29wz7iCKg2xicM53KXUtUAm59fsWHkioYQNclaGM+XsU0mXRtxDCWYAPHbg2uTL9bO06Avbeyl+tPC4cldQZMGn9M+M3kJNeSjPhox0ggjn/nWZ7DKgxW7BRBGjEmy9Mooa9uTtEGsThEjVHe3CUleotG/3aWTczRxcLK1w== 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 --- .../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..8f88540f0159 100644 --- a/mm/memcontrol-v1.c +++ b/mm/memcontrol-v1.c @@ -593,7 +593,7 @@ 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 @@ -606,17 +606,7 @@ static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css, "Please report your usecase to linux-mm@kvack.org if you " "depend on this functionality.\n"); - if (val & ~MOVE_MASK) - 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; + return -EINVAL; } #else static int mem_cgroup_move_charge_write(struct cgroup_subsys_state *css,