From patchwork Thu Apr 5 10:31:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Yu X-Patchwork-Id: 150905 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 D166DB7051 for ; Thu, 5 Apr 2012 20:31:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754478Ab2DEKbM (ORCPT ); Thu, 5 Apr 2012 06:31:12 -0400 Received: from mail-yw0-f46.google.com ([209.85.213.46]:34317 "EHLO mail-yw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753874Ab2DEKbK (ORCPT ); Thu, 5 Apr 2012 06:31:10 -0400 Received: by yhmm54 with SMTP id m54so598714yhm.19 for ; Thu, 05 Apr 2012 03:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=H6QAul3H7qkRVla3Tkz7Nzd3LzSCr7oPzyfaEYn2fW0=; b=OoQwweoQrVNgvCf1nBOcOZuph65bTpAjLSJMqvT3GB7xmKh9+R6a3Zqp56G1euPDJR jj23X+usNxTqtNHBEtsHhXewff4zivZK93+jm+y8jxKY/AoqAa/2iy0e5JoFQtwrateg zXsu8Rvr3W7Gvnr7WJzmNYYpNvrqnpefpUfxe+8poUPZrSpEbTJLL2LhX844yjZwldA/ lf7Lepi8pt5eOSCa7nQCiVg8a5OOCmKEJOeEBLdMCDIcfc/engPlCiZU/YRnPreZUMVR bLSuqNm/WNKJByzLh8cboSHQNjSQ+3w45SLN2Vgnzb7w9Dwx9cdb4/m0aUGO8O/ePFkQ WUgA== Received: by 10.50.180.135 with SMTP id do7mr1255256igc.56.1333621869477; Thu, 05 Apr 2012 03:31:09 -0700 (PDT) Received: from [10.32.101.228] ([182.92.247.2]) by mx.google.com with ESMTPS id i7sm6692184igq.11.2012.04.05.03.31.07 (version=SSLv3 cipher=OTHER); Thu, 05 Apr 2012 03:31:08 -0700 (PDT) Message-ID: <4F7D7464.7040503@gmail.com> Date: Thu, 05 Apr 2012 18:31:00 +0800 From: Li Yu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 MIME-Version: 1.0 To: netdev@vger.kernel.org Subject: [PATCH net-next] rps: introduce a new sysctl switch rps_workaround_buggy_driver Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We encountered a buggy NIC driver or hardware/firmware, it keeps non-zero constant skb->rxhash for long time, so if we enabled RPS, the targeted CPU keeps same for long time too. This patch introduces a sysctl switch to workaround for such problem, if the switch was on, RPS core discards the skb->rxhash that is computed by NIC hardware. Hope this patch also can help others, thanks. Signed-off-by Li Yu --- 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/include/linux/skbuff.h b/include/linux/skbuff.h index 192250b..4c28ce0 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -628,9 +628,13 @@ extern unsigned int skb_find_text(struct sk_buff *skb, unsigned int from, unsigned int to, struct ts_config *config, struct ts_state *state); +extern int rps_workaround_buggy_driver; extern void __skb_get_rxhash(struct sk_buff *skb); static inline __u32 skb_get_rxhash(struct sk_buff *skb) { + if (unlikely(rps_workaround_buggy_driver)) + skb->rxhash = 0; + if (!skb->rxhash) __skb_get_rxhash(skb); diff --git a/net/core/dev.c b/net/core/dev.c index 723a406..9d1e728 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -176,6 +176,8 @@ #define PTYPE_HASH_SIZE (16) #define PTYPE_HASH_MASK (PTYPE_HASH_SIZE - 1) +int rps_workaround_buggy_driver = 0; + static DEFINE_SPINLOCK(ptype_lock); static struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mostly; static struct list_head ptype_all __read_mostly; /* Taps */ diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 0c28508..065ea7c 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -172,6 +172,13 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = rps_sock_flow_sysctl }, + { + .procname = "rps_workaround_buggy_driver", + .data = &rps_workaround_buggy_driver, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec + }, #endif #endif /* CONFIG_NET */ {