From patchwork Tue Dec 5 11:34:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13480076 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 D0E7EC4167B for ; Tue, 5 Dec 2023 11:35:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6313D6B0085; Tue, 5 Dec 2023 06:35:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 590766B0089; Tue, 5 Dec 2023 06:35:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3BD3B6B0085; Tue, 5 Dec 2023 06:35:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 236806B0085 for ; Tue, 5 Dec 2023 06:35:01 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 035C5A0343 for ; Tue, 5 Dec 2023 11:35:00 +0000 (UTC) X-FDA: 81532558002.23.A323660 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf04.hostedemail.com (Postfix) with ESMTP id 2E7584001C for ; Tue, 5 Dec 2023 11:34:56 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=none; spf=pass (imf04.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=1701776099; 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=3B5fwC9qERbgCOX4tFw3OYiISGUMa0xw9VoqY6py2PY=; b=FvSVc4v2ayzCF1yx3SEA8Tnkp4MQPLz6KJ7/bl4P+ghEf386nFL+sWICGU2Tnc4BY2vBbi XCvk6wpw6yFCkf/G4e+Na3ch3bzDCLbl0LR6a4l9qStK0p2dLZJgU9sBI3zuJzhhox12TQ d8gdORv4ffoJ0Hr8+Djjehr56lq/Wz8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701776099; a=rsa-sha256; cv=none; b=1tlllkS9m5EiOeYvPhzLeehyCbbMkoUE31vMLJlzm7M7Ne+EVy+UnofistjalZFCvj6Qte 1x8yZ9xHTYbZUx9C24SzT0fBK2physJGw8V9AjozjxiZsebQxUQtNryP8wG9GKI76cVfRx vRyy9gzbtnwywFK5+a0jvvf8qpo+VRA= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=none; spf=pass (imf04.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 dggpemm500005.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Skz2G66sczWjJk; Tue, 5 Dec 2023 19:33:58 +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, 5 Dec 2023 19:34:51 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , "Michael S. Tsirkin" , Jason Wang , Andrew Morton , Eric Dumazet , , , Subject: [PATCH net-next 2/6] page_frag: unify gfp bit for order 3 page allocation Date: Tue, 5 Dec 2023 19:34:40 +0800 Message-ID: <20231205113444.63015-3-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20231205113444.63015-1-linyunsheng@huawei.com> References: <20231205113444.63015-1-linyunsheng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500005.china.huawei.com (7.185.36.74) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2E7584001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: sk37nd6hf6qk87zufmqtfbtahzjyarri X-HE-Tag: 1701776096-88860 X-HE-Meta: U2FsdGVkX18n8lgzYHVr68k1nLG0AhzbQrG65t+mVB62x/7ilBJNyQt5whpp9COjuSCtmQEHxah7B0OGsKyiV9iqSK+ORt6rQZL6rU0rSBs6/1UyaHBILMpFa3pOvEHV5l431ZnU6P+atYRbqKQ2uSY96q6Vb1+HpVyOkJocKeXzdYcpxrYiHuHyCwTlTNCC8qXVzfMrlKYbzcKB72ivq1966NShCZCX0k8IJO+UXPbFrSvoslaN7URqaCEFRGYEKIgWYbmkw9p8g/Q3KgyCHTH1Bcr7iNxmCFhCbJ46UdsqGTyxlJtDPHblCo3BZColWADMyet5X+G1bq0DcjnHxxChAtWXPejlPLj8R+mJMf8d4asNAJ1ItoW99+Roj9/x0WFSQqNaqUoDiX4DZQoMpdMw0vgdiYIFJYuVZzlScOXvGGKFXBpm/MNeGz088Xh5enQHDVHVm8I+NLljRb9CArxy07tpn4mKznlfeEy2s56GDFd24JOi1RNggR+vDOTf6KJ0fZfia2IBky5g0j6RlUj+mdD0LUANmmh+MJ7/aHURJk4C/TRxFvrUnhdXz2PQ7M8apGfsKM6u/VsYQyu0zI2y9v3445PxqoHC7VVkNDYQSMowY0NE74hYDPCKJ1ejmoWNutXOGqF2orIIsI5GIJYV1jS6EB4wD7nJveNk+TusgRk9+wh9y7zw/TfwxAK2CQM17a7r3iDwFqGOX9T9HiONDNGR7tv1S9v9hDmZ9WAqbI/AtwAtOGmX9YmXmjFB15bT5UsOiemYSl4sLcIi0+Gi14Sz9nB88la5bMsX0eWsPQ2tSUIwdWgb6AJSsXQcm2Z8fGrRqb3gw3rwVoN6gLMxakufKo4wX7yEoBXLJYKwLDmf1ALy+FrA+Z3znHeZoO57adAE1DYXsZroPiKml1XcwDRuuE9JLcP8ZP8PNAxA+TdbZk1ULYp+0P2pjSZ+uQmaefEIc4bWeMTxeEl AyGfeWBj 8zz4CXDzKyTLuTmY12UcuIhDTIQ1lE0asDsTyiUSbHSKjkKGiJgXikBTvGOItA4gaWYlKsQ/2T4d2XEuv8fvM8G13Z+ELEw/dzqpFgHlAHudAilDxW5IocWzKhj260rzHxDVaiy32k+q+j7aeAc/MPmqRsou7FVvPuIJ3HLSOWXRe1Pj8kmUDHmZEfXRCVlVjbvNQfYdWuh+90g6V/5urfT+DnFAjaOUGefWxNQY9vcKImlmI3KuQlwh+HSmu0rVIrPECCy14Ia+/pxPOcfzOjxNxVDhNAc16p8Bg 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 xor'd to avoid direct reclaim in skb_page_frag_refill(), but it is not xor'd in __page_frag_cache_refill(). This patch unifies the gfp bits used between different implementions by or'ing __GFP_NOMEMALLOC and xor'ing __GFP_DIRECT_RECLAIM for order 3 page allocation to avoid possible pressure for mm. Signed-off-by: Yunsheng Lin 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 9a16305cf985..1f0b36dd81b5 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4693,8 +4693,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 fef349dd72fa..4efa9cae4b0d 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2904,7 +2904,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;