Skip to content

Commit 7e66016

Browse files
jrfastabdavem330
authored andcommitted
net: sched: helpers to sum qlen and qlen for per cpu logic
Add qdisc qlen helper routines for lockless qdiscs to use. The qdisc qlen is no longer used in the hotpath but it is reported via stats query on the qdisc so it still needs to be tracked. This adds the per cpu operations needed along with a helper to return the summation of per cpu stats. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fd8e8d1 commit 7e66016

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

include/net/sch_generic.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,31 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
292292
BUILD_BUG_ON(sizeof(qcb->data) < sz);
293293
}
294294

295+
static inline int qdisc_qlen_cpu(const struct Qdisc *q)
296+
{
297+
return this_cpu_ptr(q->cpu_qstats)->qlen;
298+
}
299+
295300
static inline int qdisc_qlen(const struct Qdisc *q)
296301
{
297302
return q->q.qlen;
298303
}
299304

305+
static inline int qdisc_qlen_sum(const struct Qdisc *q)
306+
{
307+
__u32 qlen = 0;
308+
int i;
309+
310+
if (q->flags & TCQ_F_NOLOCK) {
311+
for_each_possible_cpu(i)
312+
qlen += per_cpu_ptr(q->cpu_qstats, i)->qlen;
313+
} else {
314+
qlen = q->q.qlen;
315+
}
316+
317+
return qlen;
318+
}
319+
300320
static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
301321
{
302322
return (struct qdisc_skb_cb *)skb->cb;

net/sched/sch_api.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
797797
goto nla_put_failure;
798798
if (q->ops->dump && q->ops->dump(q, skb) < 0)
799799
goto nla_put_failure;
800-
qlen = q->q.qlen;
800+
801+
qlen = qdisc_qlen_sum(q);
801802

802803
stab = rtnl_dereference(q->stab);
803804
if (stab && qdisc_dump_stab(skb, stab) < 0)

0 commit comments

Comments
 (0)