History

net_sched: get rid of tcfa_rcu

gen estimator has been rewritten in commit 1c0d32fde5bd ("net_sched: gen_estimator: complete rewrite of rate estimators"), the caller is no longer needed to wait for a grace period. So this patch gets rid of it. This also completely closes a race condition between action free path and filter chain add/remove path for the following patch. Because otherwise the nested RCU callback can't be caught by rcu_barrier(). Please see also the comments in code.

Cong Wang committed 9 years ago

Commit d7fb60b1 parent da8ab572 files · +8 −11Browse files

Unified · Split

2 files
  1. include/net/act_api.h +0 −2
  2. net/sched/act_api.c +8 −9
include/net/act_api.h+0−2
@@ -34,7 +34,6 @@ struct tc_action { · 33 unmodified lines
3434 struct gnet_stats_queue tcfa_qstats;
3535 struct net_rate_estimator __rcu *tcfa_rate_est;
3636 spinlock_t tcfa_lock;
37− struct rcu_head tcfa_rcu;
3837 struct gnet_stats_basic_cpu __percpu *cpu_bstats;
3938 struct gnet_stats_queue __percpu *cpu_qstats;
4039 struct tc_cookie *act_cookie;
@@ -50,7 +49,6 @@ struct tc_action { · 9 unmodified lines
5049 #define tcf_qstats common.tcfa_qstats
5150 #define tcf_rate_est common.tcfa_rate_est
5251 #define tcf_lock common.tcfa_lock
53−#define tcf_rcu common.tcfa_rcu
5452
5553 /* Update lastuse only if needed, to avoid dirtying a cache line.
5654 * We use a temp variable to avoid fetching jiffies twice.
net/sched/act_api.c+8−9
@@ -53,10 +53,13 @@ static void tcf_action_goto_chain_exec(const struct tc_action *a, · 52 unmodified lines
5353 res->goto_tp = rcu_dereference_bh(chain->filter_chain);
5454 }
5555
56−static void free_tcf(struct rcu_head *head)
56+/* XXX: For standalone actions, we don't need a RCU grace period either, because
57+ * actions are always connected to filters and filters are already destroyed in
58+ * RCU callbacks, so after a RCU grace period actions are already disconnected
59+ * from filters. Readers later can not find us.
60+ */
61+static void free_tcf(struct tc_action *p)
5762 {
58− struct tc_action *p = container_of(head, struct tc_action, tcfa_rcu);
59−
6063 free_percpu(p->cpu_bstats);
6164 free_percpu(p->cpu_qstats);
6265
@@ -76,11 +79,7 @@ static void tcf_idr_remove(struct tcf_idrinfo *idrinfo, struct tc_action *p) · 13 unmodified lines
7679 idr_remove_ext(&idrinfo->action_idr, p->tcfa_index);
7780 spin_unlock_bh(&idrinfo->lock);
7881 gen_kill_estimator(&p->tcfa_rate_est);
79− /*
80− * gen_estimator est_timer() might access p->tcfa_lock
81− * or bstats, wait a RCU grace period before freeing p
82− */
83− call_rcu(&p->tcfa_rcu, free_tcf);
82+ free_tcf(p);
8483 }
8584
8685 int __tcf_idr_release(struct tc_action *p, bool bind, bool strict)
@@ -259,7 +258,7 @@ void tcf_idr_cleanup(struct tc_action *a, struct nlattr *est) · 172 unmodified lines
259258 {
260259 if (est)
261260 gen_kill_estimator(&a->tcfa_rate_est);
262− call_rcu(&a->tcfa_rcu, free_tcf);
261+ free_tcf(a);
263262 }
264263 EXPORT_SYMBOL(tcf_idr_cleanup);
265264

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t