Commit d7fb60b9 authored by Cong Wang's avatar Cong Wang Committed by David S. Miller

net_sched: get rid of tcfa_rcu

gen estimator has been rewritten in commit 1c0d32fd
("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

Please see also the comments in code.

Cc: Jiri Pirko <[email protected]>
Cc: Jamal Hadi Salim <[email protected]>
Cc: Eric Dumazet <[email protected]>
Signed-off-by: default avatarCong Wang <[email protected]>
Signed-off-by: default avatarDavid S. Miller <[email protected]>
parent da8ab578
......@@ -34,7 +34,6 @@ struct tc_action {
struct gnet_stats_queue tcfa_qstats;
struct net_rate_estimator __rcu *tcfa_rate_est;
spinlock_t tcfa_lock;
struct rcu_head tcfa_rcu;
struct gnet_stats_basic_cpu __percpu *cpu_bstats;
struct gnet_stats_queue __percpu *cpu_qstats;
struct tc_cookie *act_cookie;
......@@ -50,7 +49,6 @@ struct tc_action {
#define tcf_qstats common.tcfa_qstats
#define tcf_rate_est common.tcfa_rate_est
#define tcf_lock common.tcfa_lock
#define tcf_rcu common.tcfa_rcu
/* Update lastuse only if needed, to avoid dirtying a cache line.
* We use a temp variable to avoid fetching jiffies twice.
......@@ -53,10 +53,13 @@ static void tcf_action_goto_chain_exec(const struct tc_action *a,
res->goto_tp = rcu_dereference_bh(chain->filter_chain);
static void free_tcf(struct rcu_head *head)
/* XXX: For standalone actions, we don't need a RCU grace period either, because
* actions are always connected to filters and filters are already destroyed in
* RCU callbacks, so after a RCU grace period actions are already disconnected
* from filters. Readers later can not find us.
static void free_tcf(struct tc_action *p)
struct tc_action *p = container_of(head, struct tc_action, tcfa_rcu);
......@@ -76,11 +79,7 @@ static void tcf_idr_remove(struct tcf_idrinfo *idrinfo, struct tc_action *p)
idr_remove_ext(&idrinfo->action_idr, p->tcfa_index);
* gen_estimator est_timer() might access p->tcfa_lock
* or bstats, wait a RCU grace period before freeing p
call_rcu(&p->tcfa_rcu, free_tcf);
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)
if (est)
call_rcu(&a->tcfa_rcu, free_tcf);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment