Skip to content

Commit

Permalink
net: sched: remove qdisc->empty for lockless qdisc
Browse files Browse the repository at this point in the history
As MISSED and DRAINING state are used to indicate a non-empty
qdisc, qdisc->empty is not longer needed, so remove it.

Acked-by: Jakub Kicinski <kuba@kernel.org>
Tested-by: Vladimir Oltean <vladimir.oltean@nxp.com> # flexcan
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yunsheng Lin authored and David S. Miller committed Jun 23, 2021
1 parent c4fef01 commit d3e0f57
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
13 changes: 3 additions & 10 deletions include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ struct Qdisc {
spinlock_t busylock ____cacheline_aligned_in_smp;
spinlock_t seqlock;

/* for NOLOCK qdisc, true if there are no enqueued skbs */
bool empty;
struct rcu_head rcu;

/* private data */
Expand Down Expand Up @@ -165,15 +163,15 @@ static inline bool qdisc_is_percpu_stats(const struct Qdisc *q)
static inline bool qdisc_is_empty(const struct Qdisc *qdisc)
{
if (qdisc_is_percpu_stats(qdisc))
return READ_ONCE(qdisc->empty);
return nolock_qdisc_is_empty(qdisc);
return !READ_ONCE(qdisc->q.qlen);
}

static inline bool qdisc_run_begin(struct Qdisc *qdisc)
{
if (qdisc->flags & TCQ_F_NOLOCK) {
if (spin_trylock(&qdisc->seqlock))
goto nolock_empty;
return true;

/* If the MISSED flag is set, it means other thread has
* set the MISSED flag before second spin_trylock(), so
Expand All @@ -195,12 +193,7 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
/* Retry again in case other CPU may not see the new flag
* after it releases the lock at the end of qdisc_run_end().
*/
if (!spin_trylock(&qdisc->seqlock))
return false;

nolock_empty:
WRITE_ONCE(qdisc->empty, false);
return true;
return spin_trylock(&qdisc->seqlock);
} else if (qdisc_is_running(qdisc)) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions net/sched/sch_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,6 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
need_retry = false;

goto retry;
} else {
WRITE_ONCE(qdisc->empty, true);
}

return skb;
Expand Down Expand Up @@ -927,7 +925,6 @@ struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
sch->enqueue = ops->enqueue;
sch->dequeue = ops->dequeue;
sch->dev_queue = dev_queue;
sch->empty = true;
dev_hold(dev);
refcount_set(&sch->refcnt, 1);

Expand Down

0 comments on commit d3e0f57

Please sign in to comment.