From patchwork Fri Jun 28 21:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13716631 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 418AEC2BD09 for ; Fri, 28 Jun 2024 21:04:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D2AFC6B009B; Fri, 28 Jun 2024 17:04:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD9016B00AC; Fri, 28 Jun 2024 17:04:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B273D6B00AD; Fri, 28 Jun 2024 17:04:12 -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 8C0EB6B009B for ; Fri, 28 Jun 2024 17:04:12 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4296F4074F for ; Fri, 28 Jun 2024 21:04:12 +0000 (UTC) X-FDA: 82281525144.23.B036573 Received: from out-181.mta1.migadu.com (out-181.mta1.migadu.com [95.215.58.181]) by imf14.hostedemail.com (Postfix) with ESMTP id 8D3C3100013 for ; Fri, 28 Jun 2024 21:04:08 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QpsayaNI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.181 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719608633; a=rsa-sha256; cv=none; b=oncBb0JY35QdF36NSCb5zX5ZaOfe4k4CztjCxok5vd5KgcXuqizH1g1AbEBZBo8v+Rhgjx m7hCOarVU27oTxef7v5G9rp3RtQqDpTA52dkW9C9FFGYN1tSRGVbhzRmzAdd1zJf86evz7 H835G0GLKfnk6NiqDS4WhLZm8t5AWmY= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=QpsayaNI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf14.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.181 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719608633; 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=oh6eW8o5ezSHh2B9Y0288jMuerKh+JrpdW4rG/niw6g=; b=bAMsC8FGALInIQ2YqMQ3GNTreiXJcfjbnDIKGxwtnCAAl5azg6PZ7u65z0YR2W87VKXawY HhT5ws0pnJMkT9/3IcH6shr3KyU2jWU3B2XUbWsB5kAjNyGvzHnP9REW3WmWLzBJ8OozAt dLehyhsoCwQj9/DjqmtLd57PD3m0m0U= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1719608644; 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=oh6eW8o5ezSHh2B9Y0288jMuerKh+JrpdW4rG/niw6g=; b=QpsayaNInZKUdJVZpy1kkSsroiwMuaPQfyxm5rAk+pXTVr8En9fFyYvIwTr6R7dJ33uiKM 1AzxHnAG8Ddl6RthYG+usN6D76Fxc8a0sAv/JKBzlZOI8QTxzSeg84AglcBFGF+h71kNIF DTcfQi/0cnTValmfFuaVbPpyxydd07g= 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 9/9] mm: memcg: put struct task_struct::in_user_fault under CONFIG_MEMCG_V1 Date: Fri, 28 Jun 2024 21:03:17 +0000 Message-ID: <20240628210317.272856-10-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: rspam12 X-Rspamd-Queue-Id: 8D3C3100013 X-Stat-Signature: cf8ak3djgxyho9kmeztzk3y98yz6sd5a X-Rspam-User: X-HE-Tag: 1719608648-656609 X-HE-Meta: U2FsdGVkX1/rDK3EBUbZgBk2qZDlvhNseaHDJK8sbNV8Id5BqZMFF5CGIbnQMJw3Olay/y9eA1wmzvhSkMijZeaj691vA+nTzw4SzYmfYz7O2YBDwrxvuBIuMUasWSCDS11dDZQIFgwQCSKi+gNi9dHcHpKx3cTPzxc01CBIqrjmRU6I8jEG1ISCK08MDPpi5BEchZtxbDtfwacE8z3cvYOi/Y+V2yTJgyoQ1ZHxIOXCo4cT5BCx8yE0/141htvPSpALIszy2nCJ2+mecr//Jxa+b/U9ERcENoXdGcQkgcOLEufr7hI1hdWgfnQuq8WOCLm20iLXTyB0evEuzKp7jYaScExAErNKJ9cyiCF2qA19EI5vtti5k6eTRP9qGoNsz9iHPC7nodKPVG2PVQ5RWQ48EcOFe/GY0TEbVqZbX4mgfKmI14+kSPy8WaDM5VfXpIGOl8I+tSFD+Fg6Nq0QmU4sXE0bluDqfRxmyasg1gCe1FLFE0tfpCGe3gw+SuaGJ2J+3cOHjX9+8vSWAYyvzOVwzzVWPqmD9J3udiWg4Bz8aGpW49RKheMCNJxCtwO3MpNymC8Mq69HLK7mM1VhzYSaFnEkMoriyikQST8knTcSpGgWyM4rMQb6aAZOp0/HkC5SBXyBpBR4bOxSPtlbHiU6Hv9H79fj1qk7LNOavPyLlZfbMi5pw+JgsPopp+avCaoAveJJs0b3a7/Ft3Gb1uqlIztf4g11pZ4SBb46HdsSQRveiqcZOJVZUedGqJbnp0KW8tGlyqysLWTF1QBRCyGOIlPZqMw03NIhwfAbQRfS9ibW5N9iOBPJNHB33Z/crpHgsd+H7qWHU/B7hSrEB2+NG28EXbIUMwiILsmNbl1CKX74U5T3HEvJhpe38OW1cA8kI0Kvo7oeP8oBDz2Rnh8uqExstA5DX8v3j3s5YResEWfqeFACZXe32ipDx2JrGlWJdArRF/eDbkllrYM h5WFyTZW 8AQEXZ89YP2qovqugd0OurS36yNfTaCxtn/P/265YEzWrgaPVgyD1UrYwlqoQQuY2a3hvNgMaA3lZzm5bWilohLI6uQdsLUyKQzTH/VYb21KRwDr4nOELoaALy2vPIkY8na62kpLlYp1J4l2kfWI+1TlKrxYGZBYONR6g 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: The struct task_struct's in_user_fault member is not used by the cgroup v2's memory controller, so it can be put under the CONFIG_MEMCG_V1 config option. To do so, mem_cgroup_enter_user_fault() and mem_cgroup_exit_user_fault() are moved under the CONFIG_MEMCG_V1 option as well. Signed-off-by: Roman Gushchin Acked-by: Shakeel Butt --- include/linux/memcontrol.h | 40 +++++++++++++++++++------------------- include/linux/sched.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index c7ef628ee882..d0c9365ff039 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -943,18 +943,6 @@ void mem_cgroup_print_oom_context(struct mem_cgroup *memcg, void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg); -static inline void mem_cgroup_enter_user_fault(void) -{ - WARN_ON(current->in_user_fault); - current->in_user_fault = 1; -} - -static inline void mem_cgroup_exit_user_fault(void) -{ - WARN_ON(!current->in_user_fault); - current->in_user_fault = 0; -} - struct mem_cgroup *mem_cgroup_get_oom_group(struct task_struct *victim, struct mem_cgroup *oom_domain); void mem_cgroup_print_oom_group(struct mem_cgroup *memcg); @@ -1402,14 +1390,6 @@ static inline void mem_cgroup_handle_over_high(gfp_t gfp_mask) { } -static inline void mem_cgroup_enter_user_fault(void) -{ -} - -static inline void mem_cgroup_exit_user_fault(void) -{ -} - static inline struct mem_cgroup *mem_cgroup_get_oom_group( struct task_struct *victim, struct mem_cgroup *oom_domain) { @@ -1890,6 +1870,18 @@ static inline void mem_cgroup_unlock_pages(void) rcu_read_unlock(); } +static inline void mem_cgroup_enter_user_fault(void) +{ + WARN_ON(current->in_user_fault); + current->in_user_fault = 1; +} + +static inline void mem_cgroup_exit_user_fault(void) +{ + WARN_ON(!current->in_user_fault); + current->in_user_fault = 0; +} + #else /* CONFIG_MEMCG_V1 */ static inline unsigned long memcg1_soft_limit_reclaim(pg_data_t *pgdat, int order, @@ -1929,6 +1921,14 @@ static inline bool mem_cgroup_oom_synchronize(bool wait) return false; } +static inline void mem_cgroup_enter_user_fault(void) +{ +} + +static inline void mem_cgroup_exit_user_fault(void) +{ +} + #endif /* CONFIG_MEMCG_V1 */ #endif /* _LINUX_MEMCONTROL_H */ diff --git a/include/linux/sched.h b/include/linux/sched.h index 2a16023e8620..a7770c566c4d 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -934,7 +934,7 @@ struct task_struct { #ifndef TIF_RESTORE_SIGMASK unsigned restore_sigmask:1; #endif -#ifdef CONFIG_MEMCG +#ifdef CONFIG_MEMCG_V1 unsigned in_user_fault:1; #endif #ifdef CONFIG_LRU_GEN