From patchwork Tue Jun 25 00:58:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13710394 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 AE4EEC2BD09 for ; Tue, 25 Jun 2024 00:59:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2DEA6B008C; Mon, 24 Jun 2024 20:59:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDD196B0157; Mon, 24 Jun 2024 20:59:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7E5D6B0139; Mon, 24 Jun 2024 20:59:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A251B6B0349 for ; Mon, 24 Jun 2024 20:59:31 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0C6A2C14ED for ; Tue, 25 Jun 2024 00:59:31 +0000 (UTC) X-FDA: 82267602942.08.4B330FC Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) by imf20.hostedemail.com (Postfix) with ESMTP id 9F6ED1C0008 for ; Tue, 25 Jun 2024 00:59:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CUq2yEEM; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@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=1719277150; 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:references:dkim-signature; bh=7bUCDVvcPw74a9i1dFIsogz30aPOz1LJXzLxaSUcaf0=; b=TWQiLzsSLdi5XgyCNB03uezHJut5P5qHAPoewZK76h+Vgukf65DUr36Uo+g4NeTHM1HdOb BJNSt6xOdw+AdHfvK9HNp+9FbYUUHaTg1SAcYiFLbi5t+8tMYC0Fl640ejZWMeXvwgHlcc uaT15yO2bTnHVtkNQO5OGdussblkE7M= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=CUq2yEEM; spf=pass (imf20.hostedemail.com: domain of roman.gushchin@linux.dev designates 91.218.175.177 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719277150; a=rsa-sha256; cv=none; b=M9FnGDHuQ1ALuO6MlUmyTbz5KcUGRKxpKIHIsRbF7YRTbVZUQ1fFilPPCL0Q9Ra7mrgY/o Fv1if3WLgTkUqOGA6v9lpuEoMCwmhQQGPIBiaspsxIeJw63SXO/1JnxLeFIdShIvr0iPZG R8pp32N0fAgajwVZYnN9FQjB11kgVWI= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719277166; 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; bh=7bUCDVvcPw74a9i1dFIsogz30aPOz1LJXzLxaSUcaf0=; b=CUq2yEEMBuNG7r6fXhRo2oS+j4h2y3UGm/AKdRNOpWS6hrotNEUzQAfR4qQRzJZW7s4M3G iO7MSsYp63Cpt82yYgqOQMizDapyVacyf6+/19UYOxZvT5PgTKHYAugYnQXbiRCbWaClr+ zfQ+5mJqYEVHLCuV8hl/TqhjSvn3i74= X-Envelope-To: hannes@cmpxchg.org X-Envelope-To: mhocko@kernel.org X-Envelope-To: shakeel.butt@linux.dev X-Envelope-To: muchun.song@linux.dev X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: cgroups@vger.kernel.org X-Envelope-To: linux-mm@kvack.org X-Envelope-To: roman.gushchin@linux.dev X-Envelope-To: willy@infradead.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Andrew Morton Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org, Roman Gushchin , Matthew Wilcox Subject: [PATCH v2 00/14] mm: memcg: separate legacy cgroup v1 code and put under config option Date: Mon, 24 Jun 2024 17:58:52 -0700 Message-ID: <20240625005906.106920-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9F6ED1C0008 X-Stat-Signature: insqnotertf41xtytmxdi7yfh4znu77o X-Rspam-User: X-HE-Tag: 1719277168-339012 X-HE-Meta: U2FsdGVkX1+UrYf+bqu3r2wa3VH82am5vxbiTKrtgD17jSJWMGMd+vuou66A1QXr14247Jz68V1F+Caj/PKIFTfRzuFPUZ2WM0wL3R5XByg9fqpeUQ3PFyXRk3AU6lsyYUsy3Pz/whOxuSWvQEssqkmY4oU36o12B4il5aNU2+6xpoUZ0mx0fhME281VADJRcYpzpiMsdD1Whbp8C+gV8x74iHdAHPQ12otWWei7t/k/7mEQ+16UtrLg1Qg3BuPlU6WojZ3JiXoQeZrklpJ6UiD06qD9BBKSn9ATmsElQpTxob6V2/PJmqIx2NenHS/61O4hPkJEwoOGLXnMK6vbi/Smxxvs6ym7btv3Zr6Sem+7eu7Y8WGQe9K3bs3pGYSjrCtV9a+5ktq9gYz88fGVSrDCjjQ8sOL9RwqiWXfEayZ4iI0C/azTkYPZEk3c9rVAsBvvoys1mx31VapbJcLlZ/ky/WWLl6+Y4q8D6CxuxyIVqPvcuw7/EpL/GmuAoVxW8YCKUAIIObYsweq3zxCA+tuP1ZzXHjGRcUUeJ/95n029xaS0aT0Di32tSyu0t/yZM6vp/BoBoSbv3wB9DY0qaJy4eeOGnAlAIsg8Gb7lFdiu2BONFRqfuappiSGg412PtI7V4ZTmX0UeJyInnruK1p7+fGQ79yWYwzqzODeqo+ZyV0DWMGrm0Ckdb9cAiKMkPDPtnmSAAl4JEWh9Ge3DIwOlk1UG4YMVnYTQFGKScLM57hVucUD7AqCpUYsAcMSgMp2eGekPzu7K7vJYd9RaF+WvAG6NY1iNadIoddGbsu+6oR5VrxjbXuRZLY2JAFXG/EiTIRAIhBJu5EzrIwxckSUAhDlLLkb/OQRuwugJ+8ylJB3Or00sQb6ZHFLl125QNfslpXkSSSd5aB+vh6Co3dxTGGVJlxjDnviL6EllUhhr/gKG0CYkxvNEKorly0IEtmTU7w2dodmT8KYLm84 NQCqUlny A3Oo/XO715g9dowluri2CBjWBs4pCwZAyhj5Byd9riuWvKGxcFYYWJ3+fMBamiHqnmqDaz+xEZxCosS+YB2KkzfitaEfFziti11+kw5kNS0XHhCVcgBjV0QiieFyOsLxvvspf7IlInrbGWYV8OcFE7BHDOwufqDUyfqr0FrMzafpXWvlQ+0AEu4nuNKgsgBMlADCHJJYKZhY+2MABu45IEn7+0eGTdQzBIAHYgfOvCbVAaDqlxFCa9XXeDVha25clXVM+ 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: Cgroups v2 have been around for a while and many users have fully adopted them, so they never use cgroups v1 features and functionality. Yet they have to "pay" for the cgroup v1 support anyway: 1) the kernel binary contains an unused cgroup v1 code, 2) some code paths have additional checks which are not needed, 3) some common structures like task_struct and mem_cgroup contain unused cgroup v1-specific members. Cgroup v1's memory controller has a number of features that are not supported by cgroup v2 and their implementation is pretty much self contained. Most notably, these features are: soft limit reclaim, oom handling in userspace, complicated event notification system, charge migration. Cgroup v1-specific code in memcontrol.c is close to 4k lines in size and it's intervened with generic and cgroup v2-specific code. It's a burden on developers and maintainers. This patchset aims to solve these problems by: 1) moving cgroup v1-specific memcg code to the new mm/memcontrol-v1.c file, 2) putting definitions shared by memcontrol.c and memcontrol-v1.c into the mm/memcontrol-v1.h header, 3) introducing the CONFIG_MEMCG_V1 config option, turned off by default, 4) making memcontrol-v1.c to compile only if CONFIG_MEMCG_V1 is set. If CONFIG_MEMCG_V1 is not set, cgroup v1 memory controller is still available for mounting, however no memory-specific control knobs are present. This patchset is based against mm-unstable tree (b610f75d19a34), however a version based on mm-stable can be found here: https://github.com/rgushchin/linux/tree/memcontrol_v1.1-stable . v2: - minor compilation fix - #else/#endif comments fix (Lance Yang) v1: - switched to CONFIG_MEMCG_V1 being off by default based on LSFMMBPF discussion [1] - switched to memcg1_ prefix (Johannes) - many minor fixes - dropped patches which put struct memcg members under CONFIG_MEMCG_V1 (will post as a separate patchset) rfc: https://lwn.net/Articles/973082/ [1]: https://lwn.net/Articles/974575/ MAINTAINERS | 2 + include/linux/memcontrol.h | 156 ++++--- init/Kconfig | 9 + mm/Makefile | 2 + mm/memcontrol-v1.c | 2933 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mm/memcontrol-v1.h | 132 ++++++ mm/memcontrol.c | 4169 +++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------- mm/vmscan.c | 10 +- 8 files changed, 3794 insertions(+), 3619 deletions(-) Suggested-by: Matthew Wilcox (Oracle) Signed-off-by: Roman Gushchin Roman Gushchin (14): mm: memcg: introduce memcontrol-v1.c mm: memcg: move soft limit reclaim code to memcontrol-v1.c mm: memcg: rename soft limit reclaim-related functions mm: memcg: move charge migration code to memcontrol-v1.c mm: memcg: rename charge move-related functions mm: memcg: move legacy memcg event code into memcontrol-v1.c mm: memcg: rename memcg_check_events() mm: memcg: move cgroup v1 oom handling code into memcontrol-v1.c mm: memcg: rename memcg_oom_recover() mm: memcg: move cgroup v1 interface files to memcontrol-v1.c mm: memcg: make memcg1_update_tree() static mm: memcg: group cgroup v1 memcg related declarations mm: memcg: put cgroup v1-related members of task_struct under config option MAINTAINERS: add mm/memcontrol-v1.c/h to the list of maintained files MAINTAINERS | 2 + include/linux/memcontrol.h | 156 +- init/Kconfig | 9 + mm/Makefile | 2 + mm/memcontrol-v1.c | 2933 +++++++++++++++++++++++++ mm/memcontrol-v1.h | 132 ++ mm/memcontrol.c | 4141 ++++++------------------------------ mm/vmscan.c | 10 +- 8 files changed, 3780 insertions(+), 3605 deletions(-) create mode 100644 mm/memcontrol-v1.c create mode 100644 mm/memcontrol-v1.h Acked-by: Shakeel Butt