[PATCH AUTOSEL for 3.18 030/101] net_sched: move tcf_lock down after gen_replace_estimator()
From: WANG Cong[ Upstream commit 74030603dfd9f76c0f279f19f1dd1ee3028fee7a ] Laura reported a sleep-in-atomic kernel warning inside tcf_act_police_init() which calls gen_replace_estimator() with spinlock protection. It is not necessary in this case, we already have RTNL lock here so it is enough to protect concurrent writers. For the reader, i.e. tcf_act_police(), it needs to make decision based on this rate estimator, in the worst case we drop more/less packets than necessary while changing the rate in parallel, it is still acceptable. Reported-by: Laura Abbott Reported-by: Nick Huber Cc: Jamal Hadi Salim Signed-off-by: Cong Wang Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/act_police.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 69791ca77a05..1a25d25b9a56 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -176,21 +176,21 @@ override: } } - spin_lock_bh(>tcf_lock); if (est) { err = gen_replace_estimator(>tcf_bstats, NULL, >tcf_rate_est, >tcf_lock, est); if (err) - goto failure_unlock; + goto failure; } else if (tb[TCA_POLICE_AVRATE] && (ret == ACT_P_CREATED || !gen_estimator_active(>tcf_bstats, >tcf_rate_est))) { err = -EINVAL; - goto failure_unlock; + goto failure; } + spin_lock_bh(>tcf_lock); /* No failure allowed after this point */ police->tcfp_mtu = parm->mtu; if (police->tcfp_mtu == 0) { @@ -242,8 +242,6 @@ override: a->priv = police; return ret; -failure_unlock: - spin_unlock_bh(>tcf_lock); failure: qdisc_put_rtab(P_tab); qdisc_put_rtab(R_tab); -- 2.15.1
[PATCH AUTOSEL for 3.18 030/101] net_sched: move tcf_lock down after gen_replace_estimator()
From: WANG Cong [ Upstream commit 74030603dfd9f76c0f279f19f1dd1ee3028fee7a ] Laura reported a sleep-in-atomic kernel warning inside tcf_act_police_init() which calls gen_replace_estimator() with spinlock protection. It is not necessary in this case, we already have RTNL lock here so it is enough to protect concurrent writers. For the reader, i.e. tcf_act_police(), it needs to make decision based on this rate estimator, in the worst case we drop more/less packets than necessary while changing the rate in parallel, it is still acceptable. Reported-by: Laura Abbott Reported-by: Nick Huber Cc: Jamal Hadi Salim Signed-off-by: Cong Wang Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/act_police.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 69791ca77a05..1a25d25b9a56 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -176,21 +176,21 @@ override: } } - spin_lock_bh(>tcf_lock); if (est) { err = gen_replace_estimator(>tcf_bstats, NULL, >tcf_rate_est, >tcf_lock, est); if (err) - goto failure_unlock; + goto failure; } else if (tb[TCA_POLICE_AVRATE] && (ret == ACT_P_CREATED || !gen_estimator_active(>tcf_bstats, >tcf_rate_est))) { err = -EINVAL; - goto failure_unlock; + goto failure; } + spin_lock_bh(>tcf_lock); /* No failure allowed after this point */ police->tcfp_mtu = parm->mtu; if (police->tcfp_mtu == 0) { @@ -242,8 +242,6 @@ override: a->priv = police; return ret; -failure_unlock: - spin_unlock_bh(>tcf_lock); failure: qdisc_put_rtab(P_tab); qdisc_put_rtab(R_tab); -- 2.15.1