All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Chen <wangchen@cn.fujitsu.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, vinay@linux.vnet.ibm.com,
	krkumar2@in.ibm.com, matheos.worku@sun.com
Subject: Re: [PATCH 2/2]: niu: Manage TX backlog in-driver.
Date: Mon, 23 Jun 2008 10:04:45 +0800	[thread overview]
Message-ID: <485F04BD.6090601@cn.fujitsu.com> (raw)
In-Reply-To: <20080622.161658.115278698.davem@davemloft.net>

David Miller said the following on 2008-6-23 7:16:
> +
> +		while ((skb = __skb_dequeue(&rp->tx_backlog)) != NULL)
> +			dev_kfree_skb(skb);

How about __skb_queue_purge(&rp->tx_backlog);

> +static void __niu_tx_queue_backlog(struct niu *np, struct tx_ring_info *rp,
> +				   struct sk_buff *skb)
> +{
> +	if (skb_queue_len(&rp->tx_backlog) < np->dev->tx_queue_len)
> +		__skb_queue_tail(&rp->tx_backlog, skb);

Do we need lock to proteck tx_backlog?
How about use skb_queue_tail()?

> +	else
> +		dev_kfree_skb(skb);
> +
> +	smp_mb();
> +
> +	/* This is a deadlock breaker.  niu_tx_work() updates the consumer
> +	 * index, then checks the tx_backlog for emptiness.  It also
> +	 * tries to mitigate work by only flushing the backlog when at
> +	 * least a certain percentage of space is available.  Those
> +	 * tests in niu_tx_work() run lockless.
> +	 *
> +	 * Here, we make the two primary memory operations in the
> +	 * reverse order.  The idea is to make sure that one of these
> +	 * two code paths will process the backlog no matter what the
> +	 * order of their relative execution might be.
> +	 *
> +	 * In short:
> +	 *
> +	 * niu_tx_work() --> rp->cons = foo; test skb_queue_empty()
> +	 * niu_start_xmit() --> __skb_queue_tail(); test rp->cons
> +	 */
> +	if (niu_tx_avail(rp) > NIU_TX_WAKEUP_THRESH(rp))
> +		__niu_xmit_backlog(np, rp);
> +}
> +


  reply	other threads:[~2008-06-23  2:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-22 23:16 [PATCH 2/2]: niu: Manage TX backlog in-driver David Miller
2008-06-23  2:04 ` Wang Chen [this message]
2008-06-23  2:30   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=485F04BD.6090601@cn.fujitsu.com \
    --to=wangchen@cn.fujitsu.com \
    --cc=davem@davemloft.net \
    --cc=krkumar2@in.ibm.com \
    --cc=matheos.worku@sun.com \
    --cc=netdev@vger.kernel.org \
    --cc=vinay@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.