Netdev List
 help / color / mirror / Atom feed
From: Li RongQing <lirongqing@baidu.com>
To: netdev@vger.kernel.org, jasowang@redhat.com
Subject: [PATCH][net-next] vhost:net: allocate 32KB memory instead of 32K pages when page frag refill
Date: Fri, 23 Nov 2018 10:04:39 +0800	[thread overview]
Message-ID: <1542938679-19837-1-git-send-email-lirongqing@baidu.com> (raw)

when page frag refills, 32K pages, 128MB memory is asked, it
hardly successes when system has memory stress

And such large memory size will cause the underflow of reference
bias, and make refcount of page chaos, since reference bias will
be decreased to negative before the allocated memory is used up

so 32KB memory is safe choice, meanwhile, remove a unnecessary
check

Fixes: e4dab1e6ea64 ("vhost_net: mitigate page reference counting during page frag refill")
Signed-off-by: Zhang Yu <zhangyu31@baidu.com>
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/vhost/net.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index d919284f103b..b933a4a8e4ba 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -641,7 +641,7 @@ static bool tx_can_batch(struct vhost_virtqueue *vq, size_t total_len)
 	       !vhost_vq_avail_empty(vq->dev, vq);
 }
 
-#define SKB_FRAG_PAGE_ORDER     get_order(32768)
+#define SKB_FRAG_PAGE_ORDER    3
 
 static bool vhost_net_page_frag_refill(struct vhost_net *net, unsigned int sz,
 				       struct page_frag *pfrag, gfp_t gfp)
@@ -654,17 +654,17 @@ static bool vhost_net_page_frag_refill(struct vhost_net *net, unsigned int sz,
 
 	pfrag->offset = 0;
 	net->refcnt_bias = 0;
-	if (SKB_FRAG_PAGE_ORDER) {
-		/* Avoid direct reclaim but allow kswapd to wake */
-		pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) |
-					  __GFP_COMP | __GFP_NOWARN |
-					  __GFP_NORETRY,
-					  SKB_FRAG_PAGE_ORDER);
-		if (likely(pfrag->page)) {
-			pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER;
-			goto done;
-		}
+
+	/* Avoid direct reclaim but allow kswapd to wake */
+	pfrag->page = alloc_pages((gfp & ~__GFP_DIRECT_RECLAIM) |
+				  __GFP_COMP | __GFP_NOWARN |
+				  __GFP_NORETRY,
+				  SKB_FRAG_PAGE_ORDER);
+	if (likely(pfrag->page)) {
+		pfrag->size = PAGE_SIZE << SKB_FRAG_PAGE_ORDER;
+		goto done;
 	}
+
 	pfrag->page = alloc_page(gfp);
 	if (likely(pfrag->page)) {
 		pfrag->size = PAGE_SIZE;
-- 
2.16.2

             reply	other threads:[~2018-11-23 12:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-23  2:04 Li RongQing [this message]
2018-11-23  2:30 ` [PATCH][net-next] vhost:net: allocate 32KB memory instead of 32K pages when page frag refill Jason Wang
2018-11-23  2:41   ` 答复: " Li,Rongqing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1542938679-19837-1-git-send-email-lirongqing@baidu.com \
    --to=lirongqing@baidu.com \
    --cc=jasowang@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox