[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <OF39977762.2BDD4BB8-ONC1257A82.0032A26B-C1257A82.00350A53@transmode.se>
Date: Sun, 23 Sep 2012 11:39:20 +0200
From: Joakim Tjernlund <joakim.tjernlund@...nsmode.se>
To: Francois Romieu <romieu@...zoreil.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH v3] ucc_geth: Lockless xmit
Francois Romieu <romieu@...zoreil.com> wrote on 2012/09/21 19:35:35:
>
> Please keep netdev in the Cc:.
Sorry, wrong reply button. Now added.
>
> Joakim Tjernlund <joakim.tjernlund@...nsmode.se> :
> [...]
> > This is what I could come up with, what do you think?
>
> In its current state the driver implicitely relies on the Tx xmit vs Tx
> completion exclusion to work. As long as they exclude each other the
> ugeth->tx_skbuff[txQ][...] and the "bd_status & T_R" states are consistent.
>
> This scheme can not work without locking. The skb alone won't provide a
> synchronization point.
I don't get it. The skb test is there just for one special case, when
the BD ring is empty the (bd_status & T_R) == 0 will be true as well so
one need something more than the bd_status test.
>
> An usual solution would be some skb dirtytx vs curtx comparison + smp
> barriers (Documentation/memory-barriers.txt).
You mean adding an extra test in addition to !skb? Something like:
if (!skb && ugeth->skb_dirtytx[txQ] == ugeth->skb_curtx[txQ])
break;
>
> Sidenote: is there some reason why modulo (%) operations should be
> avoided on this platform ?
Not that I know. The original driver author did it this way.
>
> [...]
> > @@ -3380,8 +3380,12 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ)
> > 1) & TX_RING_MOD_MASK(ugeth->ug_info->bdRingLenTx[txQ]);
> >
> > /* We freed a buffer, so now we can restart transmission */
> > - if (netif_queue_stopped(dev))
> > - netif_wake_queue(dev);
> > + if (netif_queue_stopped(dev)) {
> > + netif_tx_lock(dev);
> > + if (netif_queue_stopped(dev))
> > + netif_wake_queue(dev);
> > + netif_tx_unlock(dev);
> > + }
>
> Without exclusion we don't know if it was stopped before or after the packet
> was freed. There must be some "are there available Tx slots ?" test in the
> locked section.
This makes sense, but stopping relies on ugeth->confBd[txQ] which is updated
last in ucc_geth_tx(). Looks a bit suboptimal though so it should probably
be changed.
>
> Btw the second netif_queue_stopped test can be removed if tx queueing can
> only be stopped in a single place (I did not check).
There is a netif_stop_queue in xmit and one in ucc_geth_close() so I guess
one can say there is only one place.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists