From patchwork Wed Jun 20 00:43:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Duyck, Alexander H" X-Patchwork-Id: 165868 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 76229B700F for ; Wed, 20 Jun 2012 10:42:51 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869Ab2FTAmt (ORCPT ); Tue, 19 Jun 2012 20:42:49 -0400 Received: from mga11.intel.com ([192.55.52.93]:15901 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752623Ab2FTAms (ORCPT ); Tue, 19 Jun 2012 20:42:48 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 19 Jun 2012 17:42:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="182437026" Received: from gitlad.jf.intel.com ([10.23.23.37]) by fmsmga002.fm.intel.com with ESMTP; 19 Jun 2012 17:42:47 -0700 Received: from gitlad.jf.intel.com (gitlad.jf.intel.com [127.0.0.1]) by gitlad.jf.intel.com (8.14.2/8.14.2) with ESMTP id q5K0h6si017844; Tue, 19 Jun 2012 17:43:06 -0700 From: Alexander Duyck Subject: [PATCH] net: Update netdev_alloc_frag to work more efficiently with TCP and GRO To: netdev@vger.kernel.org Cc: davem@davemloft.net, jeffrey.t.kirsher@intel.com Date: Tue, 19 Jun 2012 17:43:06 -0700 Message-ID: <20120620004306.17814.58369.stgit@gitlad.jf.intel.com> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch is meant to help improve system performance when netdev_alloc_frag is used in scenarios in which buffers are short lived. This is accomplished by allowing the page offset to be reset in the event that the page count is 1. I also reordered the direction in which we give out sections of the page so that we start at the end of the page and end at the start. The main motivation being that I preferred to have offset represent the amount of page remaining to be used. My primary test case was using ixgbe in combination with TCP. With this patch applied I saw CPU utilization drop from 3.4% to 3.0% for a single thread of netperf receiving a TCP stream via ixgbe. I also tested several scenarios in which the page reuse would not be possible such as UDP flows and routing. In both of these scenarios I saw no noticeable performance degradation compared to the kernel without this patch. Cc: Eric Dumazet Signed-off-by: Alexander Duyck --- net/core/skbuff.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 5b21522..eb3853c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -317,15 +317,22 @@ void *netdev_alloc_frag(unsigned int fragsz) if (unlikely(!nc->page)) { refill: nc->page = alloc_page(GFP_ATOMIC | __GFP_COLD); - nc->offset = 0; } if (likely(nc->page)) { - if (nc->offset + fragsz > PAGE_SIZE) { + unsigned int offset = PAGE_SIZE; + + if (page_count(nc->page) != 1) + offset = nc->offset; + + if (offset < fragsz) { put_page(nc->page); goto refill; } - data = page_address(nc->page) + nc->offset; - nc->offset += fragsz; + + offset -= fragsz; + nc->offset = offset; + + data = page_address(nc->page) + offset; get_page(nc->page); } local_irq_restore(flags);