[vortex] tx_full eliminated
Bogdan Costescu
Bogdan.Costescu@IWR.Uni-Heidelberg.De
Tue, 16 May 2000 21:47:13 +0200 (CEST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---830399112-1291786407-958505307=:10843
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.LNX.4.10.10005162132151.10843@kenzo.iwr.uni-heidelberg.de>
Hi,
I finally got time to look into the problem with tx_full which was the one
responsible for the race that I uncovered some weeks ago. The ideea is to
remove tx_full completely and always use cur_tx and dirty_tx with their
actual values; this way the situation when cur_tx = dirty_tx and tx_full =
1 is avoided.
I included a patch against Andrew's 2.2.16-pre2 driver, but I will specify
all the necessary changes (for Donald's line of drivers).
- remove the declaration of tx_full from the beginning of the driver
- in vortex_tx_timeout:
- remove tx_full from one printk
- change:
if (vp->tx_full && (vp->cur_tx - vp->dirty_tx <= TX_RING_SIZE - 1)) {
vp->tx_full = 0;
clear_bit(0, (void*)&dev->tbusy);
}
to:
if (vp->cur_tx - vp->dirty_tx <= TX_RING_SIZE - 1)
clear_bit(0, (void*)&dev->tbusy);
- in boomerang_start_xmit, change:
if (vp->tx_full) {
if (vortex_debug ....
to:
if (vp->cur_tx - vp->dirty_tx >= TX_RING_SIZE) {
if (vortex_debug ...
which will prevent running the rest of the routine if the ring is full.
and change:
if (vp->cur_tx - vp->dirty_tx > TX_RING_SIZE - 1)
vp->tx_full = 1;
else { /* Clear previous interrupt enable. */
prev_entry->status &= cpu_to_le32(~TxIntrUploaded);
clear_bit(0, (void*)&dev->tbusy);
}
to:
if (vp->cur_tx - vp->dirty_tx <= TX_RING_SIZE - 1)
{ /* Clear previous interrupt enable. */
prev_entry->status &= cpu_to_le32(~TxIntrUploaded);
clear_bit(0, (void*)&dev->tbusy);
}
which only adds interrupt mitigation (in some drivers this part is
#ifdef-ed) only if the buffer is not full (cur_tx-dirty_tx=TX_RING_SIZE) -
if it's full we need a TxIntrUploaded on the last packet in the ring.
The condition can probably be also written as: if (vp->cur_tx -
vp->dirty_tx != TX_RING_SIZE) because we were sure that cur_tx-dirty_tx <
TX_RING_SIZE (from the first test) and we just increment by 1.
- in vortex_interrupt, on the DownComplete branch, change:
if (vp->tx_full && (vp->cur_tx - dirty_tx <= TX_RING_SIZE - 1)) {
vp->tx_full = 0;
clear_bit(0, (void*)&dev->tbusy);
mark_bh(NET_BH);
}
to:
if (vp->cur_tx - dirty_tx <= TX_RING_SIZE - 1) {
clear_bit(0, (void*)&dev->tbusy);
mark_bh(NET_BH);
}
There is a difference here that I don't quite understand: in the original
code, the branch is only executed if the ring was full and there are some
entries available which should be almost every time, except if
boomerang_start_xmit add packets at the same rhythm as vortex_interrupt
eats them (in which case the ring is kept full) - in this case we don't
clear tbusy, but also don't mark_bh. Why ?
In the proposed code, mark_bh is always called.
In testing this patch, I also moved the DownUnstall & spin_unlock in
boomerang_start_xmit in their original (as in Donald's drivers) place -
before vp->cur_tx++. This would expose the code to the race that I
experienced, but it's not happenning anymore after more than 8 hours
of testing (it used to take about 2 minutes to get it). This should also
allow these changes to work with Donald's new drivers (which have no I/O
operations in boomerang_start_xmit for non Boomerang cards).
The only thing that I haven't tested is the vortex_tx_timeout code which I
cannot reach even if I set TX_RING_SIZE = 2 and TX_TIMEOUT = 10. The tests
were: ping -f with different packet sizes, ttcp in both TCP and UDP mode
and some parallel jobs running on top of LAM-MPI (which uses TCP).
[The patch also has the loop counter after DownStall increased to 3000.]
Sincerely,
Bogdan Costescu
IWR - Interdisziplinaeres Zentrum fuer Wissenschaftliches Rechnen
Universitaet Heidelberg, INF 368, D-69120 Heidelberg, GERMANY
Telephone: +49 6221 54 8869, Telefax: +49 6221 54 8868
E-mail: Bogdan.Costescu@IWR.Uni-Heidelberg.De
---830399112-1291786407-958505307=:10843
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME=p1
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.10005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