Skip to contentSkip to conversation

PATCH 1/2 [SCHED 2.6.24]: Check subqueue status before calling hard_start_xmit

PATCH Krishna Kumar 3 participants 5 messages Nov 14, 2007 – Nov 15, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Peter,

Peter wrote on 11/13/2007 11:14:50 PM:

Quoted 10 lines
(quoted diff) +1 -1
@@ -134,7 +134,7 @@ static inline int qdisc_restart(struct net_device *dev)
 {
    struct Qdisc *q = dev->qdisc;
    struct sk_buff *skb;
-   int ret;
+   int ret = NETDEV_TX_BUSY;
 
    /* Dequeue packet */
    if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL))

Review static inline int qdisc_restart(struct net_device *dev) · line 150

Quoted 7 lines
(quoted diff) +2 -1
@@ -145,7 +145,8 @@ static inline int qdisc_restart(struct net_device *dev)
    spin_unlock(&dev->queue_lock);
 
    HARD_TX_LOCK(dev, smp_processor_id());
-   ret = dev_hard_start_xmit(skb, dev);
+   if (!netif_subqueue_stopped(dev, skb))
+      ret = dev_hard_start_xmit(skb, dev);
    HARD_TX_UNLOCK(dev);

You could optimize this by getting HARD_TX_LOCK after the check. I assume that netif_stop_subqueue (from another CPU) would always be called by the driver xmit, and that is not possible since we hold the __LINK_STATE_QDISC_RUNNING bit. Does that sound correct?

PATCH
------

net/sched/sch_generic.c +3 -2
diff -ruNp 1/net/sched/sch_generic.c 2/net/sched/sch_generic.c
@@ -144,10 +144,11 @@ static inline int qdisc_restart(struct n
 	/* And release queue */
 	spin_unlock(&dev->queue_lock);
 
-	HARD_TX_LOCK(dev, smp_processor_id());
 	if (!netif_subqueue_stopped(dev, skb))
+		HARD_TX_LOCK(dev, smp_processor_id());
 		ret = dev_hard_start_xmit(skb, dev);
-	HARD_TX_UNLOCK(dev);
+		HARD_TX_UNLOCK(dev);
+	}
 
 	spin_lock(&dev->queue_lock);
 	q = dev->qdisc;

Thanks,

- KK

maintainer
#1 lore raw

From: Krishna Kumar <[email protected]>
Date: Wed, 14 Nov 2007 11:34:12 +0530

Quoted 15 lines

Hi Peter,

Peter wrote on 11/13/2007 11:14:50 PM:

Quoted 12 lines
net/sched/sch_generic.c +1 -1
@@ -134,7 +134,7 @@ static inline int qdisc_restart(struct net_device *dev)
 {
    struct Qdisc *q = dev->qdisc;
    struct sk_buff *skb;
-   int ret;
+   int ret = NETDEV_TX_BUSY;
 
    /* Dequeue packet */
    if (unlikely((skb = dev_dequeue_skb(dev, q)) == NULL))
@@ -145,7 +145,8 @@ static inline int qdisc_restart(struct net_device *dev)
    spin_unlock(&dev->queue_lock);
 
Quoted 10 lines

Review static inline int qdisc_restart(struct net_device *dev) · line 150

Quoted 5 lines
(quoted diff) +2 -1
    HARD_TX_LOCK(dev, smp_processor_id());
-   ret = dev_hard_start_xmit(skb, dev);
+   if (!netif_subqueue_stopped(dev, skb))
+      ret = dev_hard_start_xmit(skb, dev);
    HARD_TX_UNLOCK(dev);

You could optimize this by getting HARD_TX_LOCK after the check. I assume that netif_stop_subqueue (from another CPU) would always be called by the driver xmit, and that is not possible since we hold the __LINK_STATE_QDISC_RUNNING bit. Does that sound correct?

I don't think this is a critical optimization at this time, but something to certainly do along with the surgery we'll undoubtedly be doing here in the future :-)

#2 lore raw

Hi Dave,

David Miller <[email protected]> wrote on 11/14/2007 11:44:39 AM:

Quoted 8 lines
Quoted 4 lines

You could optimize this by getting HARD_TX_LOCK after the check. I assume that netif_stop_subqueue (from another CPU) would always be called by the driver xmit, and that is not possible since we hold the __LINK_STATE_QDISC_RUNNING bit. Does that sound correct?

I don't think this is a critical optimization at this time, but something to certainly do along with the surgery we'll undoubtedly be doing here in the future :-)

Agree. Will keep in mind for later :)

Thanks,

- KK

#3 lore raw
In reply to David Miller
Quoted 8 lines
Quoted 4 lines

You could optimize this by getting HARD_TX_LOCK after the check. I assume that netif_stop_subqueue (from another CPU) would always be called by the driver xmit, and that is not possible since we hold the __LINK_STATE_QDISC_RUNNING bit. Does that sound correct?

I don't think this is a critical optimization at this time, but something to certainly do along with the surgery we'll undoubtedly be doing here in the future :-)

Apologies for the spam...

I guess this check can be completely removed once other qdiscs are modified to
support subqueue. Essentially sch_prio and sch_rr executes subqueue_stopped twice for every skb while this check is required only for other qdiscs (and really
belongs in the individual qdisc dequeue handlers).

Thanks,

- KK

#4 lore raw
In reply to Krishna Kumar
Quoted 5 lines

You could optimize this by getting HARD_TX_LOCK after the check. I assume that netif_stop_subqueue (from another CPU) would always be called by the driver xmit, and that is not possible since we hold the __LINK_STATE_QDISC_RUNNING bit. Does that sound correct?

Sorry for not responding sooner; Dave hit it on the head though with his response. I agree with your changes, and I'll incorporate them in the lockless stack patches I've been working on (in the software queuing mode). Now if I could just find some time to finish them up and get them out for review...

Thanks,

-PJ Waskiewicz