net: sched: make bstats per cpu and estimator RCU safe
[cascardo/linux.git] / net / sched / sch_htb.c
index aea942c..0256dee 100644 (file)
@@ -103,7 +103,7 @@ struct htb_class {
        u32                     prio;           /* these two are used only by leaves... */
        int                     quantum;        /* but stored for parent-to-leaf return */
 
-       struct tcf_proto        *filter_list;   /* class attached filters */
+       struct tcf_proto __rcu  *filter_list;   /* class attached filters */
        int                     filter_cnt;
        int                     refcnt;         /* usage count of this class */
 
@@ -153,7 +153,7 @@ struct htb_sched {
        int                     rate2quantum;   /* quant = rate / rate2quantum */
 
        /* filters for qdisc itself */
-       struct tcf_proto        *filter_list;
+       struct tcf_proto __rcu  *filter_list;
 
 #define HTB_WARN_TOOMANYEVENTS 0x1
        unsigned int            warned; /* only one warning */
@@ -223,9 +223,9 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,
                if (cl->level == 0)
                        return cl;
                /* Start with inner filter chain if a non-leaf class is selected */
-               tcf = cl->filter_list;
+               tcf = rcu_dereference_bh(cl->filter_list);
        } else {
-               tcf = q->filter_list;
+               tcf = rcu_dereference_bh(q->filter_list);
        }
 
        *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
@@ -251,7 +251,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,
                        return cl;      /* we hit leaf; return it */
 
                /* we have got inner class; apply inner filter chain */
-               tcf = cl->filter_list;
+               tcf = rcu_dereference_bh(cl->filter_list);
        }
        /* classification failed; try to use default class */
        cl = htb_find(TC_H_MAKE(TC_H_MAJ(sch->handle), q->defcls), sch);
@@ -932,7 +932,7 @@ ok:
                        ktime_t time = ns_to_ktime(next_event);
                        qdisc_throttled(q->watchdog.qdisc);
                        hrtimer_start(&q->watchdog.timer, time,
-                                     HRTIMER_MODE_ABS);
+                                     HRTIMER_MODE_ABS_PINNED);
                }
        } else {
                schedule_work(&q->work);
@@ -1044,7 +1044,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
 
        qdisc_watchdog_init(&q->watchdog, sch);
        INIT_WORK(&q->work, htb_work_func);
-       skb_queue_head_init(&q->direct_queue);
+       __skb_queue_head_init(&q->direct_queue);
 
        if (tb[TCA_HTB_DIRECT_QLEN])
                q->direct_qlen = nla_get_u32(tb[TCA_HTB_DIRECT_QLEN]);
@@ -1144,7 +1144,7 @@ htb_dump_class_stats(struct Qdisc *sch, unsigned long arg, struct gnet_dump *d)
        cl->xstats.tokens = PSCHED_NS2TICKS(cl->tokens);
        cl->xstats.ctokens = PSCHED_NS2TICKS(cl->ctokens);
 
-       if (gnet_stats_copy_basic(d, &cl->bstats) < 0 ||
+       if (gnet_stats_copy_basic(d, NULL, &cl->bstats) < 0 ||
            gnet_stats_copy_rate_est(d, NULL, &cl->rate_est) < 0 ||
            gnet_stats_copy_queue(d, &cl->qstats) < 0)
                return -1;
@@ -1402,7 +1402,8 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
                        goto failure;
 
                if (htb_rate_est || tca[TCA_RATE]) {
-                       err = gen_new_estimator(&cl->bstats, &cl->rate_est,
+                       err = gen_new_estimator(&cl->bstats, NULL,
+                                               &cl->rate_est,
                                                qdisc_root_sleeping_lock(sch),
                                                tca[TCA_RATE] ? : &est.nla);
                        if (err) {
@@ -1464,8 +1465,11 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
                        parent->children++;
        } else {
                if (tca[TCA_RATE]) {
-                       err = gen_replace_estimator(&cl->bstats, &cl->rate_est,
-                                                   qdisc_root_sleeping_lock(sch),
+                       spinlock_t *lock = qdisc_root_sleeping_lock(sch);
+
+                       err = gen_replace_estimator(&cl->bstats, NULL,
+                                                   &cl->rate_est,
+                                                   lock,
                                                    tca[TCA_RATE]);
                        if (err)
                                return err;
@@ -1519,11 +1523,12 @@ failure:
        return err;
 }
 
-static struct tcf_proto **htb_find_tcf(struct Qdisc *sch, unsigned long arg)
+static struct tcf_proto __rcu **htb_find_tcf(struct Qdisc *sch,
+                                            unsigned long arg)
 {
        struct htb_sched *q = qdisc_priv(sch);
        struct htb_class *cl = (struct htb_class *)arg;
-       struct tcf_proto **fl = cl ? &cl->filter_list : &q->filter_list;
+       struct tcf_proto __rcu **fl = cl ? &cl->filter_list : &q->filter_list;
 
        return fl;
 }