From: jamal <hadi@cyberus.ca>
To: David Miller <davem@davemloft.net>
Cc: xma@us.ibm.com, rdreier@cisco.com, ak@suse.de,
krkumar2@in.ibm.com, netdev@vger.kernel.org,
ashwin.chaugule@celunite.com,
Evgeniy Polyakov <johnpol@2ka.mipt.ru>,
Max Krasnyansky <maxk@qualcomm.com>,
Gagan Arneja <gagan@vmware.com>
Subject: Re: [WIP] [PATCH] WAS Re: [RFC] New driver API to speed up small packets xmits
Date: Tue, 15 May 2007 18:48:37 -0400 [thread overview]
Message-ID: <1179269317.4080.40.camel@localhost> (raw)
In-Reply-To: <1179267467.4080.33.camel@localhost>
[-- Attachment #1: Type: text/plain, Size: 681 bytes --]
On Tue, 2007-15-05 at 18:17 -0400, jamal wrote:
> I will post a patch for tun device in a few minutes
> that i use to test on my laptop (i need to remove some debugs) to show
> an example.
Ok, here it is.
The way i test is to point packets at a tun device. [One way i do it
is attach an ingress qdisc on lo; attach a u32 filter to match all;
on match redirect to the tun device].
The user space program reading sleeps for about a second every 20
packets or so. This forces things to accumulate in the drivers queue.
Backpressure builds up and the throttling effect is really nice to see
working.
I will try to post the e1000 patch tonight or tommorow morning.
cheers,
jamal
[-- Attachment #2: tun-b --]
[-- Type: text/x-patch, Size: 3734 bytes --]
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a2c6caa..076f794 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -70,6 +70,7 @@
static int debug;
#endif
+#define NETDEV_LTT 4 /* the low threshold to open up the tx path */
/* Network device part of the driver */
static LIST_HEAD(tun_dev_list);
@@ -86,9 +87,53 @@ static int tun_net_open(struct net_device *dev)
static int tun_net_close(struct net_device *dev)
{
netif_stop_queue(dev);
+ //skb_queue_purge(&dev->blist);
return 0;
}
+/* Batch Net device start xmit
+ * combine with non-batching version
+ * */
+static int tun_net_bxmit(struct sk_buff_head *skbs, struct net_device *dev)
+{
+ struct sk_buff *skb;
+ struct tun_struct *tun = netdev_priv(dev);
+ u32 qlen = skb_queue_len(&tun->readq);
+
+ /* Drop packet if interface is not attached */
+ if (!tun->attached) {
+ tun->stats.tx_dropped+=skb_queue_len(&dev->blist);
+ skb_queue_purge(&dev->blist);
+ return NETDEV_TX_OK;
+ }
+
+ while (skb_queue_len(&dev->blist)) {
+ skb = __skb_dequeue(skbs);
+ if (!skb)
+ break;
+ skb_queue_tail(&tun->readq, skb);
+ }
+
+ qlen = skb_queue_len(&tun->readq);
+ if (qlen >= dev->tx_queue_len) {
+ netif_stop_queue(dev);
+ tun->stats.tx_fifo_errors++;
+ dev->xmit_win = 1;
+ } else {
+ dev->xmit_win = dev->tx_queue_len - qlen;
+ }
+
+ /* Queue packet */
+ dev->trans_start = jiffies;
+
+ /* Notify and wake up reader process */
+ if (tun->flags & TUN_FASYNC)
+ kill_fasync(&tun->fasync, SIGIO, POLL_IN);
+ wake_up_interruptible(&tun->read_wait);
+
+ return NETDEV_TX_OK;
+}
+
/* Net device start xmit */
static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
{
@@ -207,6 +252,7 @@ static void tun_net_init(struct net_device *dev)
dev->tx_queue_len = TUN_READQ_SIZE; /* We prefer our own queue length */
break;
}
+ dev->xmit_win = dev->tx_queue_len>>1; /* handwave, handwave */
}
/* Character device part */
@@ -382,7 +428,13 @@ static ssize_t tun_chr_aio_read(struct kiocb *iocb, const struct iovec *iv,
schedule();
continue;
}
- netif_wake_queue(tun->dev);
+ {
+ u32 t = skb_queue_len(&tun->readq);
+ if (netif_queue_stopped(tun->dev) && t < NETDEV_LTT) {
+ tun->dev->xmit_win = tun->dev->tx_queue_len;
+ netif_wake_queue(tun->dev);
+ }
+ }
/** Decide whether to accept this packet. This code is designed to
* behave identically to an Ethernet interface. Accept the packet if
@@ -429,6 +481,7 @@ static void tun_setup(struct net_device *dev)
struct tun_struct *tun = netdev_priv(dev);
skb_queue_head_init(&tun->readq);
+ skb_queue_head_init(&dev->blist);
init_waitqueue_head(&tun->read_wait);
tun->owner = -1;
@@ -436,6 +489,8 @@ static void tun_setup(struct net_device *dev)
SET_MODULE_OWNER(dev);
dev->open = tun_net_open;
dev->hard_start_xmit = tun_net_xmit;
+ dev->hard_prep_xmit = NULL;
+ dev->hard_batch_xmit = tun_net_bxmit;
dev->stop = tun_net_close;
dev->get_stats = tun_net_stats;
dev->ethtool_ops = &tun_ethtool_ops;
@@ -458,7 +513,7 @@ static struct tun_struct *tun_get_by_name(const char *name)
static int tun_set_iff(struct file *file, struct ifreq *ifr)
{
struct tun_struct *tun;
- struct net_device *dev;
+ struct net_device *dev = NULL;
int err;
tun = tun_get_by_name(ifr->ifr_name);
@@ -528,12 +583,15 @@ static int tun_set_iff(struct file *file, struct ifreq *ifr)
}
DBG(KERN_INFO "%s: tun_set_iff\n", tun->dev->name);
+ dev->features |= NETIF_F_BTX;
if (ifr->ifr_flags & IFF_NO_PI)
tun->flags |= TUN_NO_PI;
- if (ifr->ifr_flags & IFF_ONE_QUEUE)
+ if (ifr->ifr_flags & IFF_ONE_QUEUE) {
tun->flags |= TUN_ONE_QUEUE;
+ dev->features &= ~NETIF_F_BTX;
+ }
file->private_data = tun;
tun->attached = 1;
next prev parent reply other threads:[~2007-05-15 22:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <OF0CAD6D87.DBE62968-ON872572DC.0073646A-882572DC.0073BEC2@us.ibm.com>
2007-05-15 21:17 ` [RFC] New driver API to speed up small packets xmits Roland Dreier
[not found] ` <OFF5654BB8.74EC8DCB-ON872572DC.00752079-882572DC.00756B23@us.ibm.com>
2007-05-15 21:25 ` Roland Dreier
[not found] ` <OF21D475A2.5E5C88DE-ON872572DC.00763DE4-882572DC.00768A7E@us.ibm.com>
2007-05-15 21:38 ` David Miller
2007-05-15 21:32 ` David Miller
2007-05-15 22:17 ` [WIP] [PATCH] WAS " jamal
2007-05-15 22:48 ` jamal [this message]
2007-05-16 0:50 ` jamal
2007-05-16 22:12 ` Sridhar Samudrala
2007-05-16 22:52 ` jamal
2007-05-17 3:25 ` jamal
2007-05-18 12:07 ` jamal
2007-05-17 4:03 ` Krishna Kumar2
2007-05-16 21:44 ` Sridhar Samudrala
2007-05-17 5:01 ` Krishna Kumar2
[not found] ` <OF6757F56D.EE5984FD-ON872572DC.0081026C-882572DC.00814B8F@us.ibm.com>
2007-05-15 23:36 ` David Miller
2007-05-21 7:56 ` Herbert Xu
[not found] ` <OF9ABCD08D.2CD1B193-ON872572E3.007A6FC1-882572E3.007ACE1A@us.ibm.com>
2007-05-22 22:36 ` David Miller
[not found] ` <OFCF3EB7F8.9740C0C7-ON872572E3.007DADF6-882572E3.007E0E7B@us.ibm.com>
2007-05-22 23:04 ` David Miller
2007-05-22 23:12 ` Herbert Xu
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=1179269317.4080.40.camel@localhost \
--to=hadi@cyberus.ca \
--cc=ak@suse.de \
--cc=ashwin.chaugule@celunite.com \
--cc=davem@davemloft.net \
--cc=gagan@vmware.com \
--cc=johnpol@2ka.mipt.ru \
--cc=krkumar2@in.ibm.com \
--cc=maxk@qualcomm.com \
--cc=netdev@vger.kernel.org \
--cc=rdreier@cisco.com \
--cc=xma@us.ibm.com \
/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).