* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: jamal @ 2010-12-04 14:55 UTC (permalink / raw)
To: Changli Gao; +Cc: Jarek Poplawski, netdev
In-Reply-To: <AANLkTimy_dK0uDCWqo3AZBKSvod+KnE6Om-CxrbFmPj+@mail.gmail.com>
On Sat, 2010-12-04 at 22:45 +0800, Changli Gao wrote:
>
> If we breaks the loop when there are still skbs in tq and no skb in
> rq, the skbs will be left in txq until new skbs are enqueued into rq.
> In rare cases, no new skb is queued, then these skbs will stay in rq
> forever.
So should we goto resched?
cheers,
jamal
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: Changli Gao @ 2010-12-04 14:50 UTC (permalink / raw)
To: hadi; +Cc: netdev
In-Reply-To: <1291473756.2159.31.camel@mojatatu>
On Sat, Dec 4, 2010 at 10:42 PM, jamal <hadi@cyberus.ca> wrote:
> On Sat, 2010-12-04 at 09:18 -0500, jamal wrote:
>
>> I like the splice idea but this patch makes me twitch
>> a little. What test setup did you use to check it?
>
> Ok, here's one thing you changed which is important. We do:
>
> -->XXX-->rq-->tq-->XXX-->
>
> rq is controlled by queue limit.
> We only load rq to tq if all of tq is empty. If it is not
> we dont move things over. Essentially this is a flow
> control scheme. We dont want many sources to be overwhelming
> us with packets and every time we grab a txqlen number of packets.
> For this reason:
> I would be comfortable if all you did was to add the splice
> after you skb_peek() - i think that would be a good improvement
> which is not bound to break anything else.
>
Maybe you misread my patch. tq is a stack variable in ri_tasklet, and
initialized all the time. ri_tasklet() won't exits until tq is
empty().
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply
* Re: Question about __alloc_skb() speedup
From: Eric Dumazet @ 2010-12-04 14:49 UTC (permalink / raw)
To: Junchang Wang; +Cc: netdev
In-Reply-To: <1291474058.2806.96.camel@edumazet-laptop>
Le samedi 04 décembre 2010 à 15:47 +0100, Eric Dumazet a écrit :
> Le samedi 04 décembre 2010 à 22:18 +0800, Junchang Wang a écrit :
>
> > I added the prefetchw() in pktgen as follows:
> >
> > diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> > index 2953b2a..512f1ae 100644
> > --- a/net/core/pktgen.c
> > +++ b/net/core/pktgen.c
> > @@ -2660,6 +2660,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
> > sprintf(pkt_dev->result, "No memory");
> > return NULL;
> > }
> > + prefetchw(skb->data);
> >
> > skb_reserve(skb, datalen);
> >
> > This time, I can check it without rebooting the system. The performance
> > gain is 4%-5%(stable). Does 4% worth submitting it to the kernel?
>
> Yes I believe so, pktgen being very specific, but I have few questions :
>
> Is it with SLUB or SLAB ?
>
> How many buffers in TX ring on you nic (ethtool -g eth0) ?
>
> What is the datalen value here ? (you prefetch, then advance skb->data)
>
> 32 or 64bit kernel ?
>
> How many pps do you get before and after patch ?
>
> Thanks
>
Also, dont forget to include the prefetchw() in fill_packet_ipv6() as
well when submitting your patch.
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: jamal @ 2010-12-04 14:48 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: Changli Gao, netdev
In-Reply-To: <1291472889.2159.18.camel@mojatatu>
On Sat, 2010-12-04 at 09:28 -0500, jamal wrote:
> The idea was to defer processing at the first error. Changli
> is changing it to continue despite the error.
> The initial goal was to yield whenever possible since we dont maintain
> a lot of state.
Changli:
Other points we could defer processing is in case of packets
being dropped by dev_queue_xmit and netif_rx
cheers,
jamal
^ permalink raw reply
* Re: Question about __alloc_skb() speedup
From: Eric Dumazet @ 2010-12-04 14:47 UTC (permalink / raw)
To: Junchang Wang; +Cc: netdev
In-Reply-To: <20101204141826.GA5830@Desktop-Junchang>
Le samedi 04 décembre 2010 à 22:18 +0800, Junchang Wang a écrit :
> I added the prefetchw() in pktgen as follows:
>
> diff --git a/net/core/pktgen.c b/net/core/pktgen.c
> index 2953b2a..512f1ae 100644
> --- a/net/core/pktgen.c
> +++ b/net/core/pktgen.c
> @@ -2660,6 +2660,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
> sprintf(pkt_dev->result, "No memory");
> return NULL;
> }
> + prefetchw(skb->data);
>
> skb_reserve(skb, datalen);
>
> This time, I can check it without rebooting the system. The performance
> gain is 4%-5%(stable). Does 4% worth submitting it to the kernel?
Yes I believe so, pktgen being very specific, but I have few questions :
Is it with SLUB or SLAB ?
How many buffers in TX ring on you nic (ethtool -g eth0) ?
What is the datalen value here ? (you prefetch, then advance skb->data)
32 or 64bit kernel ?
How many pps do you get before and after patch ?
Thanks
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: Changli Gao @ 2010-12-04 14:45 UTC (permalink / raw)
To: hadi; +Cc: Jarek Poplawski, netdev
In-Reply-To: <1291472889.2159.18.camel@mojatatu>
On Sat, Dec 4, 2010 at 10:28 PM, jamal <hadi@cyberus.ca> wrote:
> On Sat, 2010-12-04 at 14:15 +0100, Jarek Poplawski wrote:
>
>> > @@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
>> > rcu_read_unlock();
>> > dev_kfree_skb(skb);
>> > stats->tx_dropped++;
>> > - break;
>> > + continue;
>>
>> IMHO this line is a bugfix and should be a separate patch (for stable).
>
> Should be separate, yes.
> Bug? no.
If we breaks the loop when there are still skbs in tq and no skb in
rq, the skbs will be left in txq until new skbs are enqueued into rq.
In rare cases, no new skb is queued, then these skbs will stay in rq
forever.
- if (__netif_tx_trylock(txq)) {
- if ((skb = skb_peek(&dp->rq)) == NULL) {
- dp->tasklet_pending = 0;
- if (netif_queue_stopped(_dev))
- netif_wake_queue(_dev);
- } else {
- __netif_tx_unlock(txq);
- goto resched;
- }
- __netif_tx_unlock(txq);
- } else {
-resched:
- dp->tasklet_pending = 1;
- tasklet_schedule(&dp->ifb_tasklet);
- }
-
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: Changli Gao @ 2010-12-04 14:20 UTC (permalink / raw)
To: hadi; +Cc: netdev
In-Reply-To: <1291472282.2159.8.camel@mojatatu>
On Sat, Dec 4, 2010 at 10:18 PM, jamal <hadi@cyberus.ca> wrote:
>
> I like the splice idea but this patch makes me twitch
> a little. What test setup did you use to check it?
>
Just a simple test:
tc qdisc add dev eth0 ingress
tc filter add dev eth0 parent ffff: protocol ip basic action mirred
egress redirect dev ifb0
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: jamal @ 2010-12-04 14:42 UTC (permalink / raw)
To: Changli Gao; +Cc: netdev
In-Reply-To: <1291472282.2159.8.camel@mojatatu>
On Sat, 2010-12-04 at 09:18 -0500, jamal wrote:
> I like the splice idea but this patch makes me twitch
> a little. What test setup did you use to check it?
Ok, here's one thing you changed which is important. We do:
-->XXX-->rq-->tq-->XXX-->
rq is controlled by queue limit.
We only load rq to tq if all of tq is empty. If it is not
we dont move things over. Essentially this is a flow
control scheme. We dont want many sources to be overwhelming
us with packets and every time we grab a txqlen number of packets.
For this reason:
I would be comfortable if all you did was to add the splice
after you skb_peek() - i think that would be a good improvement
which is not bound to break anything else.
cheers,
jamal
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: jamal @ 2010-12-04 14:28 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: Changli Gao, netdev
In-Reply-To: <4CFA3F01.20109@gmail.com>
On Sat, 2010-12-04 at 14:15 +0100, Jarek Poplawski wrote:
> > @@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
> > rcu_read_unlock();
> > dev_kfree_skb(skb);
> > stats->tx_dropped++;
> > - break;
> > + continue;
>
> IMHO this line is a bugfix and should be a separate patch (for stable).
Should be separate, yes.
Bug? no.
Improvement, maybe ;->
The idea was to defer processing at the first error. Changli
is changing it to continue despite the error.
The initial goal was to yield whenever possible since we dont maintain
a lot of state.
cheers,
jamal
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: jamal @ 2010-12-04 14:18 UTC (permalink / raw)
To: Changli Gao; +Cc: netdev
In-Reply-To: <1291442121-3302-3-git-send-email-xiaosuo@gmail.com>
On Sat, 2010-12-04 at 13:55 +0800, Changli Gao wrote:
> tq is only used in ri_tasklet, so we move it from ifb_private to a
> stack variable of ri_tasklet.
>
> skb_queue_splice_tail_init() is used instead of the open coded and slow
> one.
I like the splice idea but this patch makes me twitch
a little. What test setup did you use to check it?
cheers,
jamal
^ permalink raw reply
* Re: Question about __alloc_skb() speedup
From: Junchang Wang @ 2010-12-04 14:18 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev
In-Reply-To: <1291373429.2897.96.camel@edumazet-laptop>
On Fri, Dec 03, 2010 at 11:50:29AM +0100, Eric Dumazet wrote:
>
>This is because __alloc_skb() is generic :
>
>We dont know if the skb->data is going to be used right after or not at
>all.
>
>For example, NIC drivers call __alloc_skb() to refill their RX ring
>buffer. There is no gain to prefetch data in this case since the data is
>going to be written by the NIC hardware. The reverse would be needed
>actually : ask to local cpu to evict data from its cache, so that device
>can DMA it faster (less bus transactions)
Thanks for your explanation. Now I understand your patch. :)
>
>By the way, adding prefetchw() right before the "return skb;" is
>probably not very useful.
Did you mean adding prefetchw() right before the "return" instruction
doesn't gain beneficial effect?
My understanding is that what prefetch instructions do is to hint cpu
to hot some cache lines, so this kind of prefetch could also benefit
following functions.
>You can certainly try to add the prefetchw()
>in pktgen itself, since you know for sure you are going to write the
>data.
>
>I dont understand your 10% speedup because pktgen actually uses
>__netdev_alloc_skb(), so it calls skb_reserve(skb, NET_SKB_PAD) : your
>prefetchw is bringing a cache line that wont be used at all by pktgen.
Thanks for corrections. Please check the following code.
>
>I would say 10% sounds highly suspect to me...
>
I repeated the experiment a number of times (>10). The number of 10% was
careless, but I confirmed there's speedup, which fall into (%3, 8%). I
found it hard to give the exact number of speedup because I had to reboot
the system each time I added the prefetch code.
I noticed the hardware prefetch(Hardware Prefetcher and Adjacent Cache
Line Prefetch) was turn on by default. I doubt my faulty code gain benefit
from hardware prefetch. Without those two options, the performance of
both pktgens reduced by 5%-8% and I can hardly see beneficial effect from
my previous code.
I added the prefetchw() in pktgen as follows:
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 2953b2a..512f1ae 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -2660,6 +2660,7 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
sprintf(pkt_dev->result, "No memory");
return NULL;
}
+ prefetchw(skb->data);
skb_reserve(skb, datalen);
This time, I can check it without rebooting the system. The performance
gain is 4%-5%(stable). Does 4% worth submitting it to the kernel?
Thanks.
--Junchang
^ permalink raw reply related
* Re: [PATCH 2/3] ifb: remove unused macro TX_TIMEOUT
From: jamal @ 2010-12-04 14:13 UTC (permalink / raw)
To: Changli Gao; +Cc: netdev
In-Reply-To: <1291442121-3302-2-git-send-email-xiaosuo@gmail.com>
On Sat, 2010-12-04 at 13:55 +0800, Changli Gao wrote:
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
cheers,
jamal
^ permalink raw reply
* Re: [PATCH 1/3] ifb: remove the useless debug stats
From: jamal @ 2010-12-04 14:12 UTC (permalink / raw)
To: Changli Gao; +Cc: netdev
In-Reply-To: <1291442121-3302-1-git-send-email-xiaosuo@gmail.com>
On Sat, 2010-12-04 at 13:55 +0800, Changli Gao wrote:
> These debug stats are not exported, and become useless.
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Given the complexity of ifb, these stats have proved useful over
the years - I would typically ask someone to printk them etc.
If you want me to get me excited (in a good way) you could export these
via link XSTATS ;-> If you dont have time, then it is likely
we are stable enough we can kill them in which case, here you go:
Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
cheers,
jamal
^ permalink raw reply
* Re: [PATCH] net: init ingress queue
From: Jarek Poplawski @ 2010-12-04 13:36 UTC (permalink / raw)
To: Changli Gao
Cc: David S. Miller, Eric Dumazet, Tom Herbert, Jiri Pirko, netdev
In-Reply-To: <1291465901-3189-1-git-send-email-xiaosuo@gmail.com>
Changli Gao wrote:
> The dev field of ingress queue is forgot to initialized, then NULL
> pointer dereference happens in qdisc_alloc().
>
> Move inits of tx queues to netif_alloc_netdev_queues().
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
> v2: factorize the two inits in netdev_init_queues() and move inits of
> tx queues to netif_alloc_netdev_queues().
> net/core/dev.c | 35 +++++++++++++----------------------
> 1 file changed, 13 insertions(+), 22 deletions(-)
> diff --git a/net/core/dev.c b/net/core/dev.c
> index cd24374..4a7fc32 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
I guess you should mention it's net-next problem, because some people
might be unnecessarily concerned (why they don't have such an oops ;-)
Jarek P.
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: Changli Gao @ 2010-12-04 13:29 UTC (permalink / raw)
To: Jarek Poplawski; +Cc: jamal, netdev
In-Reply-To: <4CFA3F01.20109@gmail.com>
On Sat, Dec 4, 2010 at 9:15 PM, Jarek Poplawski <jarkao2@gmail.com> wrote:
> Changli Gao wrote:
>> tq is only used in ri_tasklet, so we move it from ifb_private to a
>> stack variable of ri_tasklet.
>>
>> skb_queue_splice_tail_init() is used instead of the open coded and slow
>> one.
>>
>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>> ---
>> drivers/net/ifb.c | 49 ++++++++++++-------------------------------------
>> 1 file changed, 12 insertions(+), 37 deletions(-)
>> diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
>> index d1e362a..cd6e90d 100644
>> --- a/drivers/net/ifb.c
>> +++ b/drivers/net/ifb.c
>> @@ -39,9 +39,7 @@
>> #define TX_Q_LIMIT 32
>> struct ifb_private {
>> struct tasklet_struct ifb_tasklet;
>> - int tasklet_pending;
>> struct sk_buff_head rq;
>> - struct sk_buff_head tq;
>> };
>>
>> static int numifbs = 2;
>> @@ -53,27 +51,25 @@ static int ifb_close(struct net_device *dev);
>>
>> static void ri_tasklet(unsigned long dev)
>> {
>> -
>> struct net_device *_dev = (struct net_device *)dev;
>> struct ifb_private *dp = netdev_priv(_dev);
>> struct net_device_stats *stats = &_dev->stats;
>> struct netdev_queue *txq;
>> struct sk_buff *skb;
>> + struct sk_buff_head tq;
>>
>> + __skb_queue_head_init(&tq);
>> txq = netdev_get_tx_queue(_dev, 0);
>> - if ((skb = skb_peek(&dp->tq)) == NULL) {
>> - if (__netif_tx_trylock(txq)) {
>> - while ((skb = skb_dequeue(&dp->rq)) != NULL) {
>> - skb_queue_tail(&dp->tq, skb);
>> - }
>> - __netif_tx_unlock(txq);
>> - } else {
>> - /* reschedule */
>> - goto resched;
>> - }
>> + if (!__netif_tx_trylock(txq)) {
>> + tasklet_schedule(&dp->ifb_tasklet);
>> + return;
>> }
>> + skb_queue_splice_tail_init(&dp->rq, &tq);
>> + if (netif_tx_queue_stopped(txq))
>> + netif_tx_wake_queue(txq);
>> + __netif_tx_unlock(txq);
>>
>> - while ((skb = skb_dequeue(&dp->tq)) != NULL) {
>> + while ((skb = __skb_dequeue(&tq)) != NULL) {
>> u32 from = G_TC_FROM(skb->tc_verd);
>>
>> skb->tc_verd = 0;
>> @@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
>> rcu_read_unlock();
>> dev_kfree_skb(skb);
>> stats->tx_dropped++;
>> - break;
>> + continue;
>
> IMHO this line is a bugfix and should be a separate patch (for stable).
It sounds reasonable.
>
> The rest looks OK to me but you could probably skip locking of dp->rq
> similarly to tq.
>
OK. Thanks.
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply
* Re: [PATCH 3/3] ifb: move tq from ifb_private
From: Jarek Poplawski @ 2010-12-04 13:15 UTC (permalink / raw)
To: Changli Gao; +Cc: jamal, netdev
In-Reply-To: <1291442121-3302-3-git-send-email-xiaosuo@gmail.com>
Changli Gao wrote:
> tq is only used in ri_tasklet, so we move it from ifb_private to a
> stack variable of ri_tasklet.
>
> skb_queue_splice_tail_init() is used instead of the open coded and slow
> one.
>
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
> drivers/net/ifb.c | 49 ++++++++++++-------------------------------------
> 1 file changed, 12 insertions(+), 37 deletions(-)
> diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
> index d1e362a..cd6e90d 100644
> --- a/drivers/net/ifb.c
> +++ b/drivers/net/ifb.c
> @@ -39,9 +39,7 @@
> #define TX_Q_LIMIT 32
> struct ifb_private {
> struct tasklet_struct ifb_tasklet;
> - int tasklet_pending;
> struct sk_buff_head rq;
> - struct sk_buff_head tq;
> };
>
> static int numifbs = 2;
> @@ -53,27 +51,25 @@ static int ifb_close(struct net_device *dev);
>
> static void ri_tasklet(unsigned long dev)
> {
> -
> struct net_device *_dev = (struct net_device *)dev;
> struct ifb_private *dp = netdev_priv(_dev);
> struct net_device_stats *stats = &_dev->stats;
> struct netdev_queue *txq;
> struct sk_buff *skb;
> + struct sk_buff_head tq;
>
> + __skb_queue_head_init(&tq);
> txq = netdev_get_tx_queue(_dev, 0);
> - if ((skb = skb_peek(&dp->tq)) == NULL) {
> - if (__netif_tx_trylock(txq)) {
> - while ((skb = skb_dequeue(&dp->rq)) != NULL) {
> - skb_queue_tail(&dp->tq, skb);
> - }
> - __netif_tx_unlock(txq);
> - } else {
> - /* reschedule */
> - goto resched;
> - }
> + if (!__netif_tx_trylock(txq)) {
> + tasklet_schedule(&dp->ifb_tasklet);
> + return;
> }
> + skb_queue_splice_tail_init(&dp->rq, &tq);
> + if (netif_tx_queue_stopped(txq))
> + netif_tx_wake_queue(txq);
> + __netif_tx_unlock(txq);
>
> - while ((skb = skb_dequeue(&dp->tq)) != NULL) {
> + while ((skb = __skb_dequeue(&tq)) != NULL) {
> u32 from = G_TC_FROM(skb->tc_verd);
>
> skb->tc_verd = 0;
> @@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
> rcu_read_unlock();
> dev_kfree_skb(skb);
> stats->tx_dropped++;
> - break;
> + continue;
IMHO this line is a bugfix and should be a separate patch (for stable).
The rest looks OK to me but you could probably skip locking of dp->rq
similarly to tq.
Jarek P.
> }
> rcu_read_unlock();
> skb->skb_iif = _dev->ifindex;
> @@ -100,23 +96,6 @@ static void ri_tasklet(unsigned long dev)
> } else
> BUG();
> }
> -
> - if (__netif_tx_trylock(txq)) {
> - if ((skb = skb_peek(&dp->rq)) == NULL) {
> - dp->tasklet_pending = 0;
> - if (netif_queue_stopped(_dev))
> - netif_wake_queue(_dev);
> - } else {
> - __netif_tx_unlock(txq);
> - goto resched;
> - }
> - __netif_tx_unlock(txq);
> - } else {
> -resched:
> - dp->tasklet_pending = 1;
> - tasklet_schedule(&dp->ifb_tasklet);
> - }
> -
> }
>
> static const struct net_device_ops ifb_netdev_ops = {
> @@ -162,10 +141,8 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
> }
>
> skb_queue_tail(&dp->rq, skb);
> - if (!dp->tasklet_pending) {
> - dp->tasklet_pending = 1;
> + if (skb_queue_len(&dp->rq) == 1)
> tasklet_schedule(&dp->ifb_tasklet);
> - }
>
> return NETDEV_TX_OK;
> }
> @@ -177,7 +154,6 @@ static int ifb_close(struct net_device *dev)
> tasklet_kill(&dp->ifb_tasklet);
> netif_stop_queue(dev);
> skb_queue_purge(&dp->rq);
> - skb_queue_purge(&dp->tq);
> return 0;
> }
>
> @@ -187,7 +163,6 @@ static int ifb_open(struct net_device *dev)
>
> tasklet_init(&dp->ifb_tasklet, ri_tasklet, (unsigned long)dev);
> skb_queue_head_init(&dp->rq);
> - skb_queue_head_init(&dp->tq);
> netif_start_queue(dev);
>
> return 0;
^ permalink raw reply
* [PATCH] net: init ingress queue
From: Changli Gao @ 2010-12-04 12:31 UTC (permalink / raw)
To: David S. Miller
Cc: Eric Dumazet, Tom Herbert, Jiri Pirko, netdev, Changli Gao
The dev field of ingress queue is forgot to initialized, then NULL
pointer dereference happens in qdisc_alloc().
Move inits of tx queues to netif_alloc_netdev_queues().
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
v2: factorize the two inits in netdev_init_queues() and move inits of
tx queues to netif_alloc_netdev_queues().
net/core/dev.c | 35 +++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index cd24374..4a7fc32 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5109,11 +5109,21 @@ static int netif_alloc_rx_queues(struct net_device *dev)
}
#endif
+static void netdev_init_one_queue(struct net_device *dev,
+ struct netdev_queue *queue, void *_unused)
+{
+ /* Initialize queue lock */
+ spin_lock_init(&queue->_xmit_lock);
+ netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
+ queue->xmit_lock_owner = -1;
+ netdev_queue_numa_node_write(queue, -1);
+ queue->dev = dev;
+}
+
static int netif_alloc_netdev_queues(struct net_device *dev)
{
unsigned int count = dev->num_tx_queues;
struct netdev_queue *tx;
- int i;
BUG_ON(count < 1);
@@ -5125,27 +5135,10 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
}
dev->_tx = tx;
- for (i = 0; i < count; i++) {
- netdev_queue_numa_node_write(&tx[i], -1);
- tx[i].dev = dev;
- }
- return 0;
-}
-
-static void netdev_init_one_queue(struct net_device *dev,
- struct netdev_queue *queue,
- void *_unused)
-{
- /* Initialize queue lock */
- spin_lock_init(&queue->_xmit_lock);
- netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
- queue->xmit_lock_owner = -1;
-}
-
-static void netdev_init_queues(struct net_device *dev)
-{
netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL);
spin_lock_init(&dev->tx_global_lock);
+
+ return 0;
}
/**
@@ -5184,8 +5177,6 @@ int register_netdevice(struct net_device *dev)
dev->iflink = -1;
- netdev_init_queues(dev);
-
/* Init, if this function is available */
if (dev->netdev_ops->ndo_init) {
ret = dev->netdev_ops->ndo_init(dev);
^ permalink raw reply related
* Re: [PATCH 1/2] vsprintf: Add %pMbt, bluetooth mac address
From: Michał Mirosław @ 2010-12-04 11:03 UTC (permalink / raw)
To: Joe Perches; +Cc: Marcel Holtmann, Gustavo F. Padovan, linux-kernel, netdev
In-Reply-To: <a33a0b00eeb29713a08d91156cbb2d816176f990.1291419007.git.joe@perches.com>
2010/12/4 Joe Perches <joe@perches.com>:
> Bluetooth output the MAC address in reverse order.
> Bluetooth memory order: 00 01 02 03 04 05 is output "05:04:03:02:01:00".
>
> This can save overall text when bluetooth is compiled in.
>
> Bluetooth currently uses a very slightly unsafe local function (batostr)
> to output these formatted addresses.
>
> Adding %pMbt allows the batostr function to be removed.
Just a nitpick:
You could call it %pMR, as in 'Reverse', so it sounds better when/if
some other subsystem uses it. It would also be a hint of what is this
doing instead of where it came from.
Best Regards,
Michał Mirosław
^ permalink raw reply
* Re: [PATCH] net: init ingress queue
From: Changli Gao @ 2010-12-04 8:55 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S. Miller, Tom Herbert, Jiri Pirko, netdev
In-Reply-To: <1291452427.2806.90.camel@edumazet-laptop>
On Sat, Dec 4, 2010 at 4:47 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> Le samedi 04 décembre 2010 à 13:45 +0800, Changli Gao a écrit :
>> The dev field of ingress queue is forgot to initialized, then NULL
>> pointer dereference happens in qdisc_alloc().
>
> < deleted oops >
>
>> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
>> ---
>> net/core/dev.c | 2 ++
>> 1 file changed, 2 insertions(+)
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index cd24374..8083c68 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -5577,6 +5577,8 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
>> queue = kzalloc(sizeof(*queue), GFP_KERNEL);
>> if (!queue)
>> return NULL;
>> + netdev_queue_numa_node_write(queue, -1);
>> + queue->dev = dev;
>> netdev_init_one_queue(dev, queue, NULL);
>> queue->qdisc = &noop_qdisc;
>> queue->qdisc_sleeping = &noop_qdisc;
>
> Hi Changli, thanks for bug report and patch.
>
> IMHO there is no point to include this long Oops report in Changelog for
> a net-next-2.6 temporary problem, there wont be any bugzilla report.
>
OK, Thanks.
> Instead, you could say it is a followup patch for commits 1d24eb4815d1e0
> and f2cd2d3e9b3ef960. Two or three lines with relevant information.
>
> I suggest you submit following patch instead, as this seems cleaner to
> me ?
>
> (factorize the two inits in netdev_init_one_queue())
>
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index cd24374..36e10b4 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5113,7 +5113,6 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
> {
> unsigned int count = dev->num_tx_queues;
> struct netdev_queue *tx;
> - int i;
>
> BUG_ON(count < 1);
>
> @@ -5125,10 +5124,6 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
> }
> dev->_tx = tx;
>
> - for (i = 0; i < count; i++) {
> - netdev_queue_numa_node_write(&tx[i], -1);
> - tx[i].dev = dev;
> - }
> return 0;
> }
>
> @@ -5140,6 +5135,8 @@ static void netdev_init_one_queue(struct net_device *dev,
> spin_lock_init(&queue->_xmit_lock);
> netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
> queue->xmit_lock_owner = -1;
> + netdev_queue_numa_node_write(queue, -1);
> + queue->dev = dev;
> }
>
> static void netdev_init_queues(struct net_device *dev)
>
>
>
I thought about it before submitting. I am not sure if there are some
users of txq->dev before netdev_init_one_queue().
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply
* Re: [PATCH] net: init ingress queue
From: Eric Dumazet @ 2010-12-04 8:47 UTC (permalink / raw)
To: Changli Gao; +Cc: David S. Miller, Tom Herbert, Jiri Pirko, netdev
In-Reply-To: <1291441558-3196-1-git-send-email-xiaosuo@gmail.com>
Le samedi 04 décembre 2010 à 13:45 +0800, Changli Gao a écrit :
> The dev field of ingress queue is forgot to initialized, then NULL
> pointer dereference happens in qdisc_alloc().
< deleted oops >
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
> net/core/dev.c | 2 ++
> 1 file changed, 2 insertions(+)
> diff --git a/net/core/dev.c b/net/core/dev.c
> index cd24374..8083c68 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5577,6 +5577,8 @@ struct netdev_queue *dev_ingress_queue_create(struct net_device *dev)
> queue = kzalloc(sizeof(*queue), GFP_KERNEL);
> if (!queue)
> return NULL;
> + netdev_queue_numa_node_write(queue, -1);
> + queue->dev = dev;
> netdev_init_one_queue(dev, queue, NULL);
> queue->qdisc = &noop_qdisc;
> queue->qdisc_sleeping = &noop_qdisc;
Hi Changli, thanks for bug report and patch.
IMHO there is no point to include this long Oops report in Changelog for
a net-next-2.6 temporary problem, there wont be any bugzilla report.
Instead, you could say it is a followup patch for commits 1d24eb4815d1e0
and f2cd2d3e9b3ef960. Two or three lines with relevant information.
I suggest you submit following patch instead, as this seems cleaner to
me ?
(factorize the two inits in netdev_init_one_queue())
diff --git a/net/core/dev.c b/net/core/dev.c
index cd24374..36e10b4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5113,7 +5113,6 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
{
unsigned int count = dev->num_tx_queues;
struct netdev_queue *tx;
- int i;
BUG_ON(count < 1);
@@ -5125,10 +5124,6 @@ static int netif_alloc_netdev_queues(struct net_device *dev)
}
dev->_tx = tx;
- for (i = 0; i < count; i++) {
- netdev_queue_numa_node_write(&tx[i], -1);
- tx[i].dev = dev;
- }
return 0;
}
@@ -5140,6 +5135,8 @@ static void netdev_init_one_queue(struct net_device *dev,
spin_lock_init(&queue->_xmit_lock);
netdev_set_xmit_lockdep_class(&queue->_xmit_lock, dev->type);
queue->xmit_lock_owner = -1;
+ netdev_queue_numa_node_write(queue, -1);
+ queue->dev = dev;
}
static void netdev_init_queues(struct net_device *dev)
^ permalink raw reply related
* Re: kernel panic with time-stamping in phy devices (monitor mode)
From: Eric Dumazet @ 2010-12-04 8:17 UTC (permalink / raw)
To: Richard Cochran; +Cc: Andrew Watts, netdev, David Miller
In-Reply-To: <20101204075750.GA3949@riccoc20.at.omicron.at>
Le samedi 04 décembre 2010 à 08:57 +0100, Richard Cochran a écrit :
> Date: Sat, 4 Dec 2010 08:55:04 +0100
> From: Richard Cochran <richardcochran@gmail.com>
> To: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Andrew Watts <akwatts@ymail.com>, netdev@vger.kernel.org,
> David Miller <davem@davemloft.net>
> Subject: Re: kernel panic with time-stamping in phy devices (monitor mode)
> Message-ID: <20101204075503.GA3490@riccoc20.at.omicron.at>
> References: <252997.92320.qm@web111013.mail.gq1.yahoo.com>
> <1291307884.2871.69.camel@edumazet-laptop>
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> In-Reply-To: <1291307884.2871.69.camel@edumazet-laptop>
> User-Agent: Mutt/1.5.20 (2009-06-14)
>
> Ugh, new kernel code with no users is already causing trouble!
>
> On Thu, Dec 02, 2010 at 05:38:04PM +0100, Eric Dumazet wrote:
> > Thanks for the report
> >
> > Please try following patch.
>
> And thank you, Eric, for the quick patch.
>
> Can this fix go into 2.6.37, please?
Sure, I'll submit to David today, thanks !
^ permalink raw reply
* Re: kernel panic with time-stamping in phy devices (monitor mode)
From: Richard Cochran @ 2010-12-04 7:57 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Andrew Watts, netdev, David Miller
In-Reply-To: <1291307884.2871.69.camel@edumazet-laptop>
Date: Sat, 4 Dec 2010 08:55:04 +0100
From: Richard Cochran <richardcochran@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Andrew Watts <akwatts@ymail.com>, netdev@vger.kernel.org,
David Miller <davem@davemloft.net>
Subject: Re: kernel panic with time-stamping in phy devices (monitor mode)
Message-ID: <20101204075503.GA3490@riccoc20.at.omicron.at>
References: <252997.92320.qm@web111013.mail.gq1.yahoo.com>
<1291307884.2871.69.camel@edumazet-laptop>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1291307884.2871.69.camel@edumazet-laptop>
User-Agent: Mutt/1.5.20 (2009-06-14)
Ugh, new kernel code with no users is already causing trouble!
On Thu, Dec 02, 2010 at 05:38:04PM +0100, Eric Dumazet wrote:
> Thanks for the report
>
> Please try following patch.
And thank you, Eric, for the quick patch.
Can this fix go into 2.6.37, please?
Thanks,
Richard
^ permalink raw reply
* [PATCH 3/3] ifb: move tq from ifb_private
From: Changli Gao @ 2010-12-04 5:55 UTC (permalink / raw)
To: jamal; +Cc: netdev, jamal, Changli Gao
In-Reply-To: <1291442121-3302-1-git-send-email-xiaosuo@gmail.com>
tq is only used in ri_tasklet, so we move it from ifb_private to a
stack variable of ri_tasklet.
skb_queue_splice_tail_init() is used instead of the open coded and slow
one.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
drivers/net/ifb.c | 49 ++++++++++++-------------------------------------
1 file changed, 12 insertions(+), 37 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index d1e362a..cd6e90d 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -39,9 +39,7 @@
#define TX_Q_LIMIT 32
struct ifb_private {
struct tasklet_struct ifb_tasklet;
- int tasklet_pending;
struct sk_buff_head rq;
- struct sk_buff_head tq;
};
static int numifbs = 2;
@@ -53,27 +51,25 @@ static int ifb_close(struct net_device *dev);
static void ri_tasklet(unsigned long dev)
{
-
struct net_device *_dev = (struct net_device *)dev;
struct ifb_private *dp = netdev_priv(_dev);
struct net_device_stats *stats = &_dev->stats;
struct netdev_queue *txq;
struct sk_buff *skb;
+ struct sk_buff_head tq;
+ __skb_queue_head_init(&tq);
txq = netdev_get_tx_queue(_dev, 0);
- if ((skb = skb_peek(&dp->tq)) == NULL) {
- if (__netif_tx_trylock(txq)) {
- while ((skb = skb_dequeue(&dp->rq)) != NULL) {
- skb_queue_tail(&dp->tq, skb);
- }
- __netif_tx_unlock(txq);
- } else {
- /* reschedule */
- goto resched;
- }
+ if (!__netif_tx_trylock(txq)) {
+ tasklet_schedule(&dp->ifb_tasklet);
+ return;
}
+ skb_queue_splice_tail_init(&dp->rq, &tq);
+ if (netif_tx_queue_stopped(txq))
+ netif_tx_wake_queue(txq);
+ __netif_tx_unlock(txq);
- while ((skb = skb_dequeue(&dp->tq)) != NULL) {
+ while ((skb = __skb_dequeue(&tq)) != NULL) {
u32 from = G_TC_FROM(skb->tc_verd);
skb->tc_verd = 0;
@@ -87,7 +83,7 @@ static void ri_tasklet(unsigned long dev)
rcu_read_unlock();
dev_kfree_skb(skb);
stats->tx_dropped++;
- break;
+ continue;
}
rcu_read_unlock();
skb->skb_iif = _dev->ifindex;
@@ -100,23 +96,6 @@ static void ri_tasklet(unsigned long dev)
} else
BUG();
}
-
- if (__netif_tx_trylock(txq)) {
- if ((skb = skb_peek(&dp->rq)) == NULL) {
- dp->tasklet_pending = 0;
- if (netif_queue_stopped(_dev))
- netif_wake_queue(_dev);
- } else {
- __netif_tx_unlock(txq);
- goto resched;
- }
- __netif_tx_unlock(txq);
- } else {
-resched:
- dp->tasklet_pending = 1;
- tasklet_schedule(&dp->ifb_tasklet);
- }
-
}
static const struct net_device_ops ifb_netdev_ops = {
@@ -162,10 +141,8 @@ static netdev_tx_t ifb_xmit(struct sk_buff *skb, struct net_device *dev)
}
skb_queue_tail(&dp->rq, skb);
- if (!dp->tasklet_pending) {
- dp->tasklet_pending = 1;
+ if (skb_queue_len(&dp->rq) == 1)
tasklet_schedule(&dp->ifb_tasklet);
- }
return NETDEV_TX_OK;
}
@@ -177,7 +154,6 @@ static int ifb_close(struct net_device *dev)
tasklet_kill(&dp->ifb_tasklet);
netif_stop_queue(dev);
skb_queue_purge(&dp->rq);
- skb_queue_purge(&dp->tq);
return 0;
}
@@ -187,7 +163,6 @@ static int ifb_open(struct net_device *dev)
tasklet_init(&dp->ifb_tasklet, ri_tasklet, (unsigned long)dev);
skb_queue_head_init(&dp->rq);
- skb_queue_head_init(&dp->tq);
netif_start_queue(dev);
return 0;
^ permalink raw reply related
* [PATCH 2/3] ifb: remove unused macro TX_TIMEOUT
From: Changli Gao @ 2010-12-04 5:55 UTC (permalink / raw)
To: jamal; +Cc: netdev, jamal, Changli Gao
In-Reply-To: <1291442121-3302-1-git-send-email-xiaosuo@gmail.com>
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
drivers/net/ifb.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index 4387525..d1e362a 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -36,8 +36,6 @@
#include <net/pkt_sched.h>
#include <net/net_namespace.h>
-#define TX_TIMEOUT (2*HZ)
-
#define TX_Q_LIMIT 32
struct ifb_private {
struct tasklet_struct ifb_tasklet;
^ permalink raw reply related
* [PATCH 1/3] ifb: remove the useless debug stats
From: Changli Gao @ 2010-12-04 5:55 UTC (permalink / raw)
To: jamal; +Cc: netdev, jamal, Changli Gao
These debug stats are not exported, and become useless.
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
drivers/net/ifb.c | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ab9f675..4387525 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -42,16 +42,6 @@
struct ifb_private {
struct tasklet_struct ifb_tasklet;
int tasklet_pending;
- /* mostly debug stats leave in for now */
- unsigned long st_task_enter; /* tasklet entered */
- unsigned long st_txq_refl_try; /* transmit queue refill attempt */
- unsigned long st_rxq_enter; /* receive queue entered */
- unsigned long st_rx2tx_tran; /* receive to trasmit transfers */
- unsigned long st_rxq_notenter; /*receiveQ not entered, resched */
- unsigned long st_rx_frm_egr; /* received from egress path */
- unsigned long st_rx_frm_ing; /* received from ingress path */
- unsigned long st_rxq_check;
- unsigned long st_rxq_rsch;
struct sk_buff_head rq;
struct sk_buff_head tq;
};
@@ -73,19 +63,14 @@ static void ri_tasklet(unsigned long dev)
struct sk_buff *skb;
txq = netdev_get_tx_queue(_dev, 0);
- dp->st_task_enter++;
if ((skb = skb_peek(&dp->tq)) == NULL) {
- dp->st_txq_refl_try++;
if (__netif_tx_trylock(txq)) {
- dp->st_rxq_enter++;
while ((skb = skb_dequeue(&dp->rq)) != NULL) {
skb_queue_tail(&dp->tq, skb);
- dp->st_rx2tx_tran++;
}
__netif_tx_unlock(txq);
} else {
/* reschedule */
- dp->st_rxq_notenter++;
goto resched;
}
}
@@ -110,10 +95,8 @@ static void ri_tasklet(unsigned long dev)
skb->skb_iif = _dev->ifindex;
if (from & AT_EGRESS) {
- dp->st_rx_frm_egr++;
dev_queue_xmit(skb);
} else if (from & AT_INGRESS) {
- dp->st_rx_frm_ing++;
skb_pull(skb, skb->dev->hard_header_len);
netif_rx(skb);
} else
@@ -121,13 +104,11 @@ static void ri_tasklet(unsigned long dev)
}
if (__netif_tx_trylock(txq)) {
- dp->st_rxq_check++;
if ((skb = skb_peek(&dp->rq)) == NULL) {
dp->tasklet_pending = 0;
if (netif_queue_stopped(_dev))
netif_wake_queue(_dev);
} else {
- dp->st_rxq_rsch++;
__netif_tx_unlock(txq);
goto resched;
}
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox