From patchwork Thu May 9 03:41:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13659418 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 B206CC10F1A for ; Thu, 9 May 2024 03:42:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 376DC6B009D; Wed, 8 May 2024 23:42:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3250C6B009E; Wed, 8 May 2024 23:42:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 103356B009F; Wed, 8 May 2024 23:42:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id E159F6B009D for ; Wed, 8 May 2024 23:42:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5E2E38049F for ; Thu, 9 May 2024 03:42:31 +0000 (UTC) X-FDA: 82097460102.09.7D57E5B Received: from out-186.mta1.migadu.com (out-186.mta1.migadu.com [95.215.58.186]) by imf06.hostedemail.com (Postfix) with ESMTP id B2907180003 for ; Thu, 9 May 2024 03:42:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Exu/CQXX"; spf=pass (imf06.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.186 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=1715226149; 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=Dw2WxfyzO5phrNYcejGku6aC7TT0H0mgxaapi/nzE68=; b=r1GtuT9VNPKqrNC0n/qpLdUOPqUvk/tJnZjURHY9GTbJxRyb0nM3uVivf3FHiaYcFhZOBe LpSArzRk2DAgFULHaytGUtziNCWvXhvS+dlRHsJPkbBzM+g0zOgoNECN4r2rIuRz22CiWd N4/ohOGkY+yNaE0IPjdqtB0pCQOe9qw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="Exu/CQXX"; spf=pass (imf06.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.186 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=1715226149; a=rsa-sha256; cv=none; b=TydSXplzpdNdWF57VsOfS7fYewWUxCFtJLJRbUz8veox/SnHmW1MsF6aF44Ec6vMpvjIoK +hveP8r0+ynOkuPuYWynoO39VW83GDEuT5ytt2DhOmcpVfxSIowSl7bIKB3j6zyZbCmXNi 4WsTNIipLcg5JktgOGpD7p8JThZfEbA= 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=1715226148; 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=Dw2WxfyzO5phrNYcejGku6aC7TT0H0mgxaapi/nzE68=; b=Exu/CQXXta7/748feKtaHt6ZdSNf+MZZejRvNAAT//Krgqm+P11yXG98gr8CAkUsrJgl+o BHXl1frW++LIeLHUpp2ymfP2LhgalpYaW5nEbjDFc6vuljOGpIGBsdQIK0IbxjTePaUYB+ mvY2jN0/UkvwueWbqM/FMOgJaL5V+KA= From: Roman Gushchin To: Andrew Morton Cc: Muchun Song , Johannes Weiner , Michal Hocko , Shakeel Butt , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Roman Gushchin Subject: [PATCH rfc 9/9] mm: memcg: put cgroup v1-related members of task_struct under config option Date: Wed, 8 May 2024 20:41:38 -0700 Message-ID: <20240509034138.2207186-10-roman.gushchin@linux.dev> In-Reply-To: <20240509034138.2207186-1-roman.gushchin@linux.dev> References: <20240509034138.2207186-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Stat-Signature: j33fc7xc8y98zzrtkcc74dibekof4gu9 X-Rspam-User: X-Rspamd-Queue-Id: B2907180003 X-Rspamd-Server: rspam05 X-HE-Tag: 1715226149-681486 X-HE-Meta: U2FsdGVkX19eg5PgLXpKKGJ0RvdPxL/9q7sbERYdGlQfhZ/Mq49la+sqfs6wlDcXS2OfaZmeoGZXJFfmjBzKqI70wl+eyUl4a93Rnz//MjJSexlT/psZ101SO8js8NlYJcETfwUUZD7Ebigr6umgr8pzoO3aXC9kR2xFsuqVU32pHYmvqvfRfWcROz9I410479eWqDMkB6vHjRcS3xYhH3sXZzJ3xJG8kPeOoaxzTOuZSuI05+MOouovKE/nifX/TykANHQ2K4x3OpdcqiZzcg3JcLGGRnIU+3G9Z/fL5EaiH+7SGtlzin5uNXFNsM+DAdpyTCoRJTZPPcV+UJPf++dLFnNM13NNXUNvNwKAGpedbfxfP47aiQd53X7rbMlhxySmsJBjGIEwbpL4nCxcw11kNE9cOjljhBxXQEOVwVThgL6sPSVm7fgZwbV+PUEVAKqkvHW5e38pfT+wKgIwEbjYsZ69T0vlQ9meGKQqozWvZTlw2JjJawjAneI2I7ckAiyK/0K+mX7acD7HnHkg28LzlXDtNFqNNxAf/fp8mIRSQb30RRXPmB5UHjlZaEE0druV26hE2/DXXPUavm556HhDxJ2GG0ZRSGRh9xz9/P1hjfMyzGdCYblWnYZSgzlFMtmTkKWh+pquGNlr02NwPCijfUb+P/RBs1sWNGJBz61uI7uDAhyO2RoGW6vwuzAwBZoDtMTMPWmggXEs+Z7kPSviNqh/zfyVmTq+IZZzkos7H6udIr4n0TIhpq6Jaj10Q/gwJMDxw5heUEp46EHUTVQTlVhjwinopWsjafRpjejSujMJqTpTFhmObuzYoFr04WH4lS06xw9VvNTSlLEXo3aljI+H8riGdZXkyzGKgTPJG/lOIUJzp3A5QVMOMElM5Ed8kDMtgPHyInPWpCtoT9F2HSMy41Yw2rZnmbgvsPI40ueYeKHWX+rgqSBfwjogKffzKP0hycryUs5IChB fmCt7ucD oZH/fANRC7HjrgSrQ81cnPC5GPvCs9nSZVrrxmA4Eh2a36fMautOn7k3OoiztVY5k+DNCMm/ZpWupvfiAXcwv6OfjFNr3oiej7nKqX5R53dd8aj6FSvHSozZx/UY0yWGUMgqK 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: Guard cgroup v1-related members of task_struct under the CONFIG_MEMCG_V1 config option, so that users who adopted cgroup v2 don't have to waste the memory for fields which are never accessed. Signed-off-by: Roman Gushchin --- include/linux/memcontrol.h | 11 ++++++++++- include/linux/sched.h | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 4347d6889fa0..8005d749f8fc 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -944,6 +944,7 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg); +#ifdef CONFIG_MEMCG_V1 static inline void mem_cgroup_enter_user_fault(void) { WARN_ON(current->in_user_fault); @@ -961,9 +962,17 @@ static inline bool task_in_memcg_oom(struct task_struct *p) return p->memcg_in_oom; } -#ifdef CONFIG_MEMCG_V1 bool mem_cgroup_oom_synchronize(bool wait); #else +static inline void mem_cgroup_enter_user_fault(void) {} + +static inline void mem_cgroup_exit_user_fault(void) {} + +static inline bool task_in_memcg_oom(struct task_struct *p) +{ + return false; +} + static inline bool mem_cgroup_oom_synchronize(bool wait) { return false; diff --git a/include/linux/sched.h b/include/linux/sched.h index 4118b3f959c3..2ecdeb7588e3 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1446,11 +1446,14 @@ struct task_struct { unsigned int kcov_softirq; #endif -#ifdef CONFIG_MEMCG + +#ifdef CONFIG_MEMCG_V1 struct mem_cgroup *memcg_in_oom; gfp_t memcg_oom_gfp_mask; int memcg_oom_order; +#endif +#ifdef CONFIG_MEMCG /* Number of pages to reclaim on returning to userland: */ unsigned int memcg_nr_pages_over_high;