On Mon, Nov 13, 2017 at 3:08 PM, John Fastabend
<john.fastab...@gmail.com> wrote:
> sch_direct_xmit() uses qdisc_qlen as a return value but all call sites
> of the routine only check if it is zero or not. Simplify the logic so
> that we don't need to return an actual queue length value.
>
> This introduces a case now where sch_direct_xmit would have returned
> a qlen of zero but now it returns true.

You mean the first case, when the likely(skb) branch failed?
Can that return false, then?

> However in this case all
> call sites of sch_direct_xmit will implement a dequeue() and get
> a null skb and abort. This trades tracking qlen in the hotpath for
> an extra dequeue operation. Overall this seems to be good for
> performance.
>
> Signed-off-by: John Fastabend <john.fastab...@gmail.com>

> @@ -198,18 +198,19 @@ int sch_direct_xmit(struct sk_buff *skb, struct Qdisc 
> *q,
>
>         if (dev_xmit_complete(ret)) {
>                 /* Driver sent out skb successfully or skb was consumed */
> -               ret = qdisc_qlen(q);
> +               ret = true;
>         } else {
>                 /* Driver returned NETDEV_TX_BUSY - requeue skb */
>                 if (unlikely(ret != NETDEV_TX_BUSY))
>                         net_warn_ratelimited("BUG %s code %d qlen %d\n",
>                                              dev->name, ret, q->q.qlen);
>
> -               ret = dev_requeue_skb(skb, q);
> +               dev_requeue_skb(skb, q);
> +               ret = false;
>         }
>
>         if (ret && netif_xmit_frozen_or_stopped(txq))
> -               ret = 0;
> +               ret = false;
>
>         return ret;
>  }


This can now become

   if (!dev_queue_complete(ret)) {
      if (unlikely(ret != NETDEV_TX_BUSY))
        ...
      dev_requeue_skb(skb, q);
      return false;
  }

  if (netif_xmit_frozen_or_stopped(txq))
    return false;

  return true;

Reply via email to