From patchwork Tue Jan 23 10:42:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13527215 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 73088C47DDB for ; Tue, 23 Jan 2024 10:44:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A5506B007E; Tue, 23 Jan 2024 05:44:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 02F726B0080; Tue, 23 Jan 2024 05:44:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E11F96B0081; Tue, 23 Jan 2024 05:44:09 -0500 (EST) 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 D1FB76B007E for ; Tue, 23 Jan 2024 05:44:09 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7954E1A0229 for ; Tue, 23 Jan 2024 10:44:09 +0000 (UTC) X-FDA: 81710241018.14.06BA2F3 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf07.hostedemail.com (Postfix) with ESMTP id 1E5BE4000B for ; Tue, 23 Jan 2024 10:44:06 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 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=1706006647; 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=jf0l1UYva5auP6nYlKrgu67I0vTDR0VmH+NorAnif7E=; b=I1FTOTkO4xVbAMZVzKFsdtrajZLPNueS3LB6P8z67jppwrinXnyfKtK4PFxot+Gnfx5ikX NdbdYrbvdXzE61pC7CC5KVgspQghU1GVHPo8kh0ISWmxjKM4CeTKI6tfQ26PuOQhn4xeho RLwA1BYopRDwEJxzuF7CVwagekV450g= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf07.hostedemail.com: domain of linyunsheng@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=linyunsheng@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706006647; a=rsa-sha256; cv=none; b=cppr4df/D6Oq83xbajOCPkHS10H6vbNYT4RqZBd67elQRIrpFhXUbyH6hT/eanYk2dEcVB LcXanas0D5bIWdqkZcOHdvkKdUy2BzA2e7QzrpRBbo44qfA9JkqQKV59uNkZBO913rWzuI ORPK6Wxq6pkB1E5tis1hmNtiERz8n1U= Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4TK3Z422B9z29kHr; Tue, 23 Jan 2024 18:42:20 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id B05A8140153; Tue, 23 Jan 2024 18:43:48 +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_128_GCM_SHA256) id 15.1.2507.35; Tue, 23 Jan 2024 18:43:35 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Alexander Duyck , "Michael S. Tsirkin" , Jason Wang , Andrew Morton , Eric Dumazet , , , Subject: [PATCH net-next v3 2/5] page_frag: unify gfp bits for order 3 page allocation Date: Tue, 23 Jan 2024 18:42:47 +0800 Message-ID: <20240123104250.9103-3-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240123104250.9103-1-linyunsheng@huawei.com> References: <20240123104250.9103-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-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1E5BE4000B X-Stat-Signature: 5ye83w6bk84gcncsnniiwfc5pm97swqk X-HE-Tag: 1706006646-579354 X-HE-Meta: U2FsdGVkX180t0YC2Ovq1SUS925zaeJ1u3sEA/tmuLzlI5wyB4AvZvBV8ZDCNWR25Sbxd66lVg3IYpAEZg2rg2ZK8IEyNgkbcSroEE//l4ZWKXKwe+VdVMdKwyXVJ0mewBtEup1B+mC4VWpHWdcEJnlgZ6b1MVbLgWsXaZDYSLVVXIQ1cIvLR3akY+ycGrGMA/pVRidt5vnhmqRXrcUIr+DzoT8LKOAmw7XECCoYiFJV6OcTNNPUQOnp1bvq2jXlEQuOAvMCefvTy47+XMnT4wsZNGxB2FbBKioaMWv6CC6bCmOndBxPbQkSZftv+fcV5gFMqz5Ms1KQkbCJmh/NOwFrytyNgSP2V6ry+pnAVfKxVDLCzjtmWCU8Qrxz+yjUiOjBnrmbuVFilGvQ4wbn2OJtrSyb2kCE85qxQxI7z8VCb1V2b4CROYxAG61vlMLz6l7SYR80VXhy8R4vSgrin/xaDOx0EhBYC4fyd3bQ9Mi1Z7ejhwGLELY5OflzvUkV9BJkjI41pCYJdxOOFPHPgMbg+75hReAbBU0I2EDV6zlN7OyD8Cv4MgIN8n9RRfQWuOcrtF5El36vwTx/JcnGkd95xymE4SlNoX8wYXruU4v4wB82jXa2O2DUbbgGcrptM3+UqwRoEGLXFHBQZ9Jx1w2B/BFrRo/+HnIfBwZkFbIGGztqFb7Da2+AH3wOHKhwySkyhovriAl3FR9t4ZfFYp4L/pjWigUyWxcQtmBsibNBtkRXkFUV1GtuWGvO3hZWMYCv2pS/egU8GAJf1eXp0lS7AQgP+P6HFJrU9BaO6FIyZhQQDxhL38r23GExwEZUJTI1S+OvQzw0sgGbCvkmnCbLMd9iEh6ZTzlouLd3gdno6ZcnRweN1hpvazi4+WVv/UmJ4wZAF9vXedmvZMD7BA2gqBkAUONzBHOmwiBW/U0QloXUrntXzwxtwG3+4S5RzD8trBe47KiQI3Rq/sW T70rbFGJ 89eXkPeMn8VkxrsIpLeO1qNoJHmofbbLT2k2cpqMt9mwHZyULQTMFlOrsTkRsB/8Wdlq8LxxR8CrZuMo46fF7iG9eQ8U+tYnRwX4MO6Ob0CFP9fxk5iW9IU4E8AVVM77fRlRZV0E3pLIwRqw2s6gqml2bbo04A4mz6aVs/m2JkOer2dgYXQvUgNBb3Gy5MaT8nSS3g0732fqAXuH4QZRWENeyWb3YVvGNxBbJCgdMraIQg3LCq7JrshKL3Bf8iQaNniVmBObx1PmG0LZ4R5b9WKujKkqaquynFhjAl0pJgVrQKPjFByBe0ffZU5JnIQX80gIddibr69iTLmaXc6tBnSn8f+Jj72mIuqpb 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: Currently there seems to be three page frag implementions which all try to allocate order 3 page, if that fails, it then fail back to allocate order 0 page, and each of them all allow order 3 page allocation to fail under certain condition by using specific gfp bits. The gfp bits for order 3 page allocation are different between different implementation, __GFP_NOMEMALLOC is or'd to forbid access to emergency reserves memory for __page_frag_cache_refill(), but it is not or'd in other implementions, __GFP_DIRECT_RECLAIM is masked off to avoid direct reclaim in skb_page_frag_refill(), but it is not masked off in __page_frag_cache_refill(). This patch unifies the gfp bits used between different implementions by or'ing __GFP_NOMEMALLOC and masking off __GFP_DIRECT_RECLAIM for order 3 page allocation to avoid possible pressure for mm. Signed-off-by: Yunsheng Lin Reviewed-by: Alexander Duyck CC: Alexander Duyck --- drivers/vhost/net.c | 2 +- mm/page_alloc.c | 4 ++-- net/core/sock.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index f2ed7167c848..e574e21cc0ca 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -670,7 +670,7 @@ static bool vhost_net_page_frag_refill(struct vhost_net *net, unsigned int sz, /* Avoid direct reclaim but allow kswapd to wake */ pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | __GFP_COMP | __GFP_NOWARN | - __GFP_NORETRY, + __GFP_NORETRY | __GFP_NOMEMALLOC, SKB_FRAG_PAGE_ORDER); if (likely(pfrag->page)) { pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c0f7e67c4250..636145c29f70 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4685,8 +4685,8 @@ 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) - gfp_mask |= __GFP_COMP | __GFP_NOWARN | __GFP_NORETRY | - __GFP_NOMEMALLOC; + gfp_mask = (gfp_mask & ~__GFP_DIRECT_RECLAIM) | __GFP_COMP | + __GFP_NOWARN | __GFP_NORETRY | __GFP_NOMEMALLOC; page = alloc_pages_node(NUMA_NO_NODE, gfp_mask, PAGE_FRAG_CACHE_MAX_ORDER); nc->size = page ? PAGE_FRAG_CACHE_MAX_SIZE : PAGE_SIZE; diff --git a/net/core/sock.c b/net/core/sock.c index 158dbdebce6a..d4bc4269d7d7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2908,7 +2908,7 @@ bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t gfp) /* Avoid direct reclaim but allow kswapd to wake */ pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) | __GFP_COMP | __GFP_NOWARN | - __GFP_NORETRY, + __GFP_NORETRY | __GFP_NOMEMALLOC, SKB_FRAG_PAGE_ORDER); if (likely(pfrag->page)) { pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER;