From: Stephen Hemminger <shemminger@osdl.org>
To: "Eric Lemoine" <eric.lemoine@gmail.com>
Cc: "Benjamin Herrenschmidt" <benh@kernel.crashing.org>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [sungem] proposal for a new locking strategy
Date: Mon, 6 Nov 2006 09:55:51 -0800 [thread overview]
Message-ID: <20061106095551.18f9661c@freekitty> (raw)
In-Reply-To: <5cac192f0611051211t55e4c724w3eea5043dfc53db6@mail.gmail.com>
On Sun, 5 Nov 2006 21:11:34 +0100
"Eric Lemoine" <eric.lemoine@gmail.com> wrote:
> On 11/5/06, Stephen Hemminger <shemminger@osdl.org> wrote:
> > On Sun, 5 Nov 2006 18:52:45 +0100
> > "Eric Lemoine" <eric.lemoine@gmail.com> wrote:
> >
> > > On 11/5/06, Stephen Hemminger <shemminger@osdl.org> wrote:
> > > > On Sun, 5 Nov 2006 18:28:33 +0100
> > > > "Eric Lemoine" <eric.lemoine@gmail.com> wrote:
> > > >
> > > > > > You could also just use net_tx_lock() now.
> > > > >
> > > > > You mean netif_tx_lock()?
> > > > >
> > > > > Thanks for letting me know about that function. Yes, I may need it.
> > > > > tg3 and bnx2 use it to wake up the transmit queue:
> > > > >
> > > > > if (unlikely(netif_queue_stopped(tp->dev) &&
> > > > > (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH))) {
> > > > > netif_tx_lock(tp->dev);
> > > > > if (netif_queue_stopped(tp->dev) &&
> > > > > (tg3_tx_avail(tp) > TG3_TX_WAKEUP_THRESH))
> > > > > netif_wake_queue(tp->dev);
> > > > > netif_tx_unlock(tp->dev);
> > > > > }
> > > > >
> > > > > 2.6.17 didn't use it. Was it a bug?
> > > > >
> > > > > Thanks,
> > > >
> > > > No, it was introduced in 2.6.18. The functions are just a wrapper
> > > > around the network device transmit lock that is normally held.
> > > >
> > > > If the device does not need to acquire the lock during IRQ, it
> > > > is a good alternative and avoids a second lock.
> > > >
> > > > For transmit locking there are three common alternatives:
> > > >
> > > > Method A: dev->queue_xmit_lock and per-device tx_lock
> > > > send: dev->xmit_lock held by caller
> > > > dev->hard_start_xmit acquires netdev_priv(dev)->tx_lock
> > > >
> > > > irq: netdev_priv(dev)->tx_lock acquired
> > > >
> > > > Method B: dev->queue_xmit_lock only
> > > > send: dev->xmit_lock held by caller
> > > > irq: schedules softirq (NAPI)
> > > > napi_poll: calls netif_tx_lock() which acquires dev->xmit_lock
> > > >
> > > > Method C: LLTX
> > > > set dev->features LLTX
> > > > send: no locks held by caller
> > > > dev->hard_start_xmit acquires netdev_priv(dev)->tx_lock
> > > > irq: netdev_priv(dev)->tx_lock acquired
> > > >
> > > > Method A is the only one that works with 2.4 and early (2.6.8?) kernels.
> > > >
> > >
> > > Current sungem does Method C, and uses two locks: lock and tx_lock.
> > > What I was planning to do is Method B (which current tg3 uses). It
> > > seems to me that Method B is better than Method C. What do you think?
> >
> > B is better than C because the transmit logic doesn't have to
> > spin in the case of lock contention, but it is not a big difference.
>
> Current sungem does C but uses try_lock() to acquire its private
> tx_lock. So it doesn't spin either in case of contention.
But the spin is still there, just more complex..
In qdisc_restart() processing of NETDEV_TX_LOCKED causes:
spin_lock(dev->xmit_lock)
q->requeue()
netif_schedule(dev);
SOFTIRQ:
net_tx_action()
qdisc_run() --> qdisc_restart()
So instead of spinning in tight loop, you end up with a longer code
path.
--
Stephen Hemminger <shemminger@osdl.org>
next prev parent reply other threads:[~2006-11-06 17:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-11-05 13:00 [sungem] proposal for a new locking strategy Eric Lemoine
2006-11-05 13:05 ` Benjamin Herrenschmidt
2006-11-05 13:17 ` Eric Lemoine
2006-11-05 17:02 ` Stephen Hemminger
2006-11-05 17:28 ` Eric Lemoine
2006-11-05 17:41 ` Stephen Hemminger
2006-11-05 17:52 ` Eric Lemoine
2006-11-05 18:49 ` Stephen Hemminger
2006-11-05 20:11 ` Eric Lemoine
2006-11-06 17:55 ` Stephen Hemminger [this message]
2006-11-06 20:55 ` Eric Lemoine
2006-11-06 20:57 ` Stephen Hemminger
2006-11-06 21:10 ` Eric Lemoine
2006-11-06 21:49 ` Stephen Hemminger
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=20061106095551.18f9661c@freekitty \
--to=shemminger@osdl.org \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=eric.lemoine@gmail.com \
--cc=netdev@vger.kernel.org \
/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.