From patchwork Thu Apr 15 03:01:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 50209 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 3DDD9B7D2F for ; Thu, 15 Apr 2010 13:01:41 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756680Ab0DODBf (ORCPT ); Wed, 14 Apr 2010 23:01:35 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:56294 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756519Ab0DODBf (ORCPT ); Wed, 14 Apr 2010 23:01:35 -0400 Received: by pva18 with SMTP id 18so544451pva.19 for ; Wed, 14 Apr 2010 20:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=mWFUcmayMTOGIaCZbk6md0mOequb0ZzmTfoUOPMYxGI=; b=FoQpQbFUSqZGqcjU22qfcj9i+3tVabol7j1a0XaPiq6coUBbDvLb1n7Is0LFsyqv20 Wua4EFQPLfS3IsZLOKYwg+B0JdrkIkQiVHSe/AmqCZRpoeN4aDEJ7f8ufauWwPkMKjFL OA1ZAkbohDW1eOwnpMOfFEEReNrRtZ25AMH3U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=O2SittlPBl3U7Ok3eE0OsC24KR4IfhrVracgIIH4qatuTlFo7EP6/a6eM94kam3j5v BSM5ZiX5jOwbG51B9qC2JkxPU7TtFKPEjoiUhteZcxiIcqzehY4ZDEyqoBdoe6Czpwhl XD9IhMoZHm60+kOqcYK9M0rwq2r0fym1j8Oy0= Received: by 10.114.7.35 with SMTP id 35mr147074wag.4.1271300494248; Wed, 14 Apr 2010 20:01:34 -0700 (PDT) Received: from localhost.localdomain ([60.29.39.134]) by mx.google.com with ESMTPS id 21sm848258pzk.12.2010.04.14.20.01.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 14 Apr 2010 20:01:33 -0700 (PDT) From: Changli Gao To: "David S. Miller" Cc: Tom Herbert , Eric Dumazet , netdev@vger.kernel.org, Changli Gao Subject: [PATCH] net: fix softnet_stat Date: Thu, 15 Apr 2010 11:01:53 +0800 Message-Id: <1271300513-9995-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.6.4.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org fix softnet_stat Per cpu variable softnet_data.total was shared between IRQ and SoftIRQ context without any protection. And enqueue_to_backlog should update the netdev_rx_stat of the target CPU. This patch changes the meaning of softnet_data.total to the number of packets processed, not includes dropped, in order to avoid it sharing between IRQ and SoftIRQ. And softnet_data.dropped is protected in the corresponding input_pkt_queue.lock, if RPS is enabled. Signed-off-by: Changli Gao ---- net/core/dev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 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/dev.c b/net/core/dev.c index a10a216..b38a991 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -2336,7 +2336,6 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu) queue = &per_cpu(softnet_data, cpu); local_irq_save(flags); - __get_cpu_var(netdev_rx_stat).total++; rps_lock(queue); if (queue->input_pkt_queue.qlen <= netdev_max_backlog) { @@ -2366,9 +2365,9 @@ enqueue: goto enqueue; } + per_cpu(netdev_rx_stat, cpu).dropped++; rps_unlock(queue); - __get_cpu_var(netdev_rx_stat).dropped++; local_irq_restore(flags); kfree_skb(skb); @@ -3565,7 +3564,7 @@ static int softnet_seq_show(struct seq_file *seq, void *v) struct netif_rx_stats *s = v; seq_printf(seq, "%08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n", - s->total, s->dropped, s->time_squeeze, 0, + s->total + s->dropped, s->dropped, s->time_squeeze, 0, 0, 0, 0, 0, /* was fastroute */ s->cpu_collision, s->received_rps); return 0;