From patchwork Fri Aug 4 14:54:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 797841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="E01PAE2c"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xP92b45wsz9sRm; Sat, 5 Aug 2017 00:55:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dde0S-0007Py-MU; Fri, 04 Aug 2017 14:55:16 +0000 Received: from mail-qk0-f177.google.com ([209.85.220.177]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dde0C-0007Fu-RA for kernel-team@lists.ubuntu.com; Fri, 04 Aug 2017 14:55:00 +0000 Received: by mail-qk0-f177.google.com with SMTP id d136so10368651qkg.3 for ; Fri, 04 Aug 2017 07:55:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Hw98L6gyajFd50aHc8Rh9ujdXk2Uv6+gDwQsVwDGaqg=; b=E01PAE2cDV64O2wP43zSyonw07LKWvpXDacLSr17inpNAdURkQ63E87lwlVmA4A5zF dW2A940B1MAGu4Mjki+WQI8g2qyEHoR02Ij96tRgr0R9RdSCUhR8+Nuy01Tx8OuNMrM0 DJ1RsRGot3kdofuAU3TLoyzErvYkzEh89TZtseUTuWfNu48ThHi+7MWfvSRGIqYKMp+v BO/Q7EK/tRkJ+PUXUP0B31vwm37SlEbRuYIieCZlg8TGHbQpANsAMkE+ZxiM07yzj85X SeifFgkhTFobubVtXjmVsfQFZxaivHGcSeXqqi0R84NylV4/YiNKnfO0ySq4+/MXZHvt yKmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Hw98L6gyajFd50aHc8Rh9ujdXk2Uv6+gDwQsVwDGaqg=; b=t2kMQmmCNiEcMyxuDVamI4gWhw5dmNweC4ogg20au4rSxbN0RQRz/EN63SIPTkvmll UsvKT+s4d/z5SNT/RPqww/rDU/1Llap3rZRjgQeL6JJaeuNlSLaRpFGKaNWcwt5SZg7Z q2gH9DRDmIXoYx7ArKYdF0UwNNIeDYzaU0XjeDUcwK3bRCjuf144iJ/o5UKlOZkATwir V1yBledONEIciX+wLenB+jrVpFVW4GPYp0VURZuFdXXg7VDA6ATD4IRDuSbwEFVmSxNT ONViQTHqHYafTucIaLI91BmtiWQlBUbCng4HqFdglIR3XbZX3iV/vvwJGJO0M8gUymKL Wlgg== X-Gm-Message-State: AHYfb5jKvGKuBfVN0NpDg1h4RURKSRDal6Ex12Og9yKjd1OsN4AzVTXb fIFLF9xvjjkBD6bcUKc= X-Received: by 10.55.163.212 with SMTP id m203mr3304519qke.332.1501858499667; Fri, 04 Aug 2017 07:54:59 -0700 (PDT) Received: from localhost.localdomain ([191.8.84.147]) by smtp.gmail.com with ESMTPSA id z47sm1194750qth.87.2017.08.04.07.54.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Aug 2017 07:54:58 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [azure][PATCH v1 3/9] Revert "UBUNTU: SAUCE: netvsc: optimize calculation of number of slots" Date: Fri, 4 Aug 2017 11:54:38 -0300 Message-Id: <1501858484-28849-4-git-send-email-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> References: <1501858484-28849-1-git-send-email-marcelo.cerri@canonical.com> Cc: Josh Poulson , Stephen Hemminger X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com BugLink: http://bugs.launchpad.net/bugs/1708469 This reverts commit a0c7595bce2091faff21222bdcfb4e7ebd3a6b5f. The equivalent commit was also reverted in net-next. Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/netvsc_drv.c | 43 +++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 9400839cfb27..1825929db52a 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -322,14 +322,34 @@ static u32 init_page_array(void *hdr, u32 len, struct sk_buff *skb, return slots_used; } -/* Estimate number of page buffers neede to transmit - * Need at most 2 for RNDIS header plus skb body and fragments. - */ -static unsigned int netvsc_get_slots(const struct sk_buff *skb) +static int count_skb_frag_slots(struct sk_buff *skb) +{ + int i, frags = skb_shinfo(skb)->nr_frags; + int pages = 0; + + for (i = 0; i < frags; i++) { + skb_frag_t *frag = skb_shinfo(skb)->frags + i; + unsigned long size = skb_frag_size(frag); + unsigned long offset = frag->page_offset; + + /* Skip unused frames from start of page */ + offset &= ~PAGE_MASK; + pages += PFN_UP(offset + size); + } + return pages; +} + +static int netvsc_get_slots(struct sk_buff *skb) { - return PFN_UP(offset_in_page(skb->data) + skb_headlen(skb)) - + skb_shinfo(skb)->nr_frags - + 2; + char *data = skb->data; + unsigned int offset = offset_in_page(data); + unsigned int len = skb_headlen(skb); + int slots; + int frag_slots; + + slots = DIV_ROUND_UP(offset + len, PAGE_SIZE); + frag_slots = count_skb_frag_slots(skb); + return slots + frag_slots; } static u32 net_checksum_info(struct sk_buff *skb) @@ -367,18 +387,21 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) struct hv_page_buffer page_buf[MAX_PAGE_BUFFER_COUNT]; struct hv_page_buffer *pb = page_buf; - /* We can only transmit MAX_PAGE_BUFFER_COUNT number + /* We will atmost need two pages to describe the rndis + * header. We can only transmit MAX_PAGE_BUFFER_COUNT number * of pages in a single packet. If skb is scattered around * more pages we try linearizing it. */ - num_data_pgs = netvsc_get_slots(skb); + + num_data_pgs = netvsc_get_slots(skb) + 2; + if (unlikely(num_data_pgs > MAX_PAGE_BUFFER_COUNT)) { ++net_device_ctx->eth_stats.tx_scattered; if (skb_linearize(skb)) goto no_memory; - num_data_pgs = netvsc_get_slots(skb); + num_data_pgs = netvsc_get_slots(skb) + 2; if (num_data_pgs > MAX_PAGE_BUFFER_COUNT) { ++net_device_ctx->eth_stats.tx_too_big; goto drop;