Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1041527/?format=api
{ "id": 1041527, "url": "http://patchwork.ozlabs.org/api/patches/1041527/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190213185115.25877-7-anirudh.venkataramanan@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20190213185115.25877-7-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2019-02-13T18:51:06", "name": "[S14,06/15] ice: Limit the ice_add_rx_frag to frag addition", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "3a92be8013ef5059713ab8435457b10aa42e509f", "submitter": { "id": 73601, "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api", "name": "Anirudh Venkataramanan", "email": "anirudh.venkataramanan@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190213185115.25877-7-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 91786, "url": "http://patchwork.ozlabs.org/api/series/91786/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=91786", "date": "2019-02-13T18:51:02", "name": "Implementation updates for ice", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/91786/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1041527/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1041527/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.133; helo=hemlock.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 4407w524LKz9s2P\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 14 Feb 2019 05:53:41 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id D261986A14;\n\tWed, 13 Feb 2019 18:53:39 +0000 (UTC)", "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id sM0HkiNf2Ybe; Wed, 13 Feb 2019 18:53:34 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 877B986A07;\n\tWed, 13 Feb 2019 18:53:34 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 059271BF988\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Feb 2019 18:51:19 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id F342622C44\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Feb 2019 18:51:18 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id XMegPmcJxCOp for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Feb 2019 18:51:17 +0000 (UTC)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 8DBDB22CB0\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 13 Feb 2019 18:51:17 +0000 (UTC)", "from orsmga001.jf.intel.com ([10.7.209.18])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t13 Feb 2019 10:51:17 -0800", "from shasta.jf.intel.com ([10.166.241.11])\n\tby orsmga001.jf.intel.com with ESMTP; 13 Feb 2019 10:51:16 -0800" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.58,366,1544515200\"; d=\"scan'208\";a=\"138354238\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Wed, 13 Feb 2019 10:51:06 -0800", "Message-Id": "<20190213185115.25877-7-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.14.5", "In-Reply-To": "<20190213185115.25877-1-anirudh.venkataramanan@intel.com>", "References": "<20190213185115.25877-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH S14 06/15] ice: Limit the ice_add_rx_frag\n\tto frag addition", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>\n\nRefactor ice_fetch_rx_buf and ice_add_rx_frag in a way that we have\nstandalone functions that do either the skb construction or frag\naddition to previously constructed skb.\n\nThe skb handling between rx_bufs is spread among various functions. The\nice_get_rx_buf will retrieve the skb pointer from rx_buf and if it is a\nNULL pointer then we do the ice_construct_skb, otherwise we add a frag\nto the current skb via ice_add_rx_frag. Then, on the ice_put_rx_buf the\nskb pointer that belongs to rx_buf will be cleared. Moving further, if\nthe current frame is not EOP frame we assign the current skb to the\nrx_buf that is pointed by updated next_to_clean indicator.\n\nWhat is more during the buffer reuse let's assign each member of\nice_rx_buf individually so we avoid the unnecessary copy of skb.\n\nLast but not least, this logic split will allow us for better code reuse\nwhen adding a support for build_skb.\n\nSigned-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> cleaned up commit message]\n---\n drivers/net/ethernet/intel/ice/ice_txrx.c | 160 +++++++++++++++---------------\n 1 file changed, 79 insertions(+), 81 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c\nindex 0eb594abe6ef..aaa29ac18cdb 100644\n--- a/drivers/net/ethernet/intel/ice/ice_txrx.c\n+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c\n@@ -563,63 +563,29 @@ static bool ice_can_reuse_rx_page(struct ice_rx_buf *rx_buf)\n }\n \n /**\n- * ice_add_rx_frag - Add contents of Rx buffer to sk_buff\n+ * ice_add_rx_frag - Add contents of Rx buffer to sk_buff as a frag\n * @rx_buf: buffer containing page to add\n- * @skb: sk_buf to place the data into\n- * @size: the length of the packet\n+ * @skb: sk_buff to place the data into\n+ * @size: packet length from rx_desc\n *\n * This function will add the data contained in rx_buf->page to the skb.\n- * This is done either through a direct copy if the data in the buffer is\n- * less than the skb header size, otherwise it will just attach the page as\n- * a frag to the skb.\n- *\n- * The function will then update the page offset\n+ * It will just attach the page as a frag to the skb.\n+ * The function will then update the page offset.\n */\n static void\n ice_add_rx_frag(struct ice_rx_buf *rx_buf, struct sk_buff *skb,\n \t\tunsigned int size)\n {\n-#if (PAGE_SIZE < 8192)\n-\tunsigned int truesize = ICE_RXBUF_2048;\n+#if (PAGE_SIZE >= 8192)\n+\tunsigned int truesize = SKB_DATA_ALIGN(size);\n #else\n-\tunsigned int truesize = ALIGN(size, L1_CACHE_BYTES);\n-#endif /* PAGE_SIZE < 8192) */\n-\tstruct page *page = rx_buf->page;\n-\tunsigned int pull_len;\n-\tunsigned char *va;\n-\n-\tva = page_address(page) + rx_buf->page_offset;\n-\tif (unlikely(skb_is_nonlinear(skb)))\n-\t\tgoto add_tail_frag;\n-\n-\t/* will the data fit in the skb we allocated? if so, just\n-\t * copy it as it is pretty small anyway\n-\t */\n-\tif (size <= ICE_RX_HDR_SIZE) {\n-\t\tmemcpy(__skb_put(skb, size), va, ALIGN(size, sizeof(long)));\n-\n-\t\trx_buf->pagecnt_bias++;\n-\t\treturn;\n-\t}\n-\n-\t/* we need the header to contain the greater of either ETH_HLEN or\n-\t * 60 bytes if the skb->len is less than 60 for skb_pad.\n-\t */\n-\tpull_len = eth_get_headlen(va, ICE_RX_HDR_SIZE);\n-\n-\t/* align pull length to size of long to optimize memcpy performance */\n-\tmemcpy(__skb_put(skb, pull_len), va, ALIGN(pull_len, sizeof(long)));\n+\tunsigned int truesize = ICE_RXBUF_2048;\n+#endif\n \n-\t/* the header from the frame that we're adding as a frag was added to\n-\t * linear part of skb so move the pointer past that header and\n-\t * reduce the size of data\n-\t */\n-\tva += pull_len;\n-\tsize -= pull_len;\n+\tskb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buf->page,\n+\t\t\trx_buf->page_offset, size, truesize);\n \n-add_tail_frag:\n-\tskb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,\n-\t\t\t(unsigned long)va & ~PAGE_MASK, size, truesize);\n+\t/* page is being used so we must update the page offset */\n \tice_rx_buf_adjust_pg_offset(rx_buf, truesize);\n }\n \n@@ -642,25 +608,34 @@ ice_reuse_rx_page(struct ice_ring *rx_ring, struct ice_rx_buf *old_buf)\n \tnta++;\n \trx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0;\n \n-\t/* transfer page from old buffer to new buffer */\n-\t*new_buf = *old_buf;\n+\t/* Transfer page from old buffer to new buffer.\n+\t * Move each member individually to avoid possible store\n+\t * forwarding stalls and unnecessary copy of skb.\n+\t */\n+\tnew_buf->dma = old_buf->dma;\n+\tnew_buf->page = old_buf->page;\n+\tnew_buf->page_offset = old_buf->page_offset;\n+\tnew_buf->pagecnt_bias = old_buf->pagecnt_bias;\n }\n \n /**\n * ice_get_rx_buf - Fetch Rx buffer and synchronize data for use\n * @rx_ring: Rx descriptor ring to transact packets on\n+ * @skb: skb to be used\n * @size: size of buffer to add to skb\n *\n * This function will pull an Rx buffer from the ring and synchronize it\n * for use by the CPU.\n */\n static struct ice_rx_buf *\n-ice_get_rx_buf(struct ice_ring *rx_ring, const unsigned int size)\n+ice_get_rx_buf(struct ice_ring *rx_ring, struct sk_buff **skb,\n+\t const unsigned int size)\n {\n \tstruct ice_rx_buf *rx_buf;\n \n \trx_buf = &rx_ring->rx_buf[rx_ring->next_to_clean];\n \tprefetchw(rx_buf->page);\n+\t*skb = rx_buf->skb;\n \n \t/* we are reusing so sync this buffer for CPU use */\n \tdma_sync_single_range_for_cpu(rx_ring->dev, rx_buf->dma,\n@@ -674,50 +649,64 @@ ice_get_rx_buf(struct ice_ring *rx_ring, const unsigned int size)\n }\n \n /**\n- * ice_fetch_rx_buf - Allocate skb and populate it\n+ * ice_construct_skb - Allocate skb and populate it\n * @rx_ring: Rx descriptor ring to transact packets on\n * @rx_buf: Rx buffer to pull data from\n * @size: the length of the packet\n *\n- * This function allocates an skb on the fly, and populates it with the page\n- * data from the current receive descriptor, taking care to set up the skb\n- * correctly, as well as handling calling the page recycle function if\n- * necessary.\n+ * This function allocates an skb. It then populates it with the page\n+ * data from the current receive descriptor, taking care to set up the\n+ * skb correctly.\n */\n static struct sk_buff *\n-ice_fetch_rx_buf(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf,\n-\t\t unsigned int size)\n+ice_construct_skb(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf,\n+\t\t unsigned int size)\n {\n-\tstruct sk_buff *skb = rx_buf->skb;\n-\n-\tif (likely(!skb)) {\n-\t\tu8 *page_addr = page_address(rx_buf->page) +\n-\t\t\t\trx_buf->page_offset;\n+\tvoid *va = page_address(rx_buf->page) + rx_buf->page_offset;\n+\tunsigned int headlen;\n+\tstruct sk_buff *skb;\n \n-\t\t/* prefetch first cache line of first page */\n-\t\tprefetch(page_addr);\n+\t/* prefetch first cache line of first page */\n+\tprefetch(va);\n #if L1_CACHE_BYTES < 128\n-\t\tprefetch((void *)(page_addr + L1_CACHE_BYTES));\n+\tprefetch((u8 *)va + L1_CACHE_BYTES);\n #endif /* L1_CACHE_BYTES */\n \n-\t\t/* allocate a skb to store the frags */\n-\t\tskb = __napi_alloc_skb(&rx_ring->q_vector->napi,\n-\t\t\t\t ICE_RX_HDR_SIZE,\n-\t\t\t\t GFP_ATOMIC | __GFP_NOWARN);\n-\t\tif (unlikely(!skb)) {\n-\t\t\trx_ring->rx_stats.alloc_buf_failed++;\n-\t\t\trx_buf->pagecnt_bias++;\n-\t\t\treturn NULL;\n-\t\t}\n+\t/* allocate a skb to store the frags */\n+\tskb = __napi_alloc_skb(&rx_ring->q_vector->napi, ICE_RX_HDR_SIZE,\n+\t\t\t GFP_ATOMIC | __GFP_NOWARN);\n+\tif (unlikely(!skb))\n+\t\treturn NULL;\n+\n+\tskb_record_rx_queue(skb, rx_ring->q_index);\n+\t/* Determine available headroom for copy */\n+\theadlen = size;\n+\tif (headlen > ICE_RX_HDR_SIZE)\n+\t\theadlen = eth_get_headlen(va, ICE_RX_HDR_SIZE);\n \n-\t\tskb_record_rx_queue(skb, rx_ring->q_index);\n+\t/* align pull length to size of long to optimize memcpy performance */\n+\tmemcpy(__skb_put(skb, headlen), va, ALIGN(headlen, sizeof(long)));\n+\n+\t/* if we exhaust the linear part then add what is left as a frag */\n+\tsize -= headlen;\n+\tif (size) {\n+#if (PAGE_SIZE >= 8192)\n+\t\tunsigned int truesize = SKB_DATA_ALIGN(size);\n+#else\n+\t\tunsigned int truesize = ICE_RXBUF_2048;\n+#endif\n+\t\tskb_add_rx_frag(skb, 0, rx_buf->page,\n+\t\t\t\trx_buf->page_offset + headlen, size, truesize);\n+\t\t/* buffer is used by skb, update page_offset */\n+\t\tice_rx_buf_adjust_pg_offset(rx_buf, truesize);\n \t} else {\n-\t\trx_buf->skb = NULL;\n+\t\t/* buffer is unused, reset bias back to rx_buf; data was copied\n+\t\t * onto skb's linear part so there's no need for adjusting\n+\t\t * page offset and we can reuse this buffer as-is\n+\t\t */\n+\t\trx_buf->pagecnt_bias++;\n \t}\n \n-\t/* pull page into skb */\n-\tice_add_rx_frag(rx_buf, skb, size);\n-\n \treturn skb;\n }\n \n@@ -744,6 +733,7 @@ static void ice_put_rx_buf(struct ice_ring *rx_ring, struct ice_rx_buf *rx_buf)\n \n \t/* clear contents of buffer_info */\n \trx_buf->page = NULL;\n+\trx_buf->skb = NULL;\n }\n \n /**\n@@ -1024,11 +1014,19 @@ static int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)\n \t\tsize = le16_to_cpu(rx_desc->wb.pkt_len) &\n \t\t\tICE_RX_FLX_DESC_PKT_LEN_M;\n \n-\t\trx_buf = ice_get_rx_buf(rx_ring, size);\n+\t\trx_buf = ice_get_rx_buf(rx_ring, &skb, size);\n \t\t/* allocate (if needed) and populate skb */\n-\t\tskb = ice_fetch_rx_buf(rx_ring, rx_buf, size);\n-\t\tif (!skb)\n+\t\tif (skb)\n+\t\t\tice_add_rx_frag(rx_buf, skb, size);\n+\t\telse\n+\t\t\tskb = ice_construct_skb(rx_ring, rx_buf, size);\n+\n+\t\t/* exit if we failed to retrieve a buffer */\n+\t\tif (!skb) {\n+\t\t\trx_ring->rx_stats.alloc_buf_failed++;\n+\t\t\trx_buf->pagecnt_bias++;\n \t\t\tbreak;\n+\t\t}\n \n \t\tice_put_rx_buf(rx_ring, rx_buf);\n \t\tcleaned_count++;\n", "prefixes": [ "S14", "06/15" ] }