From patchwork Fri Jun 28 21:03:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13716628 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 C85B8C30658 for ; Fri, 28 Jun 2024 21:04:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FEA56B00A5; Fri, 28 Jun 2024 17:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AD8A6B00A6; Fri, 28 Jun 2024 17:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D94A6B00A7; Fri, 28 Jun 2024 17:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id EA3756B00A5 for ; Fri, 28 Jun 2024 17:04:02 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 815D6A1702 for ; Fri, 28 Jun 2024 21:04:02 +0000 (UTC) X-FDA: 82281524724.14.68749ED Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by imf09.hostedemail.com (Postfix) with ESMTP id 5F8C4140014 for ; Fri, 28 Jun 2024 21:04:00 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mHSdMIeh; spf=pass (imf09.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.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=1719608630; 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=9l0JWNwiJR4vL4yVXqOBdtMhTUxMdQRWjUtEfPwLXqg=; b=pewOtvs0ntwmqWXdjvui5DNc3k6uiB85J79g0Hsq+nJhaP0PJfwJyqxytbAmw/DPZprOBW a2SB1RQbtdeHc/Mjm0gGEE6WEJ1gAJwoMaZY5JcYS29dpVLkhmij72nseQDERxNFbvhEON VASE/k6GoQjoi+mB2b50SHokpcqbT2g= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=mHSdMIeh; spf=pass (imf09.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.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=1719608630; a=rsa-sha256; cv=none; b=lAcDHu14mIi4JOivw0guWy9GtI2TkeAKuAwVxSxsn4HhTmF0o25+uunmjYmWrfd5P9OQVj StCpZ5YG1VS6oNlHJ/bDuQqge5ILfuQu3eqwOkSXb8GRC29fGZju6qRsYRGySHdKeRSs2n FoaSz/sK/AR6FqQP1EGHKoB5ECHiNsc= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719608639; 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=9l0JWNwiJR4vL4yVXqOBdtMhTUxMdQRWjUtEfPwLXqg=; b=mHSdMIehmfU80tUJ13pZQ5VJl08J44pqQFvWQh7HCi0HobI2vAa9le3PXL2LVITuRM7jfV ZbPYZXPvjueIrJ5ZFTUtdCNBYN0/RQ7nwmOF7mYOr06/IRW9+FAPlz3QzGyQ6PGml9o/HS 9EKtVQoUKle2Fb8KcYURkjqecYYRsic= X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org 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: roman.gushchin@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Roman Gushchin Subject: [PATCH v1 6/9] mm: memcg: put memcg1-specific struct mem_cgroup's members under CONFIG_MEMCG_V1 Date: Fri, 28 Jun 2024 21:03:14 +0000 Message-ID: <20240628210317.272856-7-roman.gushchin@linux.dev> In-Reply-To: <20240628210317.272856-1-roman.gushchin@linux.dev> References: <20240628210317.272856-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 5F8C4140014 X-Stat-Signature: hx3kezjhydhgyar745w581ui684nz6fe X-Rspam-User: X-HE-Tag: 1719608640-183994 X-HE-Meta: U2FsdGVkX1+4WxHcohbcSv0sGwC6RyPxitp21MmfVH8tAwmlYsz/OLAEQIDT+Ygr8nbWaC0Ogezm76wDDoRprEBnSf4tf5JLfPJun3N9gqvZbKQQsV7R1i+NIeeGOj8melphcsYJPBeQCYpTELdmRctJXDSmiw1+44N/FuMkKqMmGroW6osUKrvqbdc8gscx6X8JlD5desPFuAG3WALG0mgOWitP+jREo8OYNAKaLh3i0I//vr8KyTEn5jrsjfVmz/hDEOt8IqX+GnPjn4N6nuOAgPI7yY5BSPNu2qtjl3urcsLvePoxWDaCn0MIHAZlgtn0AUHfIl3amHSap0LC4YRlQOGqDrI2Whwwp+9/NvEUFIy9MSti2kczelVg/mb0oNWRaJ2qTeY8KRkXo8Mc5iKYk67sh3oPOFAB/22JrDPKzU8kbvACKNhrp/6GsXP17RU7qLlw6ng+MzT2tRCepnF6RMgrC2ePyfhp0hAgHr15Jl3VJXnivO/+Ka5v2UlCpGJlskmlXDh3HJiJTM8rUdeGJ0goPHPZFZIVOGppd4FnC3dRSQhuLIh/+f9+WS6fBE6eIjFMO1l75c5x9oB1PczfbJodUGgwaFdoAiSFqZGdxlgg1knjf+jzFTyKCqgoDTQZ25plLI+qxRNldaFDr4PjFMvE/xB5DFfPP96v4ts9puGM9pRsBoZTSe9ekxsjYE1Uv4XTzZjzbIRyPqjVzsu82t0l0zX4QQ6JrCc6ues87y0DATWJBWqBh8Zo59sdWaHI4I8Gpjh1h6pF4G46VBmsZ2ujtO6ppEWQs38aD/Zy2i8JHaa8c0fl8BBGgoqiFzL5iH4fdoXtkj2uOHu4MzBAKlDTcusQ8R4THJv6gioqVOauxQ3O8e6W0CyyNBc4A1nEBgMdhniZVnbWakHG/V79t7qzqer9GN0Cp56oF1yGQCBI56Fg2Y2WVUbkKw8JoUmssNz96LVReFZV3ac jdSyczn8 C+2yJ3o4h1MOkR15TPPsi4vbFkqIEEBcTz+5qDfpargvO08p0DA/zsE2hfZF8IT2vZ06X+DVMNEmIviPwxz+OzJDmd54VuaIrN7ljwHYZzf4k4AzEQQrQcXbNkiOVdsXc3z8/rPIls9PksXxnxWZdIv3/kc3is1q3csEbNCzKGm2wv0vcY8k554K9MXeuGIKPqU5UfyFCGSzS4EM= 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: Put memcg1-specific members of struct mem_cgroup under the CONFIG_MEMCG_V1 config option. Also group them close to the end of struct mem_cgroup just before the dynamic per-node part. Signed-off-by: Roman Gushchin Acked-by: Shakeel Butt --- include/linux/memcontrol.h | 103 +++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 44ab6394c9ed..107b0c5d6eab 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -188,10 +188,6 @@ struct mem_cgroup { struct page_counter memsw; /* v1 only */ }; - /* Legacy consumer-oriented counters */ - struct page_counter kmem; /* v1 only */ - struct page_counter tcpmem; /* v1 only */ - /* Range enforcement for interrupt charges */ struct work_struct high_work; @@ -205,8 +201,6 @@ struct mem_cgroup { bool zswap_writeback; #endif - unsigned long soft_limit; - /* vmpressure notifications */ struct vmpressure vmpressure; @@ -215,13 +209,7 @@ struct mem_cgroup { */ bool oom_group; - /* protected by memcg_oom_lock */ - bool oom_lock; - int under_oom; - - int swappiness; - /* OOM-Killer disable */ - int oom_kill_disable; + int swappiness; /* memory.events and memory.events.local */ struct cgroup_file events_file; @@ -230,27 +218,6 @@ struct mem_cgroup { /* handle for "memory.swap.events" */ struct cgroup_file swap_events_file; - /* protect arrays of thresholds */ - struct mutex thresholds_lock; - - /* thresholds for memory usage. RCU-protected */ - struct mem_cgroup_thresholds thresholds; - - /* thresholds for mem+swap usage. RCU-protected */ - struct mem_cgroup_thresholds memsw_thresholds; - - /* For oom notifier event fd */ - struct list_head oom_notify; - - /* - * Should we move charges of a task when a task is moved into this - * mem_cgroup ? And what type of charges should we move ? - */ - unsigned long move_charge_at_immigrate; - /* taken only while moving_account > 0 */ - spinlock_t move_lock; - unsigned long move_lock_flags; - CACHELINE_PADDING(_pad1_); /* memory.stat */ @@ -267,10 +234,6 @@ struct mem_cgroup { */ unsigned long socket_pressure; - /* Legacy tcp memory accounting */ - bool tcpmem_active; - int tcpmem_pressure; - #ifdef CONFIG_MEMCG_KMEM int kmemcg_id; /* @@ -284,14 +247,6 @@ struct mem_cgroup { struct list_head objcg_list; #endif - CACHELINE_PADDING(_pad2_); - - /* - * set > 0 if pages under this cgroup are moving to other cgroup. - */ - atomic_t moving_account; - struct task_struct *move_lock_task; - struct memcg_vmstats_percpu __percpu *vmstats_percpu; #ifdef CONFIG_CGROUP_WRITEBACK @@ -300,10 +255,6 @@ struct mem_cgroup { struct memcg_cgwb_frn cgwb_frn[MEMCG_CGWB_FRN_CNT]; #endif - /* List of events which userspace want to receive */ - struct list_head event_list; - spinlock_t event_list_lock; - #ifdef CONFIG_TRANSPARENT_HUGEPAGE struct deferred_split deferred_split_queue; #endif @@ -313,6 +264,58 @@ struct mem_cgroup { struct lru_gen_mm_list mm_list; #endif +#ifdef CONFIG_MEMCG_V1 + /* Legacy consumer-oriented counters */ + struct page_counter kmem; /* v1 only */ + struct page_counter tcpmem; /* v1 only */ + + unsigned long soft_limit; + + /* protected by memcg_oom_lock */ + bool oom_lock; + int under_oom; + + /* OOM-Killer disable */ + int oom_kill_disable; + + /* protect arrays of thresholds */ + struct mutex thresholds_lock; + + /* thresholds for memory usage. RCU-protected */ + struct mem_cgroup_thresholds thresholds; + + /* thresholds for mem+swap usage. RCU-protected */ + struct mem_cgroup_thresholds memsw_thresholds; + + /* For oom notifier event fd */ + struct list_head oom_notify; + + /* + * Should we move charges of a task when a task is moved into this + * mem_cgroup ? And what type of charges should we move ? + */ + unsigned long move_charge_at_immigrate; + /* taken only while moving_account > 0 */ + spinlock_t move_lock; + unsigned long move_lock_flags; + + /* Legacy tcp memory accounting */ + bool tcpmem_active; + int tcpmem_pressure; + + CACHELINE_PADDING(_pad2_); + + /* + * set > 0 if pages under this cgroup are moving to other cgroup. + */ + atomic_t moving_account; + struct task_struct *move_lock_task; + + /* List of events which userspace want to receive */ + struct list_head event_list; + spinlock_t event_list_lock; +#endif /* CONFIG_MEMCG_V1 */ + struct mem_cgroup_per_node *nodeinfo[]; };