From patchwork Wed Jun 5 13:32: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: 13686900 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 3C4BBC27C5E for ; Wed, 5 Jun 2024 13:36:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D3A06B0085; Wed, 5 Jun 2024 09:36:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 00D716B0089; Wed, 5 Jun 2024 09:36:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1E3B6B008A; Wed, 5 Jun 2024 09:36:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C5C1E6B0085 for ; Wed, 5 Jun 2024 09:36:10 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7B7531C2377 for ; Wed, 5 Jun 2024 13:36:10 +0000 (UTC) X-FDA: 82196933700.04.88150EC Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf02.hostedemail.com (Postfix) with ESMTP id 31AC980018 for ; Wed, 5 Jun 2024 13:36:07 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717594568; 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=gby5ITpP6TWrGmqTH4yAqPKsgDsiBOqp0/Ewd8o3zyIcmrmS+FywzA2V42QxQXEIpgR6uE BEk7ybNsbQ06CHucRDKNgigXjmvsUNHSJMOf2fVVTNkWo+oRZm5lXsxWS1di27iOG+05Oz K6y5lScaIdz3sfIhGXok/hJYx+pqFXU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717594568; a=rsa-sha256; cv=none; b=0SM6BmOhe7XJvVh/mM2EayPzDw6udCz1ZGkIYvYWgjX4zmmeMSstSrUccNVmEM/34VB86s ne0XnQYLiKbV+w6nphIE+w4WLULAl49p3w5/gj0fumtPMV+eHgeJoEDAgLaptWOVakTtY1 ZndV66caLYOIbgqZDUlsyy7cd6c6/X8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=pass (imf02.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VvSzQ6mJyzmXlr; Wed, 5 Jun 2024 21:31:30 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 52820180085; Wed, 5 Jun 2024 21:36:04 +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.39; Wed, 5 Jun 2024 21:36:04 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Andrew Morton , Subject: [PATCH net-next v6 03/15] mm: page_frag: use free_unref_page() to free page fragment Date: Wed, 5 Jun 2024 21:32:53 +0800 Message-ID: <20240605133306.11272-4-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240605133306.11272-1-linyunsheng@huawei.com> References: <20240605133306.11272-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500005.china.huawei.com (7.185.36.74) X-Rspam-User: X-Stat-Signature: swysr6rj9gjdo1gqqkx1qtcyw46r55ic X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 31AC980018 X-HE-Tag: 1717594567-146458 X-HE-Meta: U2FsdGVkX1/fV7A6c301AZ6q0UGCQZS3zmfIvQRAbBe4ByjqDI6Bv3CWaIxUF4jTQ7IdQ8kXrj2G89IgXWa6lFgIHtzXsDpc58HQe7qLoK7pmZ+FnT6fEP5I/2bLtHZe3tEr+oZ1BXL1u6leg9hryKxkYFXsdqAcd40vEqHY7jeKDmqYwY8OpJuRrNY4xeqh3M/4fkrF83JERNaEu4cHoXpJPZaVCSy/HS6HDH7+YnPiTe84+UVEFgyULV28QiTG4UZElyRKMmKNGjvRnsZOz4Xi/xiIIZfgZLl83smHRZs4WO9RC3kogdLiluDGKIs78mKl8eGT81aZ4PPJE69+PCTzUDJZ8yqSnY6mCNC7uRuBohC1nUMWoCGjzDU/uyhfixHa9FGGpIucVcXvf8HbFxAORG3vFUsGLqlOEMPwEJr0PCjClb7Fbsf/eAo4qMd2/2UliIXnc5qgO9yUaO9rMy3HdDOOzKLNIeNok3lgFQkaraaUYDXAO09az0ylD5iWzahUF6Dl+XecMjp1xy4cWREjWB7BHGYCC+D2wT5w8QV3aNjReIAcIvtKjt4IMdwuTRa7aMSuPgA1+4IP7mLfqJB1xFedhqab9ZkWJ86AqhP1R/BJGbriLQ/hnIQk25zBUlFFlx40tzrBJqlMT1bNU+nt8T7dnc/1EUVZgNaHg3kV/lOtLmPXLxgbV8IXxV35wbiNh9Pyj+3Snkmv8kp9eGhERsDP1ZkGhoFq3L4e/Q0TMtnGAwZPfyX6yuTw+2xUavxMC4DnDsYmBhugcGEFmBZ0Zt1ecvGRkfiKLW+eJdbovdilpEHVTRYycKflR5a6t9BtQuDZHmo36duEHOm4sWoz8W/K3TJRGw7TQzQ3v/E4SizyVuPH7pCIKWABqsqAxk3AvffMzqlv+8UA7azH0BK5S8kM6t0Phr6eE+C6w3IJWkaYyPENq6CjM84CGnnf+VTfBVs/pnoCGqjdEDK uC5auEdJ dwveAknWVunHARYBMU76Tgmc0INIgDT6rMygK8gmCy3l/SWZw2B2y6fWLsO7ZwaA9TNIfXrwrCZCZ1Ldg+HIT2uGES9g01rNKo+nb8k3wSXAV64I25l/xwDAOX23TuAyQ8/f/vxzTag/qHdxQWyc2OtR+p3RqtJ3VN3N2qH+06x607ly7inOLYoYRic+oQz3gxl1H6+HVdFJKFDeyYssqZmB2OuxTF9n9iFVBi1l4xyyWSRhOSlyoFBzcx0uYYZZznmzpqBNeL5HUGmMN7iYdIDn8xYcJ477e8imq 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,