Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/730826/?format=api
{ "id": 730826, "url": "http://patchwork.ozlabs.org/api/patches/730826/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1487721348-25617-2-git-send-email-bimmy.pujari@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": "<1487721348-25617-2-git-send-email-bimmy.pujari@intel.com>", "list_archive_url": null, "date": "2017-02-21T23:55:39", "name": "[next,S61,01/10] i40e/i40evf: Update code to better handle incrementing page count", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "99d2f6f4fbd1b8b19a1f044024705fabebde8893", "submitter": { "id": 68919, "url": "http://patchwork.ozlabs.org/api/people/68919/?format=api", "name": "Pujari, Bimmy", "email": "bimmy.pujari@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/1487721348-25617-2-git-send-email-bimmy.pujari@intel.com/mbox/", "series": [], "comments": "http://patchwork.ozlabs.org/api/patches/730826/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/730826/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@lists.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" ], "Received": [ "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3vSbWJ0GWdz9s73\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 22 Feb 2017 09:58:04 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 906D38A4A4;\n\tTue, 21 Feb 2017 22:58:02 +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 qcA4NPbUQa2z; Tue, 21 Feb 2017 22:58:00 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id DCBB48A558;\n\tTue, 21 Feb 2017 22:58:00 +0000 (UTC)", "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id 677BB1BFF60\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 21 Feb 2017 22:57:57 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 6350F8A6BB\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 21 Feb 2017 22:57:57 +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 6R7VYx7igOsc for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 21 Feb 2017 22:57:55 +0000 (UTC)", "from mga01.intel.com (mga01.intel.com [192.55.52.88])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 82AB48A4D1\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 21 Feb 2017 22:57:55 +0000 (UTC)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t21 Feb 2017 14:57:54 -0800", "from bimmy.jf.intel.com (HELO bimmy.linux1.jf.intel.com)\n\t([10.166.35.87])\n\tby fmsmga002.fm.intel.com with ESMTP; 21 Feb 2017 14:57:54 -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-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos; i=\"5.35,191,1484035200\"; d=\"scan'208\";\n\ta=\"1133083123\"", "From": "Bimmy Pujari <bimmy.pujari@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 21 Feb 2017 15:55:39 -0800", "Message-Id": "<1487721348-25617-2-git-send-email-bimmy.pujari@intel.com>", "X-Mailer": "git-send-email 2.4.11", "In-Reply-To": "<1487721348-25617-1-git-send-email-bimmy.pujari@intel.com>", "References": "<1487721348-25617-1-git-send-email-bimmy.pujari@intel.com>", "Subject": "[Intel-wired-lan] [next PATCH S61 01/10] i40e/i40evf: Update code\n\tto better handle incrementing page count", "X-BeenThere": "intel-wired-lan@lists.osuosl.org", "X-Mailman-Version": "2.1.18-1", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.lists.osuosl.org>", "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>", "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.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@lists.osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>" }, "content": "From: Alexander Duyck <alexander.h.duyck@intel.com>\n\nUpdate the driver code so that we do bulk updates of the page reference\ncount instead of just incrementing it by one reference at a time. The\nadvantage to doing this is that we cut down on atomic operations and\nthis in turn should give us a slight improvement in cycles per packet.\nIn addition if we eventually move this over to using build_skb the gains\nwill be more noticeable.\n\nI also found and fixed a store forwarding stall from where we were\nassigning \"*new_buff = *old_buff\". By breaking it up into individual\ncopies we can avoid this and as a result the performance is slightly\nimproved.\n\nSigned-off-by: Alexander Duyck <alexander.h.duyck@intel.com>\nChange-ID: I1d3880dece4133eca3c32423b04a5467321ccc52\n---\nTesting Hints: Make certain this doesn't cause any memory leaks or lead\n to any data corruptions under heavy Rx traffic with a mix of frame\n sizes.\n\n drivers/net/ethernet/intel/i40e/i40e_txrx.c | 25 ++++++++++++++++++-------\n drivers/net/ethernet/intel/i40e/i40e_txrx.h | 7 ++++++-\n drivers/net/ethernet/intel/i40evf/i40e_txrx.c | 24 ++++++++++++++++++------\n drivers/net/ethernet/intel/i40evf/i40e_txrx.h | 7 ++++++-\n 4 files changed, 48 insertions(+), 15 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\nindex b442d64d..f80c76c 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c\n@@ -1139,7 +1139,7 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)\n \t\t\t\t PAGE_SIZE,\n \t\t\t\t DMA_FROM_DEVICE,\n \t\t\t\t I40E_RX_DMA_ATTR);\n-\t\t__free_pages(rx_bi->page, 0);\n+\t\t__page_frag_cache_drain(rx_bi->page, rx_bi->pagecnt_bias);\n \n \t\trx_bi->page = NULL;\n \t\trx_bi->page_offset = 0;\n@@ -1289,6 +1289,7 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,\n \tbi->dma = dma;\n \tbi->page = page;\n \tbi->page_offset = 0;\n+\tbi->pagecnt_bias = 1;\n \n \treturn true;\n }\n@@ -1676,6 +1677,7 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n #if (PAGE_SIZE >= 8192)\n \tunsigned int last_offset = PAGE_SIZE - I40E_RXBUFFER_2048;\n #endif\n+\tunsigned int pagecnt_bias = rx_buffer->pagecnt_bias--;\n \n \t/* Is any reuse possible? */\n \tif (unlikely(!i40e_page_is_reusable(page)))\n@@ -1683,7 +1685,7 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n \n #if (PAGE_SIZE < 8192)\n \t/* if we are only owner of page we can reuse it */\n-\tif (unlikely(page_count(page) != 1))\n+\tif (unlikely(page_count(page) != pagecnt_bias))\n \t\treturn false;\n \n \t/* flip page offset to other buffer */\n@@ -1696,9 +1698,14 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n \t\treturn false;\n #endif\n \n-\t/* Inc ref count on page before passing it up to the stack */\n-\tget_page(page);\n-\n+\t/* If we have drained the page fragment pool we need to update\n+\t * the pagecnt_bias and page count so that we fully restock the\n+\t * number of references the driver holds.\n+\t */\n+\tif (unlikely(pagecnt_bias == 1)) {\n+\t\tpage_ref_add(page, USHRT_MAX);\n+\t\trx_buffer->pagecnt_bias = USHRT_MAX;\n+\t}\n \treturn true;\n }\n \n@@ -1745,7 +1752,6 @@ static bool i40e_add_rx_frag(struct i40e_ring *rx_ring,\n \t\t\treturn true;\n \n \t\t/* this page cannot be reused so discard it */\n-\t\t__free_pages(page, 0);\n \t\treturn false;\n \t}\n \n@@ -1865,7 +1871,10 @@ static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,\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_buff = *old_buff;\n+\tnew_buff->dma\t\t= old_buff->dma;\n+\tnew_buff->page\t\t= old_buff->page;\n+\tnew_buff->page_offset\t= old_buff->page_offset;\n+\tnew_buff->pagecnt_bias\t= old_buff->pagecnt_bias;\n }\n \n /**\n@@ -2034,6 +2043,8 @@ struct sk_buff *i40e_fetch_rx_buffer(struct i40e_ring *rx_ring,\n \t\t/* we are not reusing the buffer so unmap it */\n \t\tdma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n \t\t\t\t DMA_FROM_DEVICE, I40E_RX_DMA_ATTR);\n+\t\t__page_frag_cache_drain(rx_buffer->page,\n+\t\t\t\t\trx_buffer->pagecnt_bias);\n \t}\n \n \t/* clear contents of buffer_info */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\nindex 34fd1e7..606f5ad 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h\n@@ -260,7 +260,12 @@ struct i40e_tx_buffer {\n struct i40e_rx_buffer {\n \tdma_addr_t dma;\n \tstruct page *page;\n-\tunsigned int page_offset;\n+#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)\n+\t__u32 page_offset;\n+#else\n+\t__u16 page_offset;\n+#endif\n+\t__u16 pagecnt_bias;\n };\n \n struct i40e_queue_stats {\ndiff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\nindex 8dc3316..39e2e73 100644\n--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\n+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c\n@@ -526,7 +526,7 @@ void i40evf_clean_rx_ring(struct i40e_ring *rx_ring)\n \t\t\t\t PAGE_SIZE,\n \t\t\t\t DMA_FROM_DEVICE,\n \t\t\t\t I40E_RX_DMA_ATTR);\n-\t\t__free_pages(rx_bi->page, 0);\n+\t\t__page_frag_cache_drain(rx_bi->page, rx_bi->pagecnt_bias);\n \n \t\trx_bi->page = NULL;\n \t\trx_bi->page_offset = 0;\n@@ -671,6 +671,7 @@ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring,\n \tbi->dma = dma;\n \tbi->page = page;\n \tbi->page_offset = 0;\n+\tbi->pagecnt_bias = 1;\n \n \treturn true;\n }\n@@ -966,7 +967,10 @@ static void i40e_reuse_rx_page(struct i40e_ring *rx_ring,\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_buff = *old_buff;\n+\tnew_buff->dma\t\t= old_buff->dma;\n+\tnew_buff->page\t\t= old_buff->page;\n+\tnew_buff->page_offset\t= old_buff->page_offset;\n+\tnew_buff->pagecnt_bias\t= old_buff->pagecnt_bias;\n }\n \n /**\n@@ -1018,6 +1022,7 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n #if (PAGE_SIZE >= 8192)\n \tunsigned int last_offset = PAGE_SIZE - I40E_RXBUFFER_2048;\n #endif\n+\tunsigned int pagecnt_bias = rx_buffer->pagecnt_bias--;\n \n \t/* Is any reuse possible? */\n \tif (unlikely(!i40e_page_is_reusable(page)))\n@@ -1025,7 +1030,7 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n \n #if (PAGE_SIZE < 8192)\n \t/* if we are only owner of page we can reuse it */\n-\tif (unlikely(page_count(page) != 1))\n+\tif (unlikely(page_count(page) != pagecnt_bias))\n \t\treturn false;\n \n \t/* flip page offset to other buffer */\n@@ -1038,8 +1043,14 @@ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer,\n \t\treturn false;\n #endif\n \n-\t/* Inc ref count on page before passing it up to the stack */\n-\tget_page(page);\n+\t/* If we have drained the page fragment pool we need to update\n+\t * the pagecnt_bias and page count so that we fully restock the\n+\t * number of references the driver holds.\n+\t */\n+\tif (unlikely(pagecnt_bias == 1)) {\n+\t\tpage_ref_add(page, USHRT_MAX);\n+\t\trx_buffer->pagecnt_bias = USHRT_MAX;\n+\t}\n \n \treturn true;\n }\n@@ -1087,7 +1098,6 @@ static bool i40e_add_rx_frag(struct i40e_ring *rx_ring,\n \t\t\treturn true;\n \n \t\t/* this page cannot be reused so discard it */\n-\t\t__free_pages(page, 0);\n \t\treturn false;\n \t}\n \n@@ -1181,6 +1191,8 @@ struct sk_buff *i40evf_fetch_rx_buffer(struct i40e_ring *rx_ring,\n \t\t/* we are not reusing the buffer so unmap it */\n \t\tdma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, PAGE_SIZE,\n \t\t\t\t DMA_FROM_DEVICE, I40E_RX_DMA_ATTR);\n+\t\t__page_frag_cache_drain(rx_buffer->page,\n+\t\t\t\t\trx_buffer->pagecnt_bias);\n \t}\n \n \t/* clear contents of buffer_info */\ndiff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\nindex 0135121..7b41df1 100644\n--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\n+++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.h\n@@ -244,7 +244,12 @@ struct i40e_tx_buffer {\n struct i40e_rx_buffer {\n \tdma_addr_t dma;\n \tstruct page *page;\n-\tunsigned int page_offset;\n+#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)\n+\t__u32 page_offset;\n+#else\n+\t__u16 page_offset;\n+#endif\n+\t__u16 pagecnt_bias;\n };\n \n struct i40e_queue_stats {\n", "prefixes": [ "next", "S61", "01/10" ] }