From patchwork Tue May 28 12:55:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13676631 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 810ABC25B78 for ; Tue, 28 May 2024 12:58:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F05E46B0092; Tue, 28 May 2024 08:58:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB5556B0095; Tue, 28 May 2024 08:58:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA4846B0098; Tue, 28 May 2024 08:58:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id BE7D16B0092 for ; Tue, 28 May 2024 08:58:58 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 17E9B80308 for ; Tue, 28 May 2024 12:58:58 +0000 (UTC) X-FDA: 82167809556.08.40642CF Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf05.hostedemail.com (Postfix) with ESMTP id BEA0E100013 for ; Tue, 28 May 2024 12:58:55 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716901136; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9HN8cRj40Iu8RSEwpFttnmunyuNRfYQ9Oos9G3z5jqA=; b=Bw7+ywi2Ty+gwmjg2am5QWfM3S09MTOCK70/PfW+R+DLAUvs9S3IPMAX2FA6hM5w/NKpdL SRmA0zMS0vMRxqMnLpianrIWgQJ3Giwyl+F/QK/fYUPw8Ef8tSrV2nchnkcb8qQvn4Rlgm 6LgoP86WtxO9+OCcDMu7tIYDTv1D6Ys= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716901136; a=rsa-sha256; cv=none; b=HCZT9rkFZdkWhjuMDmUc3lejfDM99rAwBtHW06CAQBehy0KPdSrPivQtaw9b43HHdNSAXW +zGmdy+VzSJeeeTV0vnnMhctDz90omZgSUiMJKbvT3N255KRUj2AU2Xarq2Iju0suAX4xU 4rsCMcj11oizmAztoZ7N8TWumBVyPgE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf05.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VpXbv50f7zckPt; Tue, 28 May 2024 20:57:31 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 25C4A1400D1; Tue, 28 May 2024 20:58:52 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 28 May 2024 20:58:51 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Subject: [PATCH net-next v5 03/13] mm: page_frag: use free_unref_page() to free page fragment Date: Tue, 28 May 2024 20:55:53 +0800 Message-ID: <20240528125604.63048-4-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240528125604.63048-1-linyunsheng@huawei.com> References: <20240528125604.63048-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500005.china.huawei.com (7.185.36.74) X-Stat-Signature: st9e15h57yf9npghwsoc3bgfmqrxhcsk X-Rspamd-Queue-Id: BEA0E100013 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716901135-68850 X-HE-Meta: U2FsdGVkX19qMDBu8Ues3kJsW7MVmdY7S64kibqkBEOKWAFBkUKJIazluhrISKDKiy6OFguZJxzr6EKcMa8ESJg+0BKi0w1TVA3Prs3Ue5HBROhZ8XCn6eE0vObcHxDCR2lvjZjBikQkwtECwJ2vYJ2+sHsc/1zGtiYKV8VuTAt+4TNz/lRhBl1moBVt7UJVKfhqk20vqZbM5kpt5UJ0v7m8y0GTJ/60OSP8k1Zp482tF+wQzXD6A1p0HOpwn/WncJ8gFNCLBnCqAYstoRCrmZ5LEAUW1z4Raqs0mMD+MhwJmdCbsWdZSTuMVH/fVOgvcC0OVT+HDGD98/QbOAMjhEh2MmOF2CWwg/xWXCB8xkuufz6OgfqsdrWCAPBrtZhHUbJkZhwZyTzr3hcI5uUOPoK1wPD9TIVP+ufQ0XsIzTEfvzXJn3Qn0eJBvovqJHysZa31rrpbrygpIYEwHmFXbQdsy5uhcTP4JQ8Z1YbhRO9tNCcASAruy5867no0BKrIbCSx3NygppKb8RehSRdiptlajEeaJkq4GYSKkhJVHG0HQChNggjkonHIRq0isqW23Ly+VNRZdqsV8tdvB5vHiZmnw2k9NTkAwbrpn+0qNuuUQcKa2HztmhRxgtjVgpohTzqhanjQQzslMS+avYQXYzsGWSN9RKMttIZb0gJaSqBV31+lsVn31YytOTJxUzkMifXcgD0GsIUDZIoKdjC7WQv6TkZTi4J29idJiHg3mUeI03imt6CUXF7Iild7YfN+d74bdDSMfCpF3ZoaRJjaBgDMOlWqIk16fkqB9F0ey5hY8BhY5Y7076iGYBLg6Skfg5e7zVp+qSrvYSdZ58kcnzuBFhUGY6u+c4D2mBq80bhJannYgQJiMfQWm/vNY2CbhkwL/KdJaHTG7sTyKhw+5TFlfShCbRAcJG15Kgqms2jIamrn9onH+nZ8W9RMYSD55vNp1oLHNgTlNBVFWQ7 erZElSAD 8MZZ6/T2BCJmJy9+eBbWut9llwV+XumDm4uWU+fTvUXWFRd7rgndMSWXSNW7A7XRMsKaM84kJlq8CMHWVpETzg9Tzb/40UPWzPVcWjKaI4GsAHvZq7SMZKC34QUaplrcAGPxoOi8BYJqEuRJ+Whbi8+9Yi5ThNia1uQaWrS+GqQYCN9jEcZN9UDL5jkyIng8RHjAJwyzDDFUMwQfGj8QXe2cLhlc/DI9qG+kmXZO/nPZx1/EC7KAiMGqeQlRr/5n2WYMIV4w5qlrG4ofgFNF5SgLtITXwPqEym17+ 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: free_the_page() used by page_frag call free_unref_page() or __free_pages_ok() depending on pcp_allowed_order(), as the max order of page allocated for page_frag is 3, the checking in pcp_allowed_order() is unnecessary. So call free_unref_page() directly to free a page_frag page to aovid the unnecessary checking. As the free_the_page() is a static function in page_alloc.c, using the new one also allow moving page_frag related code to a new file in the next patch. CC: Alexander Duyck Signed-off-by: Yunsheng Lin --- mm/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 2e22ce5675ca..0511c30bc265 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4781,6 +4781,9 @@ static struct page *__page_frag_cache_refill(struct page_frag_cache *nc, gfp_t gfp = gfp_mask; #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE) + /* Ensure free_unref_page() can be used to free the page fragment */ + BUILD_BUG_ON(PAGE_FRAG_CACHE_MAX_ORDER > PAGE_ALLOC_COSTLY_ORDER); + gfp_mask = (gfp_mask & ~__GFP_DIRECT_RECLAIM) | __GFP_COMP | __GFP_NOWARN | __GFP_NORETRY | __GFP_NOMEMALLOC; page = alloc_pages_node(NUMA_NO_NODE, gfp_mask,