sched: only dequeue if packet can be queued to hardware queue.
Subsystems (4)
RFC PATCH 1/1 sched: only dequeue if packet can be queued to hardware queue.
This this patch is mangled I appologize, this is my first try sending a patch directly to netdev.
The patch below is my attempt to resolve the issue found with qdisc_run only checking the state of queue zero before running. This approach essentially makes the qdisc layer smart enough to do it's own check to see if a hw queue is stopped instead of relying on other calls to check beforehand.
I have been able to verify functionality for most qdiscs with the exceptions of netem, red, sfq, and tbf. I am not familiar with the operation of these qdiscs and so I am not certain how to avoid the high drop rate I am currently seeing when using these qdiscs.
The main advantages of this patch can be seen using a netperf UDP_STREAM test to a slow interface with multiple queues and a qdisc such as pfifo, bfifo, or prio. For my testing I used an 82575 with 4 queues on a system with 8 cpus. When any queue other than 0 was used in the old method the cpu utilization for one core would go to 100%, using this new approach the cpu utilization for all queues was at the same level queue 0 was with the old approach.
---
This patch changes the behavior of the sch->dequeue to only dequeue a packet if the queue it is bound for is not currently stopped. This functionality is provided via a new op called smart_dequeue.
---
include/net/pkt_sched.h | 5 -- include/net/sch_generic.h | 27 ++++++++++ net/sched/sch_atm.c | 22 ++++++++ net/sched/sch_blackhole.c | 1 net/sched/sch_cbq.c | 118 ++++++++++++++++++++++++++++++++++++++++++++- net/sched/sch_dsmark.c | 47 ++++++++++++++++++ net/sched/sch_fifo.c | 2 + net/sched/sch_generic.c | 30 +++++++++-- net/sched/sch_gred.c | 34 +++++++++++++ net/sched/sch_hfsc.c | 86 ++++++++++++++++++++++++++++++++- net/sched/sch_htb.c | 82 ++++++++++++++++++++++++++++++- net/sched/sch_multiq.c | 45 ++++++++++++++--- net/sched/sch_netem.c | 40 +++++++++++++++ net/sched/sch_prio.c | 23 +++++++++ net/sched/sch_red.c | 22 ++++++++ net/sched/sch_sfq.c | 46 ++++++++++++++++-- net/sched/sch_tbf.c | 66 +++++++++++++++++++++++++ net/sched/sch_teql.c | 49 ++++++++++++++++--- 18 files changed, 706 insertions(+), 39 deletions(-)
include/net/pkt_sched.h +1 -4
@@ -90,10 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);static inline void qdisc_run (struct Qdisc *q) { -struct netdev_queue *txq = q->dev_queue; - -if (!netif_tx_queue_stopped (txq) && - !test_and_set_bit (__QDISC_STATE_RUNNING, &q->state)) +if (!test_and_set_bit (__QDISC_STATE_RUNNING, &q->state))__qdisc_run (q); }
include/net/sch_generic.h +27 -0
@@ -45,6 +45,7 @@ struct Qdisc#define TCQ_F_BUILTIN 1#define TCQ_F_THROTTLED 2#define TCQ_F_INGRESS 4 +#define TCQ_F_STOPPED 8int padded;struct Qdisc_ops *ops;struct qdisc_size_table *stab;
@@ -110,6 +111,7 @@ struct Qdisc_opsint (*enqueue)(struct sk_buff *,struct Qdisc *);struct sk_buff * (*dequeue)(struct Qdisc *); +struct sk_buff * (*smart_dequeue)(struct Qdisc *);int (*requeue)(struct sk_buff *,struct Qdisc *);unsigned int (*drop)(struct Qdisc *);
@@ -399,6 +401,31 @@ static inline int qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch)return __qdisc_enqueue_tail (skb, sch, &sch->q); } +static inline struct sk_buff *__qdisc_smart_dequeue (struct Qdisc *sch, +struct sk_buff_head *list) +{ +struct sk_buff *skb =skb_peek (list); +struct netdev_queue *txq; + +if (!skb) +return NULL ; + + txq =netdev_get_tx_queue (qdisc_dev (sch),skb_get_queue_mapping (skb)); +if (netif_tx_queue_stopped (txq) ||netif_tx_queue_frozen (txq)) { + sch->flags |=TCQ_F_STOPPED ; +return NULL ; + } +__skb_unlink (skb, list); + sch->qstats.backlog -=qdisc_pkt_len (skb); + sch->flags &= ~TCQ_F_STOPPED ; +return skb; +} + +static inline struct sk_buff *qdisc_smart_dequeue (struct Qdisc *sch) +{ +return __qdisc_smart_dequeue (sch, &sch->q); +} +static inline struct sk_buff *__qdisc_dequeue_head (struct Qdisc *sch,struct sk_buff_head *list) {
net/sched/sch_atm.c +21 -1
@@ -516,12 +516,31 @@ static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)pr_debug ("atm_tc_dequeue(sch %p,[qdisc %p])\n" , sch, p);tasklet_schedule (&p->task); - skb = p->link.q->dequeue (p->link.q); + skb = p->link.q->ops->dequeue (p->link.q);if (skb) sch->q.qlen--;return skb; } +static struct sk_buff *atm_tc_smart_dequeue (struct Qdisc *sch) +{ +struct atm_qdisc_data *p =qdisc_priv (sch); +struct sk_buff *skb; + +pr_debug ("atm_tc_smart_dequeue(sch %p,[qdisc %p])\n" , sch, p); +tasklet_schedule (&p->task); + skb = p->link.q->dequeue (p->link.q); +if (skb) { + sch->q.qlen--; + sch->flags &= ~TCQ_F_STOPPED ; + }else { +if (p->link.q->flags &TCQ_F_STOPPED ) + sch->flags |=TCQ_F_STOPPED ; + } + +return skb; +} +static int atm_tc_requeue (struct sk_buff *skb,struct Qdisc *sch) {struct atm_qdisc_data *p =qdisc_priv (sch);
@@ -694,6 +713,7 @@ static struct Qdisc_ops atm_qdisc_ops __read_mostly = { .priv_size = sizeof(struct atm_qdisc_data), .enqueue = atm_tc_enqueue, .dequeue = atm_tc_dequeue, + .smart_dequeue = atm_tc_smart_dequeue, .requeue = atm_tc_requeue, .drop = atm_tc_drop, .init = atm_tc_init,
net/sched/sch_blackhole.c +1 -0
@@ -33,6 +33,7 @@ static struct Qdisc_ops blackhole_qdisc_ops __read_mostly = { .priv_size = 0, .enqueue = blackhole_enqueue, .dequeue = blackhole_dequeue, + .smart_dequeue = blackhole_dequeue, .owner = THIS_MODULE, };
net/sched/sch_cbq.c +115 -3
154 lines not on this page · raw message
net/sched/sch_dsmark.c +47 -0
59 lines not on this page · raw message
net/sched/sch_fifo.c +2 -0
@@ -83,6 +83,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fifo_sched_data), .enqueue = pfifo_enqueue, .dequeue = qdisc_dequeue_head, + .smart_dequeue = qdisc_smart_dequeue, .requeue = qdisc_requeue, .drop = qdisc_queue_drop, .init = fifo_init,
@@ -98,6 +99,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fifo_sched_data), .enqueue = bfifo_enqueue, .dequeue = qdisc_dequeue_head, + .smart_dequeue = qdisc_smart_dequeue, .requeue = qdisc_requeue, .drop = qdisc_queue_drop, .init = fifo_init,
net/sched/sch_generic.c +23 -7
@@ -135,8 +135,7 @@ static inline int qdisc_restart(struct Qdisc *q) txq =netdev_get_tx_queue (dev,skb_get_queue_mapping (skb));HARD_TX_LOCK (dev, txq,smp_processor_id ()); -if (!netif_tx_queue_stopped (txq) && - !netif_tx_queue_frozen (txq)) +if (!netif_tx_queue_stopped (txq) && !netif_tx_queue_frozen (txq)) ret =dev_hard_start_xmit (skb, dev, txq);HARD_TX_UNLOCK (dev, txq);
@@ -163,10 +162,6 @@ static inline int qdisc_restart(struct Qdisc *q)break ; } -if (ret && (netif_tx_queue_stopped (txq) || -netif_tx_queue_frozen (txq))) - ret =0 ; -return ret; }
@@ -313,6 +308,7 @@ struct Qdisc_ops noop_qdisc_ops __read_mostly = { .priv_size = 0, .enqueue = noop_enqueue, .dequeue = noop_dequeue, + .smart_dequeue = noop_dequeue, .requeue = noop_requeue, .owner = THIS_MODULE, };
@@ -337,6 +333,7 @@ static struct Qdisc_ops noqueue_qdisc_ops __read_mostly = { .priv_size = 0, .enqueue = noop_enqueue, .dequeue = noop_dequeue, + .smart_dequeue = noop_dequeue, .requeue = noop_requeue, .owner = THIS_MODULE, };
@@ -400,6 +397,24 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)return NULL ; } +static struct sk_buff *pfifo_fast_smart_dequeue (struct Qdisc * qdisc) +{ +int prio; +struct sk_buff_head *list =qdisc_priv (qdisc); +struct sk_buff *skb; + +for (prio =0 ; prio <PFIFO_FAST_BANDS ; prio++) { +if (!skb_queue_empty (list + prio)) { + skb =__qdisc_smart_dequeue (qdisc, list + prio); +if (skb !=NULL ) + qdisc->q.qlen--; +return skb; + } + } + +return NULL ; +} +static int pfifo_fast_requeue (struct sk_buff *skb,struct Qdisc * qdisc) { qdisc->q.qlen++;
@@ -446,6 +461,7 @@ static struct Qdisc_ops pfifo_fast_ops __read_mostly = { .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head), .enqueue = pfifo_fast_enqueue, .dequeue = pfifo_fast_dequeue, + .smart_dequeue = pfifo_fast_smart_dequeue, .requeue = pfifo_fast_requeue, .init = pfifo_fast_init, .reset = pfifo_fast_reset,
@@ -475,7 +491,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,skb_queue_head_init (&sch->q); sch->ops = ops; sch->enqueue = ops->enqueue; - sch->dequeue = ops->dequeue; + sch->dequeue = ops->smart_dequeue; sch->dev_queue = dev_queue;dev_hold (qdisc_dev (sch));atomic_set (&sch->refcnt,1 );
net/sched/sch_gred.c +34 -0
@@ -292,6 +292,39 @@ static struct sk_buff *gred_dequeue(struct Qdisc* sch)return NULL ; } +static struct sk_buff *gred_smart_dequeue (struct Qdisc * sch) +{ +struct sk_buff *skb; +struct gred_sched *t =qdisc_priv (sch); + + skb =qdisc_smart_dequeue (sch); + +if (skb) { +struct gred_sched_data *q; +u16 dp =tc_index_to_dp (skb); + +if (dp >= t->DPs || (q = t->tab[dp]) ==NULL ) { +if (net_ratelimit ()) +printk (KERN_WARNING "GRED: Unable to relocate " +"VQ 0x%x after dequeue, screwing up " +"backlog.\n" ,tc_index_to_dp (skb)); + }else { + q->backlog -=qdisc_pkt_len (skb); + +if (!q->backlog && !gred_wred_mode (t)) +red_start_of_idle_period (&q->parms); + } + +return skb; + } + +if (!(sch->flags &TCQ_F_STOPPED ) &&gred_wred_mode (t) && + !red_is_idling (&t->wred_set)) +red_start_of_idle_period (&t->wred_set); + +return NULL ; +} +static unsigned int gred_drop (struct Qdisc * sch) {struct sk_buff *skb;
@@ -602,6 +635,7 @@ static struct Qdisc_ops gred_qdisc_ops __read_mostly = { .priv_size = sizeof(struct gred_sched), .enqueue = gred_enqueue, .dequeue = gred_dequeue, + .smart_dequeue = gred_smart_dequeue, .requeue = gred_requeue, .drop = gred_drop, .init = gred_init,
net/sched/sch_hfsc.c +84 -2
110 lines not on this page · raw message
net/sched/sch_htb.c +79 -3
114 lines not on this page · raw message
net/sched/sch_multiq.c +38 -7
59 lines not on this page · raw message
net/sched/sch_netem.c +39 -1
@@ -283,7 +283,7 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)if (sch->flags &TCQ_F_THROTTLED )return NULL ; - skb = q->qdisc->dequeue (q->qdisc); + skb = q->qdisc->ops->dequeue (q->qdisc);if (skb) {const struct netem_skb_cb *cb =netem_skb_cb (skb);psched_time_t now =psched_get_time ();
@@ -308,6 +308,42 @@ static struct sk_buff *netem_dequeue(struct Qdisc *sch)return NULL ; } +static struct sk_buff *netem_smart_dequeue (struct Qdisc *sch) +{ +struct netem_sched_data *q =qdisc_priv (sch); +struct sk_buff *skb; + +smp_mb (); +if (sch->flags &TCQ_F_THROTTLED ) +return NULL ; + + skb = q->qdisc->dequeue (q->qdisc); +if (skb) { +const struct netem_skb_cb *cb =netem_skb_cb (skb); +psched_time_t now =psched_get_time (); + +/* if more time remaining? */ +if (cb->time_to_send <= now) { +pr_debug ("netem_dequeue: return skb=%p\n" , skb); + sch->q.qlen--; + sch->flags &= ~TCQ_F_STOPPED ; +return skb; + } + +if (unlikely (q->qdisc->ops->requeue (skb, q->qdisc) !=NET_XMIT_SUCCESS )) { +qdisc_tree_decrease_qlen (q->qdisc,1 ); + sch->qstats.drops++; +printk (KERN_ERR "netem: %s could not requeue\n" , + q->qdisc->ops->id); + } + +qdisc_watchdog_schedule (&q->watchdog, cb->time_to_send); + }else if (q->qdisc->flags &TCQ_F_STOPPED ) { + sch->flags |=TCQ_F_STOPPED ; + } + +return NULL ; +}static void netem_reset (struct Qdisc *sch) {struct netem_sched_data *q =qdisc_priv (sch);
@@ -541,6 +577,7 @@ static struct Qdisc_ops tfifo_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fifo_sched_data), .enqueue = tfifo_enqueue, .dequeue = qdisc_dequeue_head, + .smart_dequeue = qdisc_smart_dequeue, .requeue = qdisc_requeue, .drop = qdisc_queue_drop, .init = tfifo_init,
@@ -716,6 +753,7 @@ static struct Qdisc_ops netem_qdisc_ops __read_mostly = { .priv_size = sizeof(struct netem_sched_data), .enqueue = netem_enqueue, .dequeue = netem_dequeue, + .smart_dequeue = netem_smart_dequeue, .requeue = netem_requeue, .drop = netem_drop, .init = netem_init,
net/sched/sch_prio.c +23 -0
@@ -128,11 +128,33 @@ static struct sk_buff *prio_dequeue(struct Qdisc* sch)for (prio =0 ; prio < q->bands; prio++) {struct Qdisc *qdisc = q->queues[prio]; +struct sk_buff *skb = qdisc->ops->dequeue (qdisc); +if (skb) { + sch->q.qlen--; +return skb; + } + } +return NULL ; + +} + +static struct sk_buff *prio_smart_dequeue (struct Qdisc * sch) +{ +struct prio_sched_data *q =qdisc_priv (sch); +int prio; + +for (prio =0 ; prio < q->bands; prio++) { +struct Qdisc *qdisc = q->queues[prio];struct sk_buff *skb = qdisc->dequeue (qdisc);if (skb) { sch->q.qlen--; + sch->flags &= ~TCQ_F_STOPPED ;return skb; } +if (qdisc->flags &TCQ_F_STOPPED ) { + sch->flags |=TCQ_F_STOPPED ; +return NULL ; + } }return NULL ;
@@ -421,6 +443,7 @@ static struct Qdisc_ops prio_qdisc_ops __read_mostly = { .priv_size = sizeof(struct prio_sched_data), .enqueue = prio_enqueue, .dequeue = prio_dequeue, + .smart_dequeue = prio_smart_dequeue, .requeue = prio_requeue, .drop = prio_drop, .init = prio_init,
net/sched/sch_red.c +21 -1
@@ -131,7 +131,7 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)struct red_sched_data *q =qdisc_priv (sch);struct Qdisc *child = q->qdisc; - skb = child->dequeue (child); + skb = child->ops->dequeue (child);if (skb) sch->q.qlen--;else if (!red_is_idling (&q->parms))
@@ -140,6 +140,25 @@ static struct sk_buff * red_dequeue(struct Qdisc* sch)return skb; } +static struct sk_buff *red_smart_dequeue (struct Qdisc * sch) +{ +struct sk_buff *skb; +struct red_sched_data *q =qdisc_priv (sch); +struct Qdisc *child = q->qdisc; + + skb = child->dequeue (child); +if (skb) { + sch->q.qlen--; + sch->flags &= ~TCQ_F_STOPPED ; + }else { +if (child->flags &TCQ_F_STOPPED ) + sch->flags |=TCQ_F_STOPPED ; +else if (!red_is_idling (&q->parms)) +red_start_of_idle_period (&q->parms); + } + +return skb; +}static unsigned int red_drop (struct Qdisc * sch) {struct red_sched_data *q =qdisc_priv (sch);
@@ -361,6 +380,7 @@ static struct Qdisc_ops red_qdisc_ops __read_mostly = { .cl_ops = &red_class_ops, .enqueue = red_enqueue, .dequeue = red_dequeue, + .smart_dequeue = red_smart_dequeue, .requeue = red_requeue, .drop = red_drop, .init = red_init,
net/sched/sch_sfq.c +43 -3
64 lines not on this page · raw message
net/sched/sch_tbf.c +66 -0
91 lines not on this page · raw message
net/sched/sch_teql.c +42 -7
61 lines not on this page · raw message
Quoted 3 lines · Alexander Duyck
This this patch is mangled I appologize, this is my first try sending a patch directly to netdev.
Already off to mangling things. I got Dave's email wrong.. Sorry to all who reply and get a bad address warning, and I meant to say "If this patch is mangled..".
Anyway if anyone decides to reply please make note of the bad address.
Thanks,
Alex
David Miller
maintainerFrom: Alexander Duyck <[email protected]>
Date: Wed, 17 Sep 2008 23:43:02 -0700
Quoted 5 lines
net/sched/sch_atm.c +0
-0
net/sched/sch_atm.c static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch) · line 524
Quoted 10 lines
net/sched/sch_atm.c +1
-1@@ -516,12 +516,31 @@ static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)pr_debug ("atm_tc_dequeue(sch %p,[qdisc %p])\n" , sch, p);tasklet_schedule (&p->task); - skb = p->link.q->dequeue (p->link.q); + skb = p->link.q->ops->dequeue (p->link.q);if (skb) sch->q.qlen--;return skb; }
So what is the difference between qdisc->dequeue and qdisc->ops->dequeue? The same applies to ->enqueue.
qdisc->{dequeue,enqueue} are given the value of ops->{dequeue,enqueue} at the time of qdisc creation. I can only see two reasons for their existence:
1) We used to allow overriding ->enqueue and ->dequeue by certain modules. I see no such use like this in the current tree.
2) For performance it's kept as a copy in the qdisc.
Either way, changing ->ops->dequeue into ->dequeue doesn't seem to be correct, unless you have some explanation.
This is done in a few other places in your patch.
Quoted 10 lines · David Miller
So what is the difference between
qdisc->dequeueandqdisc->ops->dequeue? The same applies to ->enqueue.qdisc->{dequeue,enqueue} are given the value of ops->{dequeue,enqueue} at the time of qdisc creation. I can only see two reasons for their existence:
1) We used to allow overriding ->enqueue and ->dequeue by certain modules. I see no such use like this in the current tree.
Quoted 6 lines
2) For performance it's kept as a copy in the qdisc.
Either way, changing ->ops->dequeue into ->dequeue doesn't seem to be correct, unless you have some explanation.
This is done in a few other places in your patch.
I redefined qdisc->dequeue to be set to smart_dequeue in sch_generic.c:
@@ -475,7 +491,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
skb_queue_head_init(&sch->q);
sch->ops = ops;
sch->enqueue = ops->enqueue;
- sch->dequeue = ops->dequeue;
+ sch->dequeue = ops->smart_dequeue;
sch->dev_queue = dev_queue;
dev_hold(qdisc_dev(sch));
atomic_set(&sch->refcnt, 1);Most of the changes from qdisc->dequeue to qdisc->ops->dequeue are to have the standard dequeue call use nothing but standard dequeue calls in it's path. I needed
to maintain qdisc->ops->dequeue because there are several functions throughout the qdisc code that require the ability to dequeue a packet regardless of hw queue
state.
Thanks,
Alex
Alexander Duyck wrote, On 09/18/2008 08:43 AM:
...
Quoted 8 lines
---
This patch changes the behavior of thesch->dequeueto only dequeue a packet if the queue it is bound for is not currently stopped. This functionality is provided via a new op calledsmart_dequeue.Signed-off-by Alexander Duyck <[email protected]>---
I think, these changes make sense only if they don't add more then give, and two dequeues (and still no way to kill requeue) is IMHO too much. (I mean the maintenance.) As far as I can see it's mainly for HFSC's qdisc_peek_len(), anyway this looks like main issue to me.
Below a few small doubts. (I need to find some time for details yet.) BTW, this patch needs a checkpatch run.
---
include/net/pkt_sched.h +0 -3
@@ -90,10 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);static inline void qdisc_run (struct Qdisc *q) { -struct netdev_queue *txq = q->dev_queue; - - if (!netif_tx_queue_stopped(txq) &&
I think, there is no reason to do a full dequeue try each time instead of this check, even if we save on requeuing now. We could try to save the result of the last dequeue, e.g. a number or some mask of a few tx_queues which prevented dequeuing, and check for the change of state only. (Or alternatively, what I mentioned before: a flag set with the full stop or freeze.)
- !test_and_set_bit(__QDISC_STATE_RUNNING, &q->state))
+ if (!test_and_set_bit(__QDISC_STATE_RUNNING, &q->state))
__qdisc_run(q);
}
include/net/sch_generic.h +0 -0
...
+static inline struct sk_buff *__qdisc_smart_dequeue(struct Qdisc *sch,
+ struct sk_buff_head *list)
+{
+ struct sk_buff *skb = skb_peek(list);
Since success is much more likely here, __skb_dequeue() with __skb_queue_head() on fail looks better to me.
Of course, it's a matter of taste, but (if we really need these two dequeues) maybe qdisc_dequeue_smart() would be more in line with qdisc_dequeue_head()? (And similarly smart names below.)
+ struct netdev_queue *txq;
+
+ if (!skb)
+ return NULL;
+
+ txq = netdev_get_tx_queue(qdisc_dev(sch), skb_get_queue_mapping(skb));
+ if (netif_tx_queue_stopped(txq) || netif_tx_queue_frozen(txq)) {
+ sch->flags |= TCQ_F_STOPPED;
+ return NULL;
+ }
+ __skb_unlink(skb, list);
+ sch->qstats.backlog -= qdisc_pkt_len(skb);
+ sch->flags &= ~TCQ_F_STOPPED;
This clearing is probably needed in ->reset() and in ->drop() too. (Or above, after if (!skb))
...
net/sched/sch_htb.c +0 -0
...
+static struct sk_buff *htb_smart_dequeue(struct Qdisc *sch) +{
+ struct sk_buff *skb = NULL;
+ struct htb_sched *q = qdisc_priv(sch);
+ int level, stopped = false;
+ psched_time_t next_event;
+
+ /* try to dequeue direct packets as high prio (!) to minimize cpu work */
+ skb = skb_peek(&q->direct_queue);
As above: __skb_dequeue()?
Thanks,
Jarek P.
Quoted 4 lines · Jarek Poplawski
I think, these changes make sense only if they don't add more then give, and two dequeues (and still no way to kill requeue) is IMHO too much. (I mean the maintenance.) As far as I can see it's mainly for HFSC's
qdisc_peek_len(), anyway this looks like main issue to me.
The thing is this was just meant to be a proof of concept for the most part so I was doing a lot of cut and paste coding, and as a result the size increased by a good amount. I admit this could be cleaned up a lot I just wanted to verify some things.
Also my ultimate goal wasn't to kill requeue completely as you can't do that since in the case of TSO/GSO you will end up with SKBs which require multiple transmit descriptors and therefore you will always need an option to requeue. The advantage with this approach is that you don't incur the CPU cost, which is a significant savings when you compare the requeue approach which was generating 13% cpu to the smart dequeue which was only using 3%.
Quoted 2 lines
Below a few small doubts. (I need to find some time for details yet.) BTW, this patch needs a checkpatch run.
I did run checkpatch on this. Most of the errors are inherited from the cut and paste and I didn't want to take the time to completely rewrite the core qdisc functionality. Other than those errors I believe some were whitespace complaints as I was using tabs to the start of my functions and then spaces to indent my function parameters in the case of having to wrap for long lines.
Quoted 13 lines
---
include/net/pkt_sched.h +0
-3@@ -90,10 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);static inline void qdisc_run (struct Qdisc *q) { -struct netdev_queue *txq = q->dev_queue; - - if (!netif_tx_queue_stopped(txq) &&
Quoted 6 lines
I think, there is no reason to do a full dequeue try each time instead of this check, even if we save on requeuing now. We could try to save the result of the last dequeue, e.g. a number or some mask of a few
tx_queueswhich prevented dequeuing, and check for the change of state only. (Or alternatively, what I mentioned before: a flag set with the full stop or freeze.)
Once again if you have a suggestion on approach feel free to modify the patch and see how it works for you. My only concern is that there are several qdiscs which won't give you the same packet twice and so you don't know what is going to pop out until you go in and check.
Quoted 16 lines
include/net/pkt_sched.h +1
-1- !test_and_set_bit(__QDISC_STATE_RUNNING, &q->state)) +if (!test_and_set_bit (__QDISC_STATE_RUNNING, &q->state))__qdisc_run (q); }include/net/sch_generic.h +4
-0+static inline struct sk_buff *__qdisc_smart_dequeue (struct Qdisc *sch, +struct sk_buff_head *list) +{ +struct sk_buff *skb =skb_peek (list);
Quoted 6 lines
Since success is much more likely here,
__skb_dequeue()with__skb_queue_head()on fail looks better to me.Of course, it's a matter of taste, but (if we really need these two dequeues) maybe
qdisc_dequeue_smart()would be more in line withqdisc_dequeue_head()? (And similarly smart names below.)
Right, but then we are getting back to the queue/requeue stuff. If you want feel free to make use of my patch to generate your own that uses that approach. I just don't like changing things unless I absolutely have to and all I did is essentially tear apart __skb_dequeue and place the bits inline with my testing for netif_tx_subqueue_stopped.
Quoted 14 lines
include/net/sch_generic.h +13
-0+struct netdev_queue *txq; + +if (!skb) +return NULL ; + + txq =netdev_get_tx_queue (qdisc_dev (sch),skb_get_queue_mapping (skb)); +if (netif_tx_queue_stopped (txq) ||netif_tx_queue_frozen (txq)) { + sch->flags |=TCQ_F_STOPPED ; +return NULL ; + } +__skb_unlink (skb, list); + sch->qstats.backlog -=qdisc_pkt_len (skb); + sch->flags &= ~TCQ_F_STOPPED ;
Quoted 2 lines
This clearing is probably needed in ->reset() and in ->drop() too. (Or above, after if (!skb))
For the most part I would agree with you, but for now I was only using the flag as a part of the smart_dequeue process to flag the upper queues so I didn't give it much thought. It is yet another thing I probably should have cleaned up but didn't get around to since this was mostly proof of concept.
Quoted 16 lines
...
net/sched/sch_htb.c +9
-0+static struct sk_buff *htb_smart_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb =NULL ; +struct htb_sched *q =qdisc_priv (sch); +int level, stopped = false; +psched_time_t next_event; + +/* try to dequeue direct packets as high prio (!) to minimize cpu work */ + skb =skb_peek (&q->direct_queue);
Quoted 1 line
As above:
__skb_dequeue()?
Actually I could probably replace most of the skb_peek stuff with calls to __qdisc_smart_dequeue instead and then just check for the flag on fail.
Quoted 2 lines
Thanks,
Jarek P.
I probably won't be able to contribute to this for at least the next two weeks since I am going to be out for vacation from Saturday until the start of October.
In the meantime I also just threw a couple of patches out which may help anyone who is trying to test this stuff. Turns out if you try to do a netperf UDP_STREAM test on a multiqueue aware system with 2.6.27 you get horrible performance on the receive side. The root cause appears to be that simple_tx_hash was doing a hash on fragmented packets and as a result placing packets in psuedo random queues which caused issues with packet ordering.
Thanks,
Alex
Quoted 4 lines · Alexander Duyck
Once again if you have a suggestion on approach feel free to modify the patch and see how it works for you. My only concern is that there are several qdiscs which won't give you the same packet twice and so you don't know what is going to pop out until you go in and check.
...
Actually, here is my suggestion: I think, that your obviously more complex solution should be compared with something simple which IMHO has similar feature, i.e. limited overhead of requeuing.
My proposal is to use partly David's idea of killing ->ops->requeue(), for now only the first two patches, so don't requeue back to the qdiscs, but leave qdisc->ops->requeue() for internal usage (like in HFSC's qdisc_peek_len() hack). Additionaly I use your idea of early checking the state of tx queue to make this even lighter after possibly removing the entry check from qdisc_run().
I attach my patch at the end, after original David's two patches.
Thanks,
Jarek P.
---------------> patch 1/3
Subject: [PATCH 1/9]: pkt_sched: Make qdisc->gso_skb a list.
Date: Mon, 18 Aug 2008 01:36:47 -0700 (PDT)
From: David Miller <[email protected]>
To: [email protected]
CC: [email protected]
Newsgroups: gmane.linux.network
pkt_sched: Make qdisc->gso_skb a list.
The idea is that we can use this to get rid of
->requeue().
--- include/net/sch_generic.h | 2 +- net/sched/sch_generic.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
include/net/sch_generic.h +1 -1
@@ -52,7 +52,7 @@ struct Qdiscu32 parent;atomic_t refcnt;unsigned long state; -struct sk_buff *gso_skb; +struct sk_buff_head requeue;struct sk_buff_head q;struct netdev_queue *dev_queue;struct Qdisc *next_sched;
net/sched/sch_generic.c +7 -5
@@ -45,7 +45,7 @@ static inline int qdisc_qlen(struct Qdisc *q)static inline int dev_requeue_skb (struct sk_buff *skb,struct Qdisc *q) {if (unlikely (skb->next)) - q->gso_skb = skb; +__skb_queue_head (&q->requeue, skb);else q->ops->requeue (skb, q);
@@ -57,9 +57,8 @@ static inline struct sk_buff *dequeue_skb(struct Qdisc *q) {struct sk_buff *skb; -if ((skb = q->gso_skb)) - q->gso_skb =NULL ; -else + skb =__skb_dequeue (&q->requeue); +if (!skb) skb = q->dequeue (q);return skb;
@@ -328,6 +327,7 @@ struct Qdisc noop_qdisc = { .flags = TCQ_F_BUILTIN, .ops = &noop_qdisc_ops, .list = LIST_HEAD_INIT(noop_qdisc.list), + .requeue.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock), .q.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock), .dev_queue = &noop_netdev_queue, };
@@ -353,6 +353,7 @@ static struct Qdisc noqueue_qdisc = { .flags = TCQ_F_BUILTIN, .ops = &noqueue_qdisc_ops, .list = LIST_HEAD_INIT(noqueue_qdisc.list), + .requeue.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock), .q.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock), .dev_queue = &noqueue_netdev_queue, };
@@ -473,6 +474,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, sch->padded = (char *) sch - (char *) p;INIT_LIST_HEAD (&sch->list); +skb_queue_head_init (&sch->requeue);skb_queue_head_init (&sch->q); sch->ops = ops; sch->enqueue = ops->enqueue;
@@ -543,7 +545,7 @@ void qdisc_destroy(struct Qdisc *qdisc)module_put (ops->owner);dev_put (qdisc_dev (qdisc)); -kfree_skb (qdisc->gso_skb); +__skb_queue_purge (&qdisc->requeue);kfree ((char *) qdisc - qdisc->padded); }
-------------> patch 2/3
Subject: [PATCH 2/9]: pkt_sched: Always use q->requeue in dev_requeue_skb().
Date: Mon, 18 Aug 2008 01:36:50 -0700 (PDT)
From: David Miller <[email protected]>
To: [email protected]
CC: [email protected]
Newsgroups: gmane.linux.network
pkt_sched: Always use q->requeue in dev_requeue_skb().
There is no reason to call into the complicated qdiscs just to remember the last SKB where we found the device blocked.
The SKB is outside of the qdiscs realm at this point.
--- net/sched/sch_generic.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
net/sched/sch_generic.c +1 -4
@@ -44,10 +44,7 @@ static inline int qdisc_qlen(struct Qdisc *q)static inline int dev_requeue_skb (struct sk_buff *skb,struct Qdisc *q) { -if (unlikely (skb->next)) -__skb_queue_head (&q->requeue, skb); -else - q->ops->requeue (skb, q); +__skb_queue_head (&q->requeue, skb);__netif_schedule (q);return 0 ;
----------------> patch 3/3
pkt_sched: Check the state of tx_queue in dequeue_skb()
Check in dequeue_skb() the state of tx_queue for requeued skb to save on locking and re-requeuing, and possibly remove the current check in qdisc_run(). Based on the idea of Alexander Duyck.
---
net/sched/sch_generic.c +13 -3
@@ -52,11 +52,21 @@ static inline int dev_requeue_skb(structstatic inline struct sk_buff *dequeue_skb (struct Qdisc *q) { -struct sk_buff *skb; +struct sk_buff *skb =skb_peek (&q->requeue); - skb =__skb_dequeue (&q->requeue); -if (!skb) +if (unlikely (skb)) { +struct net_device *dev =qdisc_dev (q); +struct netdev_queue *txq; + +/* check the reason of requeuing without tx lock first */ + txq =netdev_get_tx_queue (dev,skb_get_queue_mapping (skb)); +if (!netif_tx_queue_stopped (txq) && !netif_tx_queue_frozen (txq)) +__skb_unlink (skb, &q->requeue); +else + skb =NULL ; + }else { skb = q->dequeue (q); + }return skb; }
Take 2:
I missed __netif_schedule() in my patch, so the update below.
But, because of this a little change of mind: there is no reason to repeat __netif_schedule() if there is a full stop or freeze of all queues, so it seems we need additional check for this anyway. I'll send my proposal of this test soon.
Jarek P.
Quoted 4 lines · Alexander Duyck
Once again if you have a suggestion on approach feel free to modify the patch and see how it works for you. My only concern is that there are several qdiscs which won't give you the same packet twice and so you don't know what is going to pop out until you go in and check.
...
Actually, here is my suggestion: I think, that your obviously more complex solution should be compared with something simple which IMHO has similar feature, i.e. limited overhead of requeuing.
My proposal is to use partly David's idea of killing ->ops->requeue(), for now only the first two patches, so don't requeue back to the qdiscs, but leave qdisc->ops->requeue() for internal usage (like in HFSC's qdisc_peek_len() hack). Additionaly I use your idea of early checking the state of tx queue to make this even lighter after possibly removing the entry check from qdisc_run().
I attach my patch at the end, after original David's two patches.
Thanks,
Jarek P.
---------------> patch 1/3
Subject: [PATCH 1/9]: pkt_sched: Make qdisc->gso_skb a list.
Date: Mon, 18 Aug 2008 01:36:47 -0700 (PDT)
From: David Miller <[email protected]>
To: [email protected]
CC: [email protected]
Newsgroups: gmane.linux.network
pkt_sched: Make qdisc->gso_skb a list.
The idea is that we can use this to get rid of
->requeue().
--- include/net/sch_generic.h | 2 +- net/sched/sch_generic.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-)
include/net/sch_generic.h +1 -1
@@ -52,7 +52,7 @@ struct Qdiscu32 parent;atomic_t refcnt;unsigned long state; -struct sk_buff *gso_skb; +struct sk_buff_head requeue;struct sk_buff_head q;struct netdev_queue *dev_queue;struct Qdisc *next_sched;
net/sched/sch_generic.c +7 -5
@@ -45,7 +45,7 @@ static inline int qdisc_qlen(struct Qdisc *q)static inline int dev_requeue_skb (struct sk_buff *skb,struct Qdisc *q) {if (unlikely (skb->next)) - q->gso_skb = skb; +__skb_queue_head (&q->requeue, skb);else q->ops->requeue (skb, q);
@@ -57,9 +57,8 @@ static inline struct sk_buff *dequeue_skb(struct Qdisc *q) {struct sk_buff *skb; -if ((skb = q->gso_skb)) - q->gso_skb =NULL ; -else + skb =__skb_dequeue (&q->requeue); +if (!skb) skb = q->dequeue (q);return skb;
@@ -328,6 +327,7 @@ struct Qdisc noop_qdisc = { .flags = TCQ_F_BUILTIN, .ops = &noop_qdisc_ops, .list = LIST_HEAD_INIT(noop_qdisc.list), + .requeue.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock), .q.lock = __SPIN_LOCK_UNLOCKED(noop_qdisc.q.lock), .dev_queue = &noop_netdev_queue, };
@@ -353,6 +353,7 @@ static struct Qdisc noqueue_qdisc = { .flags = TCQ_F_BUILTIN, .ops = &noqueue_qdisc_ops, .list = LIST_HEAD_INIT(noqueue_qdisc.list), + .requeue.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock), .q.lock = __SPIN_LOCK_UNLOCKED(noqueue_qdisc.q.lock), .dev_queue = &noqueue_netdev_queue, };
@@ -473,6 +474,7 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, sch->padded = (char *) sch - (char *) p;INIT_LIST_HEAD (&sch->list); +skb_queue_head_init (&sch->requeue);skb_queue_head_init (&sch->q); sch->ops = ops; sch->enqueue = ops->enqueue;
@@ -543,7 +545,7 @@ void qdisc_destroy(struct Qdisc *qdisc)module_put (ops->owner);dev_put (qdisc_dev (qdisc)); -kfree_skb (qdisc->gso_skb); +__skb_queue_purge (&qdisc->requeue);kfree ((char *) qdisc - qdisc->padded); }
-------------> patch 2/3
Subject: [PATCH 2/9]: pkt_sched: Always use q->requeue in dev_requeue_skb().
Date: Mon, 18 Aug 2008 01:36:50 -0700 (PDT)
From: David Miller <[email protected]>
To: [email protected]
CC: [email protected]
Newsgroups: gmane.linux.network
pkt_sched: Always use q->requeue in dev_requeue_skb().
There is no reason to call into the complicated qdiscs just to remember the last SKB where we found the device blocked.
The SKB is outside of the qdiscs realm at this point.
--- net/sched/sch_generic.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
net/sched/sch_generic.c +1 -4
@@ -44,10 +44,7 @@ static inline int qdisc_qlen(struct Qdisc *q)static inline int dev_requeue_skb (struct sk_buff *skb,struct Qdisc *q) { -if (unlikely (skb->next)) -__skb_queue_head (&q->requeue, skb); -else - q->ops->requeue (skb, q); +__skb_queue_head (&q->requeue, skb);__netif_schedule (q);return 0 ;
----------------> patch 3/3 (take 2)
pkt_sched: Check the state of tx_queue in dequeue_skb()
Check in dequeue_skb() the state of tx_queue for requeued skb to save on locking and re-requeuing, and possibly remove the current check in qdisc_run(). Based on the idea of Alexander Duyck.
---
net/sched/sch_generic.c +16 -3
@@ -52,11 +52,24 @@ static inline int dev_requeue_skb(structstatic inline struct sk_buff *dequeue_skb (struct Qdisc *q) { -struct sk_buff *skb; +struct sk_buff *skb =skb_peek (&q->requeue); - skb =__skb_dequeue (&q->requeue); -if (!skb) +if (unlikely (skb)) { +struct net_device *dev =qdisc_dev (q); +struct netdev_queue *txq; + +/* check the reason of requeuing without tx lock first */ + txq =netdev_get_tx_queue (dev,skb_get_queue_mapping (skb)); +if (!netif_tx_queue_stopped (txq) && + !netif_tx_queue_frozen (txq)) { +__skb_unlink (skb, &q->requeue); + }else { + skb =NULL ; +__netif_schedule (q); + } + }else { skb = q->dequeue (q); + }return skb; }
PATCH 1/1 pkt_sched: Fix TX state checking in qdisc_run()
pkt_sched: Fix TX state checking in qdisc_run()
Current check wrongly uses the state of the first tx queue for all tx queues. This patch brings back per dev __LINK_STATE_XOFF flag, which is set when all tx queues are stopped. This check is needed in qdisc_run() to avoid useless __netif_schedule() calls.
---
include/linux/netdevice.h | 7 ++++++- include/net/pkt_sched.h | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-)
include/linux/netdevice.h +6 -1
@@ -271,6 +271,7 @@ struct header_ops {enum netdev_state_t { + __LINK_STATE_XOFF, __LINK_STATE_START, __LINK_STATE_PRESENT, __LINK_STATE_NOCARRIER,
@@ -1043,6 +1044,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)static inline void netif_wake_queue (struct net_device *dev) {netif_tx_wake_queue (netdev_get_tx_queue (dev,0 )); +clear_bit (__LINK_STATE_XOFF, &dev->state); }static inline void netif_tx_wake_all_queues (struct net_device *dev)
@@ -1053,6 +1055,7 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)struct netdev_queue *txq =netdev_get_tx_queue (dev, i);netif_tx_wake_queue (txq); } +clear_bit (__LINK_STATE_XOFF, &dev->state); }static inline void netif_tx_stop_queue (struct netdev_queue *dev_queue)
@@ -1069,6 +1072,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)*/ static inline void netif_stop_queue (struct net_device *dev) { +set_bit (__LINK_STATE_XOFF, &dev->state);netif_tx_stop_queue (netdev_get_tx_queue (dev,0 )); }
@@ -1076,6 +1080,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) {unsigned int i; +set_bit (__LINK_STATE_XOFF, &dev->state);for (i =0 ; i < dev->num_tx_queues; i++) {struct netdev_queue *txq =netdev_get_tx_queue (dev, i);netif_tx_stop_queue (txq);
@@ -1095,7 +1100,7 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)*/ static inline int netif_queue_stopped (const struct net_device *dev) { -return netif_tx_queue_stopped (netdev_get_tx_queue (dev,0 )); +return test_bit (__LINK_STATE_XOFF, &dev->state); }static inline int netif_tx_queue_frozen (const struct netdev_queue *dev_queue)
include/net/pkt_sched.h +1 -3
@@ -90,9 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);static inline void qdisc_run (struct Qdisc *q) { -struct netdev_queue *txq = q->dev_queue; - -if (!netif_tx_queue_stopped (txq) && +if (!netif_queue_stopped (qdisc_dev (q)) && !test_and_set_bit (__QDISC_STATE_RUNNING, &q->state))__qdisc_run (q); }
PATCH 1/1 pkt_sched: Fix TX state checking in qdisc_run()
In reply to Jarek PoplawskiAlas this time the changelog needs more details.
Sorry,
Jarek P.
-----------------> (take 2)
pkt_sched: Fix TX state checking in qdisc_run()
Current check wrongly uses the state of the first tx queue for all tx queues in case of non-default qdiscs. This patch brings back per dev __LINK_STATE_XOFF flag, which is set when all tx queues are stopped. This check is needed in qdisc_run() to avoid useless __netif_schedule() calls. The wrongness of this check was first noticed by Herbert Xu.
---
include/linux/netdevice.h | 7 ++++++- include/net/pkt_sched.h | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-)
include/linux/netdevice.h +6 -1
@@ -271,6 +271,7 @@ struct header_ops {enum netdev_state_t { + __LINK_STATE_XOFF, __LINK_STATE_START, __LINK_STATE_PRESENT, __LINK_STATE_NOCARRIER,
@@ -1043,6 +1044,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue)static inline void netif_wake_queue (struct net_device *dev) {netif_tx_wake_queue (netdev_get_tx_queue (dev,0 )); +clear_bit (__LINK_STATE_XOFF, &dev->state); }static inline void netif_tx_wake_all_queues (struct net_device *dev)
@@ -1053,6 +1055,7 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev)struct netdev_queue *txq =netdev_get_tx_queue (dev, i);netif_tx_wake_queue (txq); } +clear_bit (__LINK_STATE_XOFF, &dev->state); }static inline void netif_tx_stop_queue (struct netdev_queue *dev_queue)
@@ -1069,6 +1072,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue)*/ static inline void netif_stop_queue (struct net_device *dev) { +set_bit (__LINK_STATE_XOFF, &dev->state);netif_tx_stop_queue (netdev_get_tx_queue (dev,0 )); }
@@ -1076,6 +1080,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) {unsigned int i; +set_bit (__LINK_STATE_XOFF, &dev->state);for (i =0 ; i < dev->num_tx_queues; i++) {struct netdev_queue *txq =netdev_get_tx_queue (dev, i);netif_tx_stop_queue (txq);
@@ -1095,7 +1100,7 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)*/ static inline int netif_queue_stopped (const struct net_device *dev) { -return netif_tx_queue_stopped (netdev_get_tx_queue (dev,0 )); +return test_bit (__LINK_STATE_XOFF, &dev->state); }static inline int netif_tx_queue_frozen (const struct netdev_queue *dev_queue)
include/net/pkt_sched.h +1 -3
@@ -90,9 +90,7 @@ extern void __qdisc_run(struct Qdisc *q);static inline void qdisc_run (struct Qdisc *q) { -struct netdev_queue *txq = q->dev_queue; - -if (!netif_tx_queue_stopped (txq) && +if (!netif_queue_stopped (qdisc_dev (q)) && !test_and_set_bit (__QDISC_STATE_RUNNING, &q->state))__qdisc_run (q); }
--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH take2] pkt_sched: Fix TX state checking in qdisc_run()
Jarek Poplawski wrote, On 09/19/2008 04:44 PM:
Quoted 7 lines
Alas this time the changelog needs more details.
Sorry,
Jarek P.
-----------------> (take 2)
pkt_sched: Fix TX state checking inqdisc_run()
David,
After reading Alexander's opinion I withdaw this patch (take 1 & 2) as well.
Sorry,
Jarek P.
David Miller
maintainerRe: [PATCH take2] pkt_sched: Fix TX state checking in qdisc_run()
In reply to Jarek PoplawskiFrom: Jarek Poplawski <[email protected]>
Date: Fri, 19 Sep 2008 16:44:50 +0200
Quoted 9 lines
pkt_sched: Fix TX state checking inqdisc_run()Current check wrongly uses the state of the first tx queue for all tx queues in case of non-default qdiscs. This patch brings back per dev
__LINK_STATE_XOFFflag, which is set when all tx queues are stopped. This check is needed inqdisc_run()to avoid useless__netif_schedule()calls. The wrongness of this check was first noticed by Herbert Xu.Signed-off-by Jarek Poplawski <[email protected]>
I'm dropping this and the patches in the ->smart_requeue thread as well.
It simply isn't crystal clear how to proceed at this point.
Jarek Poplawski wrote, On 09/19/2008 12:32 PM:
Quoted 2 lines
Take 2:
I missed__netif_schedule()in my patch, so the update below.
David,
After rethinking and reading Alexender's opinion I see this change isn't needed so I withdraw this take 2.
Please, reconsider the first version of this patch (with your 2 patches), yet.
Thanks,
Jarek P.
Quoted 10 lines · Jarek Poplawski
Alexander Duyck wrote, On 09/18/2008 08:43 AM:
...Quoted 8 lines
---
This patch changes the behavior of thesch->dequeueto only dequeue a packet if the queue it is bound for is not currently stopped. This functionality is provided via a new op calledsmart_dequeue.Signed-off-by Alexander Duyck <[email protected]>---
Alexander, I guess you've seen my last messages/patches in this thread and noticed that this __netif_schedule() problem is present both in this RFC patch and sch_multiq: if skb isn't dequeued because of inner tx_queue stopped state check, there is missing __netif_schedule() before exit from qdisc_run().
Jarek P.
Quoted 12 lines · Jarek Poplawski
Quoted 10 lines · Jarek Poplawski
Alexander Duyck wrote, On 09/18/2008 08:43 AM:
...Quoted 8 lines
---
This patch changes the behavior of thesch->dequeueto only dequeue a packet if the queue it is bound for is not currently stopped. This functionality is provided via a new op calledsmart_dequeue.Signed-off-by Alexander Duyck <[email protected]>---
Quoted 7 lines
Alexander, I guess you've seen my last messages/patches in this thread and noticed that this
__netif_schedule()problem is present both in this RFC patch andsch_multiq: if skb isn't dequeued because of innertx_queuestopped state check, there is missing__netif_schedule()before exit fromqdisc_run().Jarek P.
Actually most of that is handled in the fact that netif_tx_wake_queue will call __netif_schedule when it decides to wake up a queue that has been stopped. Putting it in skb_dequeue is unnecessary, and the way you did it would cause issues because you should be scheduling the root qdisc, not the one currently doing the dequeue.
My bigger concern is the fact one queue is back to stopping all queues. By using one global XOFF state, you create head-of-line blocking. I can see the merit in this approach but the problem is for multiqueue the queues really should be independent. What your change does is reduce the benefit of having multiqueue by throwing in a new state which pretty much matches what netif_stop/wake_queue used to do in the 2.6.26 version of tx multiqueue.
Also changing dequeue_skb will likely cause additional issues for several qdiscs as it doesn't report anything up to parent queues, as a result you will end up with qdiscs like prio acting more like multiq because they won't know if a queue is empty, stopped, or throttled. Also I believe this will cause a panic on pfifo_fast and several other qdiscs because some check to see if there are packets in the queue and if so dequeue with the assumption that they will get a packet out. You will need to add checks for this to resolve this issue.
The one thing I liked about my approach was that after I was done you could have prio as a parent of multiq leaves or multiq as the parent of prio leaves and all the hardware queues would receive the packets in the same order as the result.
Thanks,
Alex
On Fri, Sep 19, 2008 at 09:26:29AM -0700, Duyck, Alexander H wrote:
...
Quoted 3 lines
Actually most of that is handled in the fact that
netif_tx_wake_queuewill call__netif_schedulewhen it decides to wake up a queue that has been stopped. Putting it inskb_dequeueis unnecessary,
You are right, I've just noticed this too, and I'll withdraw this change.
Quoted 3 lines
and the way
you did it would cause issues because you should be scheduling the root qdisc, not the one currently doing the dequeue.
I think, this is the right way (but useless here).
Quoted 7 lines
My bigger concern is the fact one queue is back to stopping all queues. By using one global XOFF state, you create head-of-line blocking. I can see the merit in this approach but the problem is for multiqueue the queues really should be independent. What your change does is reduce the benefit of having multiqueue by throwing in a new state which pretty much matches what netif_stop/wake_queue used to do in the 2.6.26 version of tx multiqueue.
Do you mean netif_tx_stop_all_queues() and then netif_tx_wake_queue() before netif_tx_wake_all_queues()? OK, I'll withdraw this patch too.
Quoted 8 lines
Also changing
dequeue_skbwill likely cause additional issues for several qdiscs as it doesn't report anything up to parent queues, as a result you will end up with qdiscs like prio acting more like multiq because they won't know if a queue is empty, stopped, or throttled. Also I believe this will cause a panic onpfifo_fastand several other qdiscs because some check to see if there are packets in the queue and if so dequeue with the assumption that they will get a packet out. You will need to add checks for this to resolve this issue.
I really can't get your point. Don't you mean skb_dequeue()? dequeue_skb() is used only by qdisc_restart()...
Quoted 4 lines
The one thing I liked about my approach was that after I was done you could have prio as a parent of multiq leaves or multiq as the parent of prio leaves and all the hardware queues would receive the packets in the same order as the result.
I'm not against your approach, but I'd like to be sure these complications are really worth of it. Of course, if my proposal, the first take of 3 patches, doesn't work as you predict (and I doubt), then we can forget about it.
Thanks,
Jarek P.
Quoted 11 lines · Jarek Poplawski
Quoted 10 lines
Also changing
dequeue_skbwill likely cause additional issues for several qdiscs as it doesn't report anything up to parent queues, as a result you will end up with qdiscs like prio acting more like multiq because they won't know if a queue is empty, stopped, or throttled.
Also I believe this will cause a panic onpfifo_fastand several other qdiscs because some check to see if there are packets in the queue and if so dequeue with the assumption that they will get a packet out. You will need to add checks for this to resolve this issue.
Quoted 2 lines
I really can't get your point. Don't you mean
skb_dequeue()?dequeue_skb()is used only byqdisc_restart()...
You're right. I misread it as skb_dequeue. The problem is though you are still relying on q->requeue which last I knew was only being used a few qdiscs. In addition you will still be taking the cpu hit for the dequeue/requeue on several qdiscs which can't use q->requeue without violating the way they were supposed to work.
Quoted 9 lines
Quoted 4 lines
The one thing I liked about my approach was that after I was done you could have prio as a parent of multiq leaves or multiq as the parent of prio leaves and all the hardware queues would receive the packets in the same order as the result.
I'm not against your approach, but I'd like to be sure these complications are really worth of it. Of course, if my proposal, the first take of 3 patches, doesn't work as you predict (and I doubt), then we can forget about it.
Well when you get some testing done let me know. The main areas I am concerned with are:
1. CPU utilization stays the same regardless of which queue used. 2. Maintain current qdisc behavior on a per hw queue basis. 3. Avoid head-of-line blocking where it applies
for example: prio band 0 not blocked by band 1, or 1 by 2, etc..
or
multiq not blocked on any band due to 1 band blocked
As long as all 3 criteria are met I would be happy with any solution provided.
Thanks,
Alex
Quoted 13 lines · Alexander H
Quoted 11 lines · Jarek Poplawski
Quoted 10 lines
Also changing
dequeue_skbwill likely cause additional issues for several qdiscs as it doesn't report anything up to parent queues, as a result you will end up with qdiscs like prio acting more like multiq because they won't know if a queue is empty, stopped, or throttled.
Also I believe this will cause a panic onpfifo_fastand several other qdiscs because some check to see if there are packets in the queue and if so dequeue with the assumption that they will get a packet out. You will need to add checks for this to resolve this issue.
Quoted 7 lines
Quoted 2 lines
I really can't get your point. Don't you mean
skb_dequeue()?dequeue_skb()is used only byqdisc_restart()...You're right. I misread it as
skb_dequeue. The problem is though you are still relying onq->requeuewhich last I knew was only being used a few qdiscs. In addition you will still be taking the cpu hit for the dequeue/requeue on several qdiscs which can't useq->requeuewithout violating the way they were supposed to work.
I'm not sure I understand your point. No qdisc will use any new q->requeue. All qdisc do dequeue, but on tx fail an skb isn't requeued back, but queued by qdisc_restart() in a private list (of root qdisc), and then tried before any new dequeuing. There will be no cpu hit, because each next try is only skb_peek() on this list, until tx queue of an skb at the head is working.
Quoted 15 lines
Quoted 9 lines
Quoted 4 lines
The one thing I liked about my approach was that after I was done you could have prio as a parent of multiq leaves or multiq as the parent of prio leaves and all the hardware queues would receive the packets in the same order as the result.
I'm not against your approach, but I'd like to be sure these complications are really worth of it. Of course, if my proposal, the first take of 3 patches, doesn't work as you predict (and I doubt), then we can forget about it.
Well when you get some testing done let me know. The main areas I am concerned with are:
1. CPU utilization stays the same regardless of which queue used. 2. Maintain current qdisc behavior on a per hw queue basis. 3. Avoid head-of-line blocking where it applies
Quoted 6 lines
for example: prio band 0 not blocked by band 1, or 1 by 2, etc..
or
multiq not blocked on any band due to 1 band blockedAs long as all 3 criteria are met I would be happy with any solution provided.
Alas this testing is both the weekest (I'm not going to do this), and the strongest side of this solution, because it's mostly David's work (my patch could be actually skipped without much impact). So, I hope, you don't suggest this could be not enough tested or otherwise not the best?!
Anyway, I don't insist on "my" solution. I simply think it's reasonable, and it's not for private reasons, because I didn't even find this out. I think, if it's so wrong you should have no problem to show this in one little test. And maybe David changed his mind in the meantime and he will choose your way even without this.
Thanks,
Jarek P.
Quoted 7 lines · Jarek Poplawski
On Fri, Sep 19, 2008 at 11:01:12AM -0700, Duyck, Alexander H wrote:
I'm not sure I understand your point. No qdisc will use any newq->requeue. All qdisc do dequeue, but on tx fail an skb isn't requeued back, but queued byqdisc_restart()in a private list (of root qdisc), and then tried before any new dequeuing. There will be no cpu hit, because each next try is onlyskb_peek()on this list, until tx queue of an skb at the head is working.
It was me missing a piece. I didn't look over the portion where Dave changed requeue to always use the requeue list. This breaks multiq and we are right back to the head-of-line blocking. Also I think patch 1 will break things since queueing a packet with skb->next already set will cause issues since the queue uses prev and next last I knew.
Quoted 11 lines
Alas this testing is both the weekest (I'm not going to do this), and the strongest side of this solution, because it's mostly David's work (my patch could be actually skipped without much impact). So, I hope, you don't suggest this could be not enough tested or otherwise not the best?!
Anyway, I don't insist on "my" solution. I simply think it's reasonable, and it's not for private reasons, because I didn't even find this out. I think, if it's so wrong you should have no problem to show this in one little test. And maybe David changed his mind in the meantime and he will choose your way even without this.
I didn't mean to insist on this if it is how it came across. My main concern is that I just don't want to break what I just got working. Most of this requeue to q->requeue stuff will break multiq and introduce head-of-line blocking. When That happens it will fall back into my lap to try to resolve it so that is why I want to avoid it in the first place.
Anyway I'm out for the next two weeks with at least the first week of that being without email access. I hope I provided some valuable input so that this can head in the right direction.
Thanks,
Alex
On Fri, Sep 19, 2008 at 05:16:32PM +0200, Jarek Poplawski wrote:
...
Quoted 5 lines
Alexander, I guess you've seen my last messages/patches in this thread and noticed that this
__netif_schedule()problem is present both in this RFC patch andsch_multiq: if skb isn't dequeued because of innertx_queuestopped state check, there is missing__netif_schedule()before exit fromqdisc_run().
Hmm... probably false alarm. It seems there have to be same wake_queue after all.
Sorry,
Jarek P.