* [PATCH v2 net-next] net: Functions to report space available in device TX queues
@ 2014-08-25 15:27 Tom Herbert
2014-08-26 0:33 ` David Miller
2014-09-03 13:20 ` Jesper Dangaard Brouer
0 siblings, 2 replies; 6+ messages in thread
From: Tom Herbert @ 2014-08-25 15:27 UTC (permalink / raw)
To: davem, netdev
This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
used to report number of bytes available in transmit queues per BQL. The
functions call dql_avail which returns BQL limit minus number of
inflight bytes. These functions can be called without txlock, for
instance to ascertain how much data should be dequeued from a qdisc in
a batch. When called without the tx_lock, the result is technically a
hint, subsequently when the tx_lock is done for a transmit it is
possible the availability has changed (for example a transmit
completion may have freed up more space in the queue or changed the
limit).
Signed-off-by: Tom Herbert <therbert@google.com>
---
include/linux/netdevice.h | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 0fac884..bdf6c85 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2544,6 +2544,30 @@ static inline void netdev_completed_queue(struct net_device *dev,
netdev_tx_completed_queue(netdev_get_tx_queue(dev, 0), pkts, bytes);
}
+static inline int netdev_tx_avail_queue(struct netdev_queue *dev_queue)
+{
+#ifdef CONFIG_BQL
+ return dql_avail(&dev_queue->dql);
+#else
+ return DQL_MAX_LIMIT;
+#endif
+}
+
+/**
+ * netdev_avail_queue - report how much space is availble for xmit
+ * @dev: network device
+ *
+ * Report the amount of space available in the TX queue in terms of
+ * number of bytes. This returns the number of bytes avaiable per
+ * DQL. This function may be called without taking the txlock on
+ * the device, however in that case the result should be taken as
+ * a (strong) hint.
+ */
+static inline int netdev_avail_queue(struct net_device *dev)
+{
+ return netdev_tx_avail_queue(netdev_get_tx_queue(dev, 0));
+}
+
static inline void netdev_tx_reset_queue(struct netdev_queue *q)
{
#ifdef CONFIG_BQL
@@ -2559,9 +2583,9 @@ static inline void netdev_tx_reset_queue(struct netdev_queue *q)
* Reset the bytes and packet count of a network device and clear the
* software flow control OFF bit for this network device
*/
-static inline void netdev_reset_queue(struct net_device *dev_queue)
+static inline void netdev_reset_queue(struct net_device *dev)
{
- netdev_tx_reset_queue(netdev_get_tx_queue(dev_queue, 0));
+ netdev_tx_reset_queue(netdev_get_tx_queue(dev, 0));
}
/**
--
2.1.0.rc2.206.gedb03e5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net-next] net: Functions to report space available in device TX queues
2014-08-25 15:27 [PATCH v2 net-next] net: Functions to report space available in device TX queues Tom Herbert
@ 2014-08-26 0:33 ` David Miller
2014-08-26 15:44 ` Tom Herbert
2014-09-03 13:20 ` Jesper Dangaard Brouer
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2014-08-26 0:33 UTC (permalink / raw)
To: therbert; +Cc: netdev
From: Tom Herbert <therbert@google.com>
Date: Mon, 25 Aug 2014 08:27:56 -0700 (PDT)
> This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
> used to report number of bytes available in transmit queues per BQL. The
> functions call dql_avail which returns BQL limit minus number of
> inflight bytes. These functions can be called without txlock, for
> instance to ascertain how much data should be dequeued from a qdisc in
> a batch. When called without the tx_lock, the result is technically a
> hint, subsequently when the tx_lock is done for a transmit it is
> possible the availability has changed (for example a transmit
> completion may have freed up more space in the queue or changed the
> limit).
>
> Signed-off-by: Tom Herbert <therbert@google.com>
Ok this looks fine, but could you please resubmit this alongside
the first use case?
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net-next] net: Functions to report space available in device TX queues
2014-08-26 0:33 ` David Miller
@ 2014-08-26 15:44 ` Tom Herbert
0 siblings, 0 replies; 6+ messages in thread
From: Tom Herbert @ 2014-08-26 15:44 UTC (permalink / raw)
To: David Miller; +Cc: Linux Netdev List
On Mon, Aug 25, 2014 at 5:33 PM, David Miller <davem@davemloft.net> wrote:
> From: Tom Herbert <therbert@google.com>
> Date: Mon, 25 Aug 2014 08:27:56 -0700 (PDT)
>
>> This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
>> used to report number of bytes available in transmit queues per BQL. The
>> functions call dql_avail which returns BQL limit minus number of
>> inflight bytes. These functions can be called without txlock, for
>> instance to ascertain how much data should be dequeued from a qdisc in
>> a batch. When called without the tx_lock, the result is technically a
>> hint, subsequently when the tx_lock is done for a transmit it is
>> possible the availability has changed (for example a transmit
>> completion may have freed up more space in the queue or changed the
>> limit).
>>
>> Signed-off-by: Tom Herbert <therbert@google.com>
>
> Ok this looks fine, but could you please resubmit this alongside
> the first use case?
>
It should be called when determining the best size for a transmit
batch, e.g. how many bytes to dequeue from qdisc on wakeup.
> Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net-next] net: Functions to report space available in device TX queues
2014-08-25 15:27 [PATCH v2 net-next] net: Functions to report space available in device TX queues Tom Herbert
2014-08-26 0:33 ` David Miller
@ 2014-09-03 13:20 ` Jesper Dangaard Brouer
2014-09-03 13:41 ` Eric Dumazet
1 sibling, 1 reply; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2014-09-03 13:20 UTC (permalink / raw)
To: Tom Herbert; +Cc: brouer, davem, netdev, Eric Dumazet
On Mon, 25 Aug 2014 08:27:56 -0700 (PDT)
Tom Herbert <therbert@google.com> wrote:
> This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
> used to report number of bytes available in transmit queues per BQL. The
> functions call dql_avail which returns BQL limit minus number of
> inflight bytes. These functions can be called without txlock, for
> instance to ascertain how much data should be dequeued from a qdisc in
> a batch. When called without the tx_lock, the result is technically a
> hint, subsequently when the tx_lock is done for a transmit it is
> possible the availability has changed (for example a transmit
> completion may have freed up more space in the queue or changed the
> limit).
>
> Signed-off-by: Tom Herbert <therbert@google.com>
> ---
> include/linux/netdevice.h | 28 ++++++++++++++++++++++++++--
> 1 file changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0fac884..bdf6c85 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2544,6 +2544,30 @@ static inline void netdev_completed_queue(struct net_device *dev,
> netdev_tx_completed_queue(netdev_get_tx_queue(dev, 0), pkts, bytes);
> }
>
> +static inline int netdev_tx_avail_queue(struct netdev_queue *dev_queue)
> +{
> +#ifdef CONFIG_BQL
> + return dql_avail(&dev_queue->dql);
> +#else
> + return DQL_MAX_LIMIT;
> +#endif
> +}
> +
> +/**
> + * netdev_avail_queue - report how much space is availble for xmit
> + * @dev: network device
> + *
> + * Report the amount of space available in the TX queue in terms of
> + * number of bytes. This returns the number of bytes avaiable per
> + * DQL. This function may be called without taking the txlock on
> + * the device, however in that case the result should be taken as
> + * a (strong) hint.
> + */
> +static inline int netdev_avail_queue(struct net_device *dev)
> +{
> + return netdev_tx_avail_queue(netdev_get_tx_queue(dev, 0));
> +}
> +
How can this work, when you are always passing 0 to: netdev_get_tx_queue(dev, 0)
???
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net-next] net: Functions to report space available in device TX queues
2014-09-03 13:20 ` Jesper Dangaard Brouer
@ 2014-09-03 13:41 ` Eric Dumazet
2014-09-03 13:49 ` Jesper Dangaard Brouer
0 siblings, 1 reply; 6+ messages in thread
From: Eric Dumazet @ 2014-09-03 13:41 UTC (permalink / raw)
To: Jesper Dangaard Brouer; +Cc: Tom Herbert, davem, netdev
On Wed, 2014-09-03 at 15:20 +0200, Jesper Dangaard Brouer wrote:
> On Mon, 25 Aug 2014 08:27:56 -0700 (PDT)
> Tom Herbert <therbert@google.com> wrote:
>
> > This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
> > used to report number of bytes available in transmit queues per BQL. The
> > functions call dql_avail which returns BQL limit minus number of
> > inflight bytes. These functions can be called without txlock, for
> > instance to ascertain how much data should be dequeued from a qdisc in
> > a batch. When called without the tx_lock, the result is technically a
> > hint, subsequently when the tx_lock is done for a transmit it is
> > possible the availability has changed (for example a transmit
> > completion may have freed up more space in the queue or changed the
> > limit).
> >
> > Signed-off-by: Tom Herbert <therbert@google.com>
> > ---
> > include/linux/netdevice.h | 28 ++++++++++++++++++++++++++--
> > 1 file changed, 26 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index 0fac884..bdf6c85 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2544,6 +2544,30 @@ static inline void netdev_completed_queue(struct net_device *dev,
> > netdev_tx_completed_queue(netdev_get_tx_queue(dev, 0), pkts, bytes);
> > }
> >
> > +static inline int netdev_tx_avail_queue(struct netdev_queue *dev_queue)
> > +{
> > +#ifdef CONFIG_BQL
> > + return dql_avail(&dev_queue->dql);
> > +#else
> > + return DQL_MAX_LIMIT;
> > +#endif
> > +}
> > +
> > +/**
> > + * netdev_avail_queue - report how much space is availble for xmit
> > + * @dev: network device
> > + *
> > + * Report the amount of space available in the TX queue in terms of
> > + * number of bytes. This returns the number of bytes avaiable per
> > + * DQL. This function may be called without taking the txlock on
> > + * the device, however in that case the result should be taken as
> > + * a (strong) hint.
> > + */
> > +static inline int netdev_avail_queue(struct net_device *dev)
> > +{
> > + return netdev_tx_avail_queue(netdev_get_tx_queue(dev, 0));
> > +}
> > +
>
> How can this work, when you are always passing 0 to: netdev_get_tx_queue(dev, 0)
> ???
>
This is the helper for drivers having a single TX queue.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 net-next] net: Functions to report space available in device TX queues
2014-09-03 13:41 ` Eric Dumazet
@ 2014-09-03 13:49 ` Jesper Dangaard Brouer
0 siblings, 0 replies; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2014-09-03 13:49 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Tom Herbert, davem, netdev, brouer
On Wed, 03 Sep 2014 06:41:57 -0700
Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Wed, 2014-09-03 at 15:20 +0200, Jesper Dangaard Brouer wrote:
> > On Mon, 25 Aug 2014 08:27:56 -0700 (PDT)
> > Tom Herbert <therbert@google.com> wrote:
> >
> > > This patch adds netdev_tx_avail_queue and netdev_avail_queue which are
> > > used to report number of bytes available in transmit queues per BQL. The
> > > functions call dql_avail which returns BQL limit minus number of
> > > inflight bytes. These functions can be called without txlock, for
> > > instance to ascertain how much data should be dequeued from a qdisc in
> > > a batch. When called without the tx_lock, the result is technically a
> > > hint, subsequently when the tx_lock is done for a transmit it is
> > > possible the availability has changed (for example a transmit
> > > completion may have freed up more space in the queue or changed the
> > > limit).
> > >
> > > Signed-off-by: Tom Herbert <therbert@google.com>
> > > ---
> > > include/linux/netdevice.h | 28 ++++++++++++++++++++++++++--
> > > 1 file changed, 26 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > > index 0fac884..bdf6c85 100644
> > > --- a/include/linux/netdevice.h
> > > +++ b/include/linux/netdevice.h
> > > @@ -2544,6 +2544,30 @@ static inline void netdev_completed_queue(struct net_device *dev,
> > > netdev_tx_completed_queue(netdev_get_tx_queue(dev, 0), pkts, bytes);
> > > }
> > >
> > > +static inline int netdev_tx_avail_queue(struct netdev_queue *dev_queue)
> > > +{
> > > +#ifdef CONFIG_BQL
> > > + return dql_avail(&dev_queue->dql);
> > > +#else
> > > + return DQL_MAX_LIMIT;
> > > +#endif
> > > +}
> > > +
> > > +/**
> > > + * netdev_avail_queue - report how much space is availble for xmit
> > > + * @dev: network device
> > > + *
> > > + * Report the amount of space available in the TX queue in terms of
> > > + * number of bytes. This returns the number of bytes avaiable per
> > > + * DQL. This function may be called without taking the txlock on
> > > + * the device, however in that case the result should be taken as
> > > + * a (strong) hint.
> > > + */
> > > +static inline int netdev_avail_queue(struct net_device *dev)
> > > +{
> > > + return netdev_tx_avail_queue(netdev_get_tx_queue(dev, 0));
> > > +}
> > > +
> >
> > How can this work, when you are always passing 0 to: netdev_get_tx_queue(dev, 0)
> > ???
> >
>
> This is the helper for drivers having a single TX queue.
Okay, so I should use:
bytelimit = netdev_tx_avail_queue(txq);
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Sr. Network Kernel Developer at Red Hat
Author of http://www.iptv-analyzer.org
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-09-03 13:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-25 15:27 [PATCH v2 net-next] net: Functions to report space available in device TX queues Tom Herbert
2014-08-26 0:33 ` David Miller
2014-08-26 15:44 ` Tom Herbert
2014-09-03 13:20 ` Jesper Dangaard Brouer
2014-09-03 13:41 ` Eric Dumazet
2014-09-03 13:49 ` Jesper Dangaard Brouer
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).