From patchwork Sun Dec 5 01:01:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 74284 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 616C4B70FD for ; Sun, 5 Dec 2010 12:02:57 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755723Ab0LEBCg (ORCPT ); Sat, 4 Dec 2010 20:02:36 -0500 Received: from mail-pv0-f174.google.com ([74.125.83.174]:35744 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755418Ab0LEBCf (ORCPT ); Sat, 4 Dec 2010 20:02:35 -0500 Received: by pva4 with SMTP id 4so1646315pva.19 for ; Sat, 04 Dec 2010 17:02:35 -0800 (PST) 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=kwdvbGT82qfM1dxPiFn4BeoVJrjUP9CM6a0QWmMSvA4=; b=ZOAnpDuZG620atm48KAEx3WhcEruqucosEIDK0dqX7eLIOmFnF09j0cxi4tIgmPNRG muSGG8wmk6eaaudXuSagz/KCpBI5nwPnpexlmUMYvMrSNKaADqoEbvxGMLSb5AWjBEDV JEiCp+Q7uuZN7ADkymHylNMw5vGslKgcz2Ux0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=MGqKojeOaoav+O36raYpWSg1HI4Q2Lld8zasQxMOdezZGU7brdvNFP7zQaQQ3FX1M9 0byd1dhcdUMzmL/IQkhn/1V0ZT0QpseKZOw83G+1u8fJELNVb+zUAqeuYj4CI1utuBlL rP7GHhH3BOqJm5kHHrQNC8gSDLYkzQRON39ls= Received: by 10.142.165.18 with SMTP id n18mr3562298wfe.175.1291510955295; Sat, 04 Dec 2010 17:02:35 -0800 (PST) Received: from localhost.localdomain ([221.239.34.230]) by mx.google.com with ESMTPS id q13sm4775382wfc.17.2010.12.04.17.02.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 04 Dec 2010 17:02:34 -0800 (PST) From: Changli Gao To: jamal Cc: netdev@vger.kernel.org, Jarek Poplawski , Changli Gao Subject: [PATCH 3/3 v2] ifb: use the lockless variants of skb_queue Date: Sun, 5 Dec 2010 09:01:52 +0800 Message-Id: <1291510912-6979-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org rq and tq are both protected by tx queue lock, so we can simply use the lockless variants of skb_queue. skb_queue_splice_tail_init() is used instead of the open coded and slow one. Signed-off-by: Changli Gao Signed-off-by: Jamal Hadi Salim --- drivers/net/ifb.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 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/drivers/net/ifb.c b/drivers/net/ifb.c index d1e362a..9825f11 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c @@ -63,9 +63,7 @@ static void ri_tasklet(unsigned long dev) txq = netdev_get_tx_queue(_dev, 0); if ((skb = skb_peek(&dp->tq)) == NULL) { if (__netif_tx_trylock(txq)) { - while ((skb = skb_dequeue(&dp->rq)) != NULL) { - skb_queue_tail(&dp->tq, skb); - } + skb_queue_splice_tail_init(&dp->rq, &dp->tq); __netif_tx_unlock(txq); } else { /* reschedule */ @@ -161,7 +159,7 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); } - skb_queue_tail(&dp->rq, skb); + __skb_queue_tail(&dp->rq, skb); if (!dp->tasklet_pending) { dp->tasklet_pending = 1; tasklet_schedule(&dp->ifb_tasklet); @@ -176,8 +174,8 @@ static int ifb_close(struct net_device *dev) tasklet_kill(&dp->ifb_tasklet); netif_stop_queue(dev); - skb_queue_purge(&dp->rq); - skb_queue_purge(&dp->tq); + __skb_queue_purge(&dp->rq); + __skb_queue_purge(&dp->tq); return 0; } @@ -186,8 +184,8 @@ static int ifb_open(struct net_device *dev) struct ifb_private *dp = netdev_priv(dev); tasklet_init(&dp->ifb_tasklet, ri_tasklet, (unsigned long)dev); - skb_queue_head_init(&dp->rq); - skb_queue_head_init(&dp->tq); + __skb_queue_head_init(&dp->rq); + __skb_queue_head_init(&dp->tq); netif_start_queue(dev); return 0;