From patchwork Tue Jan 17 16:32:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 716289 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v2wc9361Sz9ssP for ; Wed, 18 Jan 2017 03:32:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="G4OPhgjC"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id E1CD4891CC; Tue, 17 Jan 2017 16:32:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cAvqprXQWaDJ; Tue, 17 Jan 2017 16:32:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id E9E1D891BE; Tue, 17 Jan 2017 16:32:04 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id A0AD21C0306 for ; Tue, 17 Jan 2017 16:32:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 9C8F88A5A5 for ; Tue, 17 Jan 2017 16:32:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1u6hSpgRUpPr for ; Tue, 17 Jan 2017 16:32:03 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by hemlock.osuosl.org (Postfix) with ESMTPS id ED7498A38A for ; Tue, 17 Jan 2017 16:32:02 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id 19so5825768pfo.3 for ; Tue, 17 Jan 2017 08:32:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=kETiHkleDHXW3zGctwYe5tEim4H1XXzFv9I37SEWTKs=; b=G4OPhgjC+c+PJ88BH34NklWcjXL7yHJ7osVeHnnYWrMqZD+/Dxm+tN1pr+fHl7LccX +6meSvIjOcuItHbPZMqN4XmyVDmAaHeNFn4etdaay4s3iarmPFD52wZh4ZCns7lOqkUl cXZDJ2iLreMZPobzWbgK4CONUqZ7DcXZVEysMfsiU2LL8UxtJ9vXR7QPrdXmNC5LkwOV Jbsz++/CtdqbbLB2SSW9YJhNw54SYmr141UuSPiGLSXv+T8b606bnQgocembPeEu5X/Z X6P4EZCFA/lUYX04leTCwgoDLtR10dTJb23pTCjoG/p2VVS9juCMBUrf5sOHkPVWsJnp HNpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=kETiHkleDHXW3zGctwYe5tEim4H1XXzFv9I37SEWTKs=; b=ImTs1AkETrwxwfZMUBb0I2cqrQEJHu+U6EO05hkacZnYTneA5vL13exqRONJK7lFI9 8QsDI+WgwcpeY1XEUOWEDvEIp/nNyjM12+rnlmdJmXj3f/MSCh9oYEENF3ulOztIFfh6 pUoAI+rqiPACr+VRNbGF0T5kHCFlct8LXxsbN8UEsB9nDXeH4V5fJn2tBSKSsVExVTb/ C1+dSfzUY5bmDVoY9jOoyg6mHBdrMZaJ3rZsnsgDz3b2E/0wUtB3DTgCsEXROMLuJzt1 BqW09j4/xd3NTb+WNcqG6qy0WvZLxcDuI6TOU7ezjhH/MQgEcErHEcFhnJMlRw54jnA6 aM3g== X-Gm-Message-State: AIkVDXID2UA4eBt78UR4pAtxhZ5JiNymtOtA7tjEYHkFiv//9ZME3ZMnjRHs8/8ZRI1F/A== X-Received: by 10.99.1.142 with SMTP id 136mr25299585pgb.142.1484670722319; Tue, 17 Jan 2017 08:32:02 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id w11sm56921934pfk.75.2017.01.17.08.32.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Jan 2017 08:32:01 -0800 (PST) From: Alexander Duyck To: intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com Date: Tue, 17 Jan 2017 08:32:01 -0800 Message-ID: <20170117163154.5184.41138.stgit@localhost.localdomain> In-Reply-To: <20170117163010.5184.65449.stgit@localhost.localdomain> References: <20170117163010.5184.65449.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Intel-wired-lan] [next PATCH v2 3/9] igb: Clear Rx buffer_info in configure instead of clean 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" From: Alexander Duyck This change makes it so that instead of going through the entire ring on Rx cleanup we only go through the region that was designated to be cleaned up and stop when we reach the region where new allocations should start. In addition we can avoid having to perform a memset on the Rx buffer_info structures until we are about to start using the ring again. By deferring this we can avoid dirtying the cache any more than we have to which can help to improve the time needed to bring the interface down and then back up again in a reset or suspend/resume cycle. Signed-off-by: Alexander Duyck --- drivers/net/ethernet/intel/igb/igb_main.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 91a524b155ce..79a8f3a3356e 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -3435,7 +3435,7 @@ int igb_setup_rx_resources(struct igb_ring *rx_ring) size = sizeof(struct igb_rx_buffer) * rx_ring->count; - rx_ring->rx_buffer_info = vzalloc(size); + rx_ring->rx_buffer_info = vmalloc(size); if (!rx_ring->rx_buffer_info) goto err; @@ -3759,6 +3759,10 @@ void igb_configure_rx_ring(struct igb_adapter *adapter, rxdctl |= IGB_RX_HTHRESH << 8; rxdctl |= IGB_RX_WTHRESH << 16; + /* initialize rx_buffer_info */ + memset(ring->rx_buffer_info, 0, + sizeof(struct igb_rx_buffer) * ring->count); + /* initialize Rx descriptor 0 */ rx_desc = IGB_RX_DESC(ring, 0); rx_desc->wb.upper.length = 0; @@ -3937,23 +3941,16 @@ static void igb_free_all_rx_resources(struct igb_adapter *adapter) **/ static void igb_clean_rx_ring(struct igb_ring *rx_ring) { - unsigned long size; - u16 i; + u16 i = rx_ring->next_to_clean; if (rx_ring->skb) dev_kfree_skb(rx_ring->skb); rx_ring->skb = NULL; - if (!rx_ring->rx_buffer_info) - return; - /* Free all the Rx ring sk_buffs */ - for (i = 0; i < rx_ring->count; i++) { + while (i != rx_ring->next_to_alloc) { struct igb_rx_buffer *buffer_info = &rx_ring->rx_buffer_info[i]; - if (!buffer_info->page) - continue; - /* Invalidate cache lines that may have been written to by * device so that we avoid corrupting memory. */ @@ -3972,12 +3969,11 @@ static void igb_clean_rx_ring(struct igb_ring *rx_ring) __page_frag_cache_drain(buffer_info->page, buffer_info->pagecnt_bias); - buffer_info->page = NULL; + i++; + if (i == rx_ring->count) + i = 0; } - size = sizeof(struct igb_rx_buffer) * rx_ring->count; - memset(rx_ring->rx_buffer_info, 0, size); - rx_ring->next_to_alloc = 0; rx_ring->next_to_clean = 0; rx_ring->next_to_use = 0;