]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
net: sched: helpers to sum qlen and qlen for per cpu logic
authorJohn Fastabend <john.fastabend@gmail.com>
Thu, 7 Dec 2017 17:57:00 +0000 (09:57 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Dec 2017 18:32:26 +0000 (13:32 -0500)
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 <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sch_generic.h
net/sched/sch_api.c

index da2528036e2e52c6fd6075602c5051a094e1e46b..8f8c0afe529b8731df6428cac30d562e7bd6721f 100644 (file)
@@ -292,11 +292,31 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
        BUILD_BUG_ON(sizeof(qcb->data) < sz);
 }
 
+static inline int qdisc_qlen_cpu(const struct Qdisc *q)
+{
+       return this_cpu_ptr(q->cpu_qstats)->qlen;
+}
+
 static inline int qdisc_qlen(const struct Qdisc *q)
 {
        return q->q.qlen;
 }
 
+static inline int qdisc_qlen_sum(const struct Qdisc *q)
+{
+       __u32 qlen = 0;
+       int i;
+
+       if (q->flags & TCQ_F_NOLOCK) {
+               for_each_possible_cpu(i)
+                       qlen += per_cpu_ptr(q->cpu_qstats, i)->qlen;
+       } else {
+               qlen = q->q.qlen;
+       }
+
+       return qlen;
+}
+
 static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
 {
        return (struct qdisc_skb_cb *)skb->cb;
index a48ca41b7ecf5da105954f1b1b3bbeb1a53204e3..c669bb3b89b26980e311102078adbc332253380f 100644 (file)
@@ -797,7 +797,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid,
                goto nla_put_failure;
        if (q->ops->dump && q->ops->dump(q, skb) < 0)
                goto nla_put_failure;
-       qlen = q->q.qlen;
+
+       qlen = qdisc_qlen_sum(q);
 
        stab = rtnl_dereference(q->stab);
        if (stab && qdisc_dump_stab(skb, stab) < 0)