Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1438629lqp; Mon, 15 Apr 2024 06:44:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLP8EkG0PUkuxig1YTxqxXY9XdipU4soaJ3wytlx5fZMvvwwTay04mENKPt9Us7xLaz1n1aT6wv8wwTVYiDGo+Q+OIxVEMcA55kQ8L2g== X-Google-Smtp-Source: AGHT+IFichqTjQbhw+MmXXCyVbnS14K12XAwOFRb9A/ovHUIEhtav16Z96jPhaSNi22fUZyV4iPE X-Received: by 2002:a17:903:249:b0:1dd:de1a:bd02 with SMTP id j9-20020a170903024900b001ddde1abd02mr9397254plh.41.1713188665450; Mon, 15 Apr 2024 06:44:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713188665; cv=pass; d=google.com; s=arc-20160816; b=mElJlLofRgR2Cp+xioK17awzarnUxCBEhJUKnf9+OXiR5v0KzymhTljsLwoFTUURDc zGGvtZQ8iSi4tMUXXclkJ5IWRtIDYTtTg+VSz6reD9DTdBukuuHRspw8jRxlfx+pt7/5 rXGsJloSfSWc9SnHYhL/20gFvV0RAWMW8X+xZk2DusToqhWqC753cnD0yKuVfTKTNSMy P/PJvsiUx0J/XrkZAKi2ryRoT0tkGEmfoY/WfhEnZ69VwTY1TmYZnx6DOVJ8de9E4YcV P65UmK6Hpp/AOBAY1wgOLcTRdHnSTrd5XiA/ZiA+6By5vH6U67DRKTFhtxVnUrRHpRHt RQcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=zeduTcCDg526cCCJK/3xfYqN0ch44Yy/ybdxwM27+Wk=; fh=inFsbniLgByi1PvLyextVSu1v80SuS19K1zpiR/HfaU=; b=pU75l1zBouhtljrB2fJLaPK5d2+tg1BVNxJlos1MdY8RdfFrR9z/vG52wdV2b0eqNE doZXqFSXoUAs/3qAnfYUH7pnXPc4ox6JqopgdysXYWt7s6ecRpRHHZK+p1F3tgKGzy/v IJAw0lNPGFBror42fDVeB6+GbTWWT+sUd0CB4+vvHaVZLzdV8e07433C1KhWoEYzAqfu d3OhuV05Xu0mZD5tpFbIPtcK3ua6in68lgpR4usgyM/2CZtpNyWfmwzMzjivGvrj77W9 GGsEItBymmprXo8cz56/NOX/uTcj7hOGqKcgteGQJCwe9LoMAcLMfd+JBq71KUZ170vG zmxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-145242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id iw20-20020a170903045400b001e2ad612671si7498238plb.348.2024.04.15.06.44.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:44:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-145242-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145242-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 12F0EB226D8 for ; Mon, 15 Apr 2024 13:30:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C8238627A; Mon, 15 Apr 2024 13:22:02 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EDA685C59; Mon, 15 Apr 2024 13:21:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713187322; cv=none; b=sDyaeNa2XxumXLZhPOByhi0ze6X7/k59yVPtMrFoLmxMGUbKz+4BguiMO02LNaug8t0czq6MJ1QCsxLO3F76bLzR9o2c2W1EqIfvKJDSXQbBTfoFI6kfmK+xeWZw5PCYJQYtALeCwAG3rnSFL2x2rQ41SE85olfQPR0I8EK7BKc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713187322; c=relaxed/simple; bh=I+PxcFJRuWmvRj/gpe7p1XbRfGzapGnSkEHSqckN7LY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HbQY7zfirM+ndR1ODK+3Mz28fidI6m4Zh7cpF/2/f9QaW0gFIJr/lQNKuj/AlE7oDIWQxgdqLShbrIZqBkAyrVIOGHKZ7zsWSs8x0wSdCEv0cHWY1e4KriiYUbMFnEyDHQEMTMeU7imL69aHr317Fr5VAj3L4EIcr9p+7hE04jw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VJ76X1L9Kz2CcLb; Mon, 15 Apr 2024 21:19:00 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 98FE71403D1; Mon, 15 Apr 2024 21:21:56 +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; Mon, 15 Apr 2024 21:21:56 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Andrew Morton , Subject: [PATCH net-next v2 03/15] mm: page_frag: use free_unref_page() to free page fragment Date: Mon, 15 Apr 2024 21:19:28 +0800 Message-ID: <20240415131941.51153-4-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240415131941.51153-1-linyunsheng@huawei.com> References: <20240415131941.51153-1-linyunsheng@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500005.china.huawei.com (7.185.36.74) 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. Signed-off-by: Yunsheng Lin --- mm/page_alloc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 14d39f34d336..7adb29f8f364 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4693,6 +4693,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, @@ -4722,7 +4725,7 @@ void __page_frag_cache_drain(struct page *page, unsigned int count) VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); if (page_ref_sub_and_test(page, count)) - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); } EXPORT_SYMBOL(__page_frag_cache_drain); @@ -4763,7 +4766,7 @@ void *__page_frag_alloc_align(struct page_frag_cache *nc, goto refill; if (unlikely(nc->pfmemalloc)) { - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); goto refill; } @@ -4807,7 +4810,7 @@ void page_frag_free(void *addr) struct page *page = virt_to_head_page(addr); if (unlikely(put_page_testzero(page))) - free_the_page(page, compound_order(page)); + free_unref_page(page, compound_order(page)); } EXPORT_SYMBOL(page_frag_free); -- 2.33.0