From patchwork Mon Nov 4 21:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13862010 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 2295DD1BDF4 for ; Mon, 4 Nov 2024 21:06:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B4996B00A2; Mon, 4 Nov 2024 16:06:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 53E946B00A3; Mon, 4 Nov 2024 16:06:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F5636B00A4; Mon, 4 Nov 2024 16:06:12 -0500 (EST) 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 078596B00A2 for ; Mon, 4 Nov 2024 16:06:12 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B1A8340910 for ; Mon, 4 Nov 2024 21:06:11 +0000 (UTC) X-FDA: 82749645048.28.06B3A02 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf29.hostedemail.com (Postfix) with ESMTP id 57AB5120021 for ; Mon, 4 Nov 2024 21:05:26 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eKNcimCI; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730754205; 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=gXYh3cqHcJHGeUBg4M162tqHpDf+n9+pJfHXppJVvX8=; b=Y4NcxZPRXFCUc/E4+YM5g69d76o6lI3c7ghtu17NTqPqoKTxBJVtZ+2U1c/OGAuiVHPPIf 6flKJpHzw216yGzHjL0orGK+6XyPENkc//rFAUgNiLTEEM0ws9TU3/Bh56JSs6nkIwKaG4 EA5Ztmlah2LYOahFHZ+p6gLI/irD404= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=eKNcimCI; spf=none (imf29.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730754205; a=rsa-sha256; cv=none; b=X1zFaJ3R1Fi43i2nzJbTi14GiB5k/rMO/+ZyfbjK5V+DGwM18gqOvAXBUAkKiLExLTnj3w xGN8V7Ejy5oJEIN5wbsAMR5q/hTTNsTbjXMTGKcdCVU3LDZkdKgWtaN+HFLIIi23HpJF6H NZuluJFJokiJNWduMSw11eKhF25C/OU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=gXYh3cqHcJHGeUBg4M162tqHpDf+n9+pJfHXppJVvX8=; b=eKNcimCIWz8r8AhbydXdSOF4Bm vjAZ+AnNuSAHBM79pVcg8E3yOWxdhKZdrshxl64iYJae5w7OXaJpvjCZ+GDp/NXiTk/lfgPg+uLLy 9VoOx4HYikCSE8Cr4D39wxYFPf5onfG78FVxRtWXfeIUehak7qAO/SyfLDNDI2tbwqeJpgKpPRq6K BUps+r8AUI3S4B+BlS14v+IHkT/esIZ7hRxJxR77qqLtVp18bSo+jggQWqdmxHdWzgL1MHgPz0GkT QV5uDpMtMh4J+AYwWU5s32vATaIYTsVam9KW63kldO0sFODSr1Z24roYSwLalSZVoY0WwCKjhjMl/ r3a52hdQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1t84Gy-00000001ZYK-0hmI; Mon, 04 Nov 2024 21:06:04 +0000 From: "Matthew Wilcox (Oracle)" To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt Cc: "Matthew Wilcox (Oracle)" , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/3] mm: Opencode split_page_memcg() in __split_huge_page() Date: Mon, 4 Nov 2024 21:05:58 +0000 Message-ID: <20241104210602.374975-2-willy@infradead.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241104210602.374975-1-willy@infradead.org> References: <20241104210602.374975-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 57AB5120021 X-Stat-Signature: a7bfyc4smk8qj13hqtaywbmgokee4i6p X-Rspam-User: X-HE-Tag: 1730754326-639724 X-HE-Meta: U2FsdGVkX1+HI4MSs8nDuI56Vlu5ChT4kILwpG4lnBntdn0EBWA0dpOjl90EzdsytqRMwj0SFE0xVfS8Yldjzlwudtrcq53cThthahutkjGyiYuOHe315Q0E+hy/PJgzTd3F8UsulGeEBTm3mwnlkk9Q2KK8FE2u3m1riHWjkIAX08PVE334evDsTgTLedAUdvSLh6KuI5eok29c6H2nWVE4wD2gPuyDgahvSEnwayJKPtn+hs1+ObniY15nHkD3upH1vQLNmva1/HvJ5ss7SQOp6IB8wf+cSSOZiWph6vg2erWjrMQ/+moa8TL7cEHI4Nb98y1HD7PqdtltlsEcw6odJo0J9RLVzzvdWkExavgMpIqpHmuAdWG+DpgCBcW6n+/LD3KX29lq4sEyCsBpxtu6SP7RK2kYgCuEL1j/LWuoEdkeNZsRe+fBFbPII1f8Dkw1/Fn0ZCMUm6S6VV0ATDledDJbJTdBSgglPWSIJ9d/8IObmmyGb7kbU/5wdqwk2PqxSFr2qC8uJr/Z3aiU046/WnIShVERs56H60MFwNlYPxw8e5STVHRT6V42pDoNgdw6QdmpQhe4KwP5se+TRLD+/uoJNVyfib3wwKvWyriNUsOvrcWNU3jSIYX+nJW0PL7KvqR5PLTnvRrXupxehglIZnDuBMsQYQec+gAJaugIgTapiAUiprB/5k81s3JBUaUKbXtNCdRI+cTzvv3FGk70MCQ/qUMBZ3gAhS4+NvuAf6dANZaKQnCTVUqlT9Yba5ufxef1/zpGala3LJzxW81oN8sUByyJLvy4F+6zbG+S+ZqEuxYScMUvne3F6nbI/ciVvcRGxZcLnd71PcXcmwo/zrzKu7/Omv9fC1pkKUZJ9zOgKp2aQyNjcXDzW43JHCdfnUUs1bufxwjX1/2Crj21xUMSr2XlASFjBLIPBkI6hxftVhPqlEy7CZJttp/Wpgsai+oVmJ0ImYxZyBC YxtvT9ui xCOFt5ClhXaMxlawK6yJX/QQUCvQnEo4yIVGAlxktDjBeMYUI5AoTJhqeDQXDipPnM8cBd5FbmYQt0Kq0bA2+huwRvYkkDXg4TWF8BFwwZOmPTN21xscKAcCHW6u+qLI9tEnAEZ2QCb/1AB+N+ANLSJ31TW3Qa0uViSA21tnPBYUo6/V9FbQCDRWqWXFL9B6Az0jWpjxGzVjOwAs8jJLXdbUhIfkIbKI8zg/ENuigNKSxjPPEvmx6FheL+sLdCPvFofci6rJXJLi+DJDlIk5CLxpKVPq3tV6sqZhH 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: This is in preparation for only handling kmem pages in __split_huge_page(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index f92068864469..44d25a74b611 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -3234,6 +3234,10 @@ static void __split_huge_page_tail(struct folio *folio, int tail, folio_set_large_rmappable(new_folio); } +#ifdef CONFIG_MEMCG + new_folio->memcg_data = folio->memcg_data; +#endif + /* Finally unfreeze refcount. Additional reference from page cache. */ page_ref_unfreeze(page_tail, 1 + ((!folio_test_anon(folio) || folio_test_swapcache(folio)) ? @@ -3267,8 +3271,11 @@ static void __split_huge_page(struct page *page, struct list_head *list, int order = folio_order(folio); unsigned int nr = 1 << order; - /* complete memcg works before add pages to LRU */ - split_page_memcg(head, order, new_order); +#ifdef CONFIG_MEMCG + if (folio_memcg_charged(folio)) + css_get_many(&folio_memcg(folio)->css, + (1 << (order - new_order)) - 1); +#endif if (folio_test_anon(folio) && folio_test_swapcache(folio)) { offset = swap_cache_index(folio->swap);