From patchwork Wed Jan 15 16:58:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 311201 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 3E5632C0092 for ; Thu, 16 Jan 2014 03:58:13 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752408AbaAOQ6J (ORCPT ); Wed, 15 Jan 2014 11:58:09 -0500 Received: from mail-ig0-f202.google.com ([209.85.213.202]:34006 "EHLO mail-ig0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751928AbaAOQ6H (ORCPT ); Wed, 15 Jan 2014 11:58:07 -0500 Received: by mail-ig0-f202.google.com with SMTP id uq10so509549igb.1 for ; Wed, 15 Jan 2014 08:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:subject:message-id:user-agent:mime-version :content-type; bh=TdABZmxg1JpYpKmk7wFvdEGI5oHIjcM/zCmFouboa4A=; b=awFzPST7B7cdiCO5gFVjwAUIu1xF5RSMqQgw8Mj2eNfW/pZL5YDkwdb93Lz+QR1qSb uB/80SUocVtd12shtKrhPeyiC/wddGn9rtpFGuFwGZJH9O7VYg2TBDpneUbwYyTu93ez Uuxz8wmfqf4BeSueYljM1EobmIyc52QrHREsw2mAxXQ9XWhxCMAspLd0E/H5vYwf375z WeZYiFTngG7YQkU5qMw7eQd1lVnZ21RibWOFCvi6P+jTsAUIGJ5/WJjv+2trci1Q2lbQ /iz53ChpV+ryZmkNdyo87qEZ7HaQynm+eP71f6qwKftP0vp1L6Ct5gBAjESCW7EQII7j B4Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:user-agent :mime-version:content-type; bh=TdABZmxg1JpYpKmk7wFvdEGI5oHIjcM/zCmFouboa4A=; b=UFbmNWsGUfCBuz5YoJJASiwQAHI4v+//MCHJcIVeV9bhm8VlKaEhXERhDf9dEqVo5z XUKjyJp8R7eUTboexrty8i0BwYFXDG0Tm/LPo+SbMmzARhzeciFq9WGxjuS6ucYGkSk4 zeDou8UfEM7lmi5MJwfOswT4wUhric6F5oc2ZihZmEwqkSHFfTWSgF9ggcjrbqZCr8iM TkoQB+G623AxshIZeDz53Rsnm3e95B6UXSf7LaWnidSBsN9G403IMpuftWaPeaexpXel ekVKdr2DWQUmOXCxIfSt4tCRrDj8lAwUaEUat+Z5bihdj/1pr8J8hoLCTA1lnzxY5Fkq N2zQ== X-Gm-Message-State: ALoCoQmKNMP1sWmMKBgWRN50TP/aTUQca/k8aJ6E8mJWe7AM6X/CFyfHSTJAFo1nITFkhs73cQm4tEJ7E/ijhaZGL865q3ThVp5TIZY1GyekD56hs7ktNeXL0lH2xObtXpJRuhboWthB+eTKqaf4P6lwDZ6KsaN/C76Z9slLGgggAJ08OZOVvJaAEan7gyp1ixshVTBF0s4Q4OaXUqvzaYYAB4VZpkzQbw== X-Received: by 10.182.121.39 with SMTP id lh7mr1179224obb.46.1389805086799; Wed, 15 Jan 2014 08:58:06 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id k45si1406551yhn.4.2014.01.15.08.58.06 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Jan 2014 08:58:06 -0800 (PST) Received: from tomh.mtv.corp.google.com (tomh.mtv.corp.google.com [172.18.82.128]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id A22A65A4282; Wed, 15 Jan 2014 08:58:06 -0800 (PST) Received: by tomh.mtv.corp.google.com (Postfix, from userid 60832) id 61CE420050F; Wed, 15 Jan 2014 08:58:06 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by tomh.mtv.corp.google.com (Postfix) with ESMTP id 58C0E200365; Wed, 15 Jan 2014 08:58:06 -0800 (PST) Date: Wed, 15 Jan 2014 08:58:06 -0800 (PST) From: Tom Herbert To: davem@davemloft.net, netdev@vger.kernel.org Subject: [PATCH net-next v3 2/2] net: Check skb->rxhash in gro_receive Message-ID: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When initializing a gro_list for a packet, first check the rxhash of the incoming skb against that of the skb's in the list. This should be a very strong inidicator of whether the flow is going to be matched, and potentially allows a lot of other checks to be short circuited. Use skb_hash_raw so that we don't force the hash to be calculated. Tested by running netperf 200 TCP_STREAMs between two machines with GRO, HW rxhash, and 1G. Saw no performance degration, slight reduction of time in dev_gro_receive. Signed-off-by: Tom Herbert --- net/core/dev.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/core/dev.c b/net/core/dev.c index 20c834e..c063c7c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3818,10 +3818,18 @@ static void gro_list_prepare(struct napi_struct *napi, struct sk_buff *skb) { struct sk_buff *p; unsigned int maclen = skb->dev->hard_header_len; + u32 hash = skb_get_hash_raw(skb); for (p = napi->gro_list; p; p = p->next) { unsigned long diffs; + NAPI_GRO_CB(p)->flush = 0; + + if (hash != skb_get_hash_raw(p)) { + NAPI_GRO_CB(p)->same_flow = 0; + continue; + } + diffs = (unsigned long)p->dev ^ (unsigned long)skb->dev; diffs |= p->vlan_tci ^ skb->vlan_tci; if (maclen == ETH_HLEN) @@ -3832,7 +3840,6 @@ static void gro_list_prepare(struct napi_struct *napi, struct sk_buff *skb) skb_gro_mac_header(skb), maclen); NAPI_GRO_CB(p)->same_flow = !diffs; - NAPI_GRO_CB(p)->flush = 0; } }