From patchwork Mon Apr 15 03:11:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xu.xin16@zte.com.cn X-Patchwork-Id: 13629413 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 738C1C4345F for ; Mon, 15 Apr 2024 03:11:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 874426B0082; Sun, 14 Apr 2024 23:11:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 824256B0083; Sun, 14 Apr 2024 23:11:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 713506B0085; Sun, 14 Apr 2024 23:11:46 -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 536B06B0082 for ; Sun, 14 Apr 2024 23:11:46 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id DF0661C07F3 for ; Mon, 15 Apr 2024 03:11:45 +0000 (UTC) X-FDA: 82010291370.19.C1FEDDD Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by imf01.hostedemail.com (Postfix) with ESMTP id 812E34000A for ; Mon, 15 Apr 2024 03:11:42 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf01.hostedemail.com: domain of xu.xin16@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=xu.xin16@zte.com.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713150703; 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-type:content-transfer-encoding:in-reply-to: references; bh=ZtNxaSaPxNokvuXkVjrLucCc+hMGeTFWsdhBLn4T5oU=; b=P7GlfIUufhftXIFUhE6uKUFYKge0tDq2RlYldCV8JiDA6TnOkjUWtmBkhgnFinpxmRs6VN IH5wsyqXVaZFk5qfOl33JZd8C3Sh0M6j5TE2HV80JeMneNjWztXkhPszXOMPgcudLaLQ/8 E0YFbB50ivS6Nn+OGRX3W0xl040Qn34= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=zte.com.cn; spf=pass (imf01.hostedemail.com: domain of xu.xin16@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=xu.xin16@zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713150703; a=rsa-sha256; cv=none; b=cgmyEiS6VaXDBt2t0wFpX4bGZZstSOePJa6/m12VxDXLEqBC+KvxtO4b+V9lK2YZEletVo rt4Lyp6yCVB2p5T4ktOShyfePTk36uqEvqBfseOZy2zfLxOaAKTMtvr1RbF1eyhIv4p9/5 JhZMZb2jI/rJlwdoK6zfxHE3pMm6PjQ= Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4VHsdk2fWSz6G3wZ; Mon, 15 Apr 2024 11:11:38 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.99.176]) by mse-fl1.zte.com.cn with SMTP id 43F3BMeA060726; Mon, 15 Apr 2024 11:11:22 +0800 (+08) (envelope-from xu.xin16@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid32; Mon, 15 Apr 2024 11:11:23 +0800 (CST) Date: Mon, 15 Apr 2024 11:11:23 +0800 (CST) X-Zmail-TransId: 2af9661c9adb5fc-0b588 X-Mailer: Zmail v1.0 Message-ID: <20240415111123924s9IbQkgHF8S4yZv4su8LI@zte.com.cn> Mime-Version: 1.0 From: To: , , , Cc: , , , , , , , , , , Subject: =?utf-8?q?=5BPATCH=5D_mm=3A_thp=3A_makes_the_memcg_THP_deferred_spl?= =?utf-8?q?it_shrinker_aware_of?= =?utf-8?q?_?= =?utf-8?q?_node=5Fid?= X-MAIL: mse-fl1.zte.com.cn 43F3BMeA060726 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 661C9AEA.001/4VHsdk2fWSz6G3wZ X-Rspamd-Queue-Id: 812E34000A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: bj7fcs3ou6itok6tcnm1sijgu1ch64h6 X-HE-Tag: 1713150702-405830 X-HE-Meta: U2FsdGVkX1/cMLih1+jQxKKTzAprdjokLEpgkN4yjgYniUrvhuBbNUoKxUzmXF1CmFWU/5FnrHjpUaFGM7aunS0koD2JmbXxCsym8p40DczhhF2DvrAp8vdIiGKfCmtjFQ/siCBn0kTuwyxcvtZJ9f7DNL9m5lT5ascCcd/+EJk6oybFe1d0z1AqrBhIjU+xBltGmDVlV/naDreUQcNl4W7zKdz65s+9ixhresVtQwsAn4DGmHu2P8BUGobfvemXdJ6wRYsYzAw5OKLev3nVcgYRchycYMpGT6T+Zjt9Wz8F6ETvY/4iZzyA7CYFJ+6b9BDHF7EhPsl/35yjK0gTHivjDbNPR79KyFHNqrx6wXOKDdFwkbo9iFlSFSVuGLtN5B/+1UeVHy8U7hKYYwtmnoff3Nn5ToZ1C1L+t+p1vtvQcX2A+N8bRpcPQ+s0IT0WQeP91IhbwnsNss9fMcCy1U1iRMzy+ETTsW4P3TrwFM2RHVXPDNKYd5W+Jh4yGDqwxNsj/Nqsw9SLrtUH/ftE89l6VwlgV9HNHMyW2Gg5dJJ/O4HyD/CTOa9pOUcQDqb2f7IahkkrVXd3KPa14YsyTd4YqjKxiqAUac5OrDoEPd98oJa/Nj4T+qb2qcCYf7nZ1myQMDvnbMZk7ZGiK9m59XUIR1h1OJEXDD2oclct49/b3dz0BFWHeNhUKAcDMA/p006P33KnvsV4HNMUY37xUNqQXyo1AODG/JWOWNw9aMccJjnIpxLVjGlrxPy40Fa2A6sqieUGIEGY65rytTRbQnjg4hCxegA8ej0EBKTswa3tpq/bCgWv3NG406DYA7a92UdVgoTHkTgOUe3jTpcfWtYzmYm9qUWapIpPsyyyIJUVao58a4GCUrZHQTp/zqeNtg6XztADlf2+klDIBXsrpIgftst0cE76e+0F8me3EQ773+aTmxu+zfvhSLQSbsiBOWYV8lqZimDIRH23YgF /6uPrEBb VWmoYvXViS5/bSIf2Noi7I9n4RSeJwURkQlZCJC1rgnEX6xOu7S3En9YSMFYzFk9KyYwhoWhuN8GYKnq1a7slrFiy1Ly4mC0zpj0yEpcbU26AJ8qieUA/E83ooLNNWVf0JRTawJCJwgqEY8684heDDY0ROM3zHrPaEccY4g/w7L/j28lKkqJUz506Fh5COBTYbbNmXnWRG3cMuNRXp2Kvh6eZ6HKb+IrJ/8Y3tOkIlIE+x2mVoL1C0F39W8dCySpkAajHj6NV7tj4eyQ= 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: From: Ran Xiaokai Since commit 87eaceb3faa5 ("mm: thp: make deferred split shrinker memcg aware"), the THP deferred split queue is per memcg but not per mem_cgroup_per_node. This has two aspects of impact: Impact1: for kswapd reclaim ===================== kswapd balance_pgdat kswapd_shrink_node shrink_node(pgdat, sc); shrink_node_memcgs(pgdat, sc); shrink_slab(sc->gfp_mask, pgdat->node_id, memcg...); the parameter "pgdat->node_id" does not take effectct for THP deferred_split_shrinker, as the deferred_split_queue of specified memcg is not for a certain numa node but for all the nodes. We want to makes the memcg THP deferred split shrinker aware of node_id. Impact2: thp-deferred_split shrinker debugfs interface ========================================= for the "count" file: the output is acctually the sum of all numa nodes. for the "scan" file: Also the "numa id" input does not take effect here. This patch makes memcg deferred_split_queue per mem_cgroup_per_node so try to conform to semantic logic. Reviewed-by: Lu Zhongjun Signed-off-by: Ran Xiaokai Cc: xu xin Cc: Yang Yang --- include/linux/memcontrol.h | 7 +++---- mm/huge_memory.c | 6 +++--- mm/memcontrol.c | 11 +++++------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 394fd0a887ae..7282861d5a5d 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -130,6 +130,9 @@ struct mem_cgroup_per_node { bool on_tree; struct mem_cgroup *memcg; /* Back pointer, we cannot */ /* use container_of */ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + struct deferred_split deferred_split_queue; +#endif }; struct mem_cgroup_threshold { @@ -327,10 +330,6 @@ struct mem_cgroup { struct list_head event_list; spinlock_t event_list_lock; -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - struct deferred_split deferred_split_queue; -#endif - #ifdef CONFIG_LRU_GEN_WALKS_MMU /* per-memcg mm_struct list */ struct lru_gen_mm_list mm_list; diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 9859aa4f7553..338d071070a6 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -774,7 +774,7 @@ struct deferred_split *get_deferred_split_queue(struct folio *folio) struct pglist_data *pgdat = NODE_DATA(folio_nid(folio)); if (memcg) - return &memcg->deferred_split_queue; + return &memcg->nodeinfo[pgdat->node_id]->deferred_split_queue; else return &pgdat->deferred_split_queue; } @@ -3305,7 +3305,7 @@ static unsigned long deferred_split_count(struct shrinker *shrink, #ifdef CONFIG_MEMCG if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; + ds_queue = &sc->memcg->nodeinfo[sc->nid]->deferred_split_queue; #endif return READ_ONCE(ds_queue->split_queue_len); } @@ -3322,7 +3322,7 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, #ifdef CONFIG_MEMCG if (sc->memcg) - ds_queue = &sc->memcg->deferred_split_queue; + ds_queue = &sc->memcg->nodeinfo[sc->nid]->deferred_split_queue; #endif spin_lock_irqsave(&ds_queue->split_queue_lock, flags); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index fabce2b50c69..cdf9f5fa3b8e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -5445,7 +5445,11 @@ static int alloc_mem_cgroup_per_node_info(struct mem_cgroup *memcg, int node) kfree(pn); return 1; } - +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + spin_lock_init(&pn->deferred_split_queue.split_queue_lock); + INIT_LIST_HEAD(&pn->deferred_split_queue.split_queue); + pn->deferred_split_queue.split_queue_len = 0; +#endif lruvec_init(&pn->lruvec); pn->memcg = memcg; @@ -5545,11 +5549,6 @@ static struct mem_cgroup *mem_cgroup_alloc(struct mem_cgroup *parent) for (i = 0; i < MEMCG_CGWB_FRN_CNT; i++) memcg->cgwb_frn[i].done = __WB_COMPLETION_INIT(&memcg_cgwb_frn_waitq); -#endif -#ifdef CONFIG_TRANSPARENT_HUGEPAGE - spin_lock_init(&memcg->deferred_split_queue.split_queue_lock); - INIT_LIST_HEAD(&memcg->deferred_split_queue.split_queue); - memcg->deferred_split_queue.split_queue_len = 0; #endif lru_gen_init_memcg(memcg); return memcg;