netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: bhutchings@solarflare.com, linux@horizon.com
Cc: eric.dumazet@gmail.com, grantgrundler@gmail.com,
	grundler@parisc-linux.org, netdev@vger.kernel.org
Subject: Re: [RFC] tulip: Support for byte queue limits
Date: 17 Jul 2013 00:09:59 -0400	[thread overview]
Message-ID: <20130717040959.24815.qmail@science.horizon.com> (raw)
In-Reply-To: <1373932689.3745.30.camel@bwh-desktop.uk.level5networks.com>

>>  	wmb();
>>  
>> -	tp->cur_tx++;
>> -
>>  	/* Trigger an immediate transmit demand. */
>>  	iowrite32(0, tp->base_addr + CSR1);
>>  
>> +	tp->cur_tx++;
>> +	netdev_sent_queue(dev, skb->len);
>>  	spin_unlock_irqrestore(&tp->lock, flags);

> This is not good practice, because once you start DMA you have
> effectively passed ownership of the skb to the TX completion handler.

Thank you for this advice.  Just to be clear, is the only issue reading
skb->len from a potentially deallocated skb?  Or is it also going go
give the byte queue system fits if the transmit complete handler calls
netdev_completed_queue before the transmitter calls netdev_sent_queue?

I'd hope it can underflow safely, and only look at the net value after
the transmit handler returns.

> Presumably the TX completion handler will hold this spinlock and
> therefore cannot free the skb before you use skb->len above.  So this
> will be safe now.  But one day someone may want to get rid of this lock,
> so this is a trap waiting to spring.

Sounds like a fun project.  But I have to dig into the BQL code; if it's
getting and dropping locks inside netdev_*_queue, the win is limited.

(A lock-free version would have separate "sent" and "completed" counters,
and compute the difference when a snapshot is required.)

  parent reply	other threads:[~2013-07-17  4:10 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-12 13:20 [RFC] tulip: Support for byte queue limits George Spelvin
2013-07-12 13:39 ` Eric Dumazet
2013-07-12 16:31 ` Grant Grundler
2013-07-12 18:01   ` George Spelvin
2013-07-12 18:14     ` Grant Grundler
2013-07-15 23:58     ` Ben Hutchings
2013-07-16  1:17       ` Grant Grundler
2013-07-16  1:27         ` Eric Dumazet
2013-07-16 14:37         ` Ben Hutchings
2013-07-16 17:20           ` Grant Grundler
2013-07-17  4:09       ` George Spelvin [this message]
2013-07-17 15:42         ` Ben Hutchings
2013-07-31 12:34           ` George Spelvin

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=20130717040959.24815.qmail@science.horizon.com \
    --to=linux@horizon.com \
    --cc=bhutchings@solarflare.com \
    --cc=eric.dumazet@gmail.com \
    --cc=grantgrundler@gmail.com \
    --cc=grundler@parisc-linux.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).