* [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
@ 2017-06-13 20:36 Cong Wang
2017-06-13 20:40 ` Yuval Shaia
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Cong Wang @ 2017-06-13 20:36 UTC (permalink / raw)
To: netdev; +Cc: nicholashuber, labbott, Cong Wang, Jamal Hadi Salim
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 <labbott@redhat.com>
Reported-by: Nick Huber <nicholashuber@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
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 f42008b..b062bc8 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -132,21 +132,21 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
}
}
- spin_lock_bh(&police->tcf_lock);
if (est) {
err = gen_replace_estimator(&police->tcf_bstats, NULL,
&police->tcf_rate_est,
&police->tcf_lock,
NULL, est);
if (err)
- goto failure_unlock;
+ goto failure;
} else if (tb[TCA_POLICE_AVRATE] &&
(ret == ACT_P_CREATED ||
!gen_estimator_active(&police->tcf_rate_est))) {
err = -EINVAL;
- goto failure_unlock;
+ goto failure;
}
+ spin_lock_bh(&police->tcf_lock);
/* No failure allowed after this point */
police->tcfp_mtu = parm->mtu;
if (police->tcfp_mtu == 0) {
@@ -192,8 +192,6 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
return ret;
-failure_unlock:
- spin_unlock_bh(&police->tcf_lock);
failure:
qdisc_put_rtab(P_tab);
qdisc_put_rtab(R_tab);
--
2.5.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
2017-06-13 20:36 [Patch net] net_sched: move tcf_lock down after gen_replace_estimator() Cong Wang
@ 2017-06-13 20:40 ` Yuval Shaia
2017-06-13 20:45 ` Cong Wang
2017-06-14 18:42 ` David Miller
2017-06-14 12:48 ` Jamal Hadi Salim
2017-06-14 18:41 ` David Miller
2 siblings, 2 replies; 6+ messages in thread
From: Yuval Shaia @ 2017-06-13 20:40 UTC (permalink / raw)
To: Cong Wang; +Cc: netdev, nicholashuber, labbott, Jamal Hadi Salim
On Tue, Jun 13, 2017 at 01:36:24PM -0700, Cong Wang wrote:
> Laura reported a sleep-in-atomic kernel warning inside
Since you added a Reported-by tag below i don't see a reason to
specifically mention it in commit log message.
> 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 <labbott@redhat.com>
> Reported-by: Nick Huber <nicholashuber@gmail.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> 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 f42008b..b062bc8 100644
> --- a/net/sched/act_police.c
> +++ b/net/sched/act_police.c
> @@ -132,21 +132,21 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
> }
> }
>
> - spin_lock_bh(&police->tcf_lock);
> if (est) {
> err = gen_replace_estimator(&police->tcf_bstats, NULL,
> &police->tcf_rate_est,
> &police->tcf_lock,
> NULL, est);
> if (err)
> - goto failure_unlock;
> + goto failure;
> } else if (tb[TCA_POLICE_AVRATE] &&
> (ret == ACT_P_CREATED ||
> !gen_estimator_active(&police->tcf_rate_est))) {
> err = -EINVAL;
> - goto failure_unlock;
> + goto failure;
> }
>
> + spin_lock_bh(&police->tcf_lock);
> /* No failure allowed after this point */
> police->tcfp_mtu = parm->mtu;
> if (police->tcfp_mtu == 0) {
> @@ -192,8 +192,6 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
>
> return ret;
>
> -failure_unlock:
> - spin_unlock_bh(&police->tcf_lock);
> failure:
> qdisc_put_rtab(P_tab);
> qdisc_put_rtab(R_tab);
> --
> 2.5.5
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
2017-06-13 20:40 ` Yuval Shaia
@ 2017-06-13 20:45 ` Cong Wang
2017-06-14 18:42 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: Cong Wang @ 2017-06-13 20:45 UTC (permalink / raw)
To: Yuval Shaia
Cc: Linux Kernel Network Developers, nicholashuber, Laura Abbott,
Jamal Hadi Salim
On Tue, Jun 13, 2017 at 1:40 PM, Yuval Shaia <yuval.shaia@oracle.com> wrote:
> On Tue, Jun 13, 2017 at 01:36:24PM -0700, Cong Wang wrote:
>> Laura reported a sleep-in-atomic kernel warning inside
>
> Since you added a Reported-by tag below i don't see a reason to
> specifically mention it in commit log message.
If you have faith in this, feel free to update netdev-FAQ.txt to save
your time and others' time in the future.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
2017-06-13 20:36 [Patch net] net_sched: move tcf_lock down after gen_replace_estimator() Cong Wang
2017-06-13 20:40 ` Yuval Shaia
@ 2017-06-14 12:48 ` Jamal Hadi Salim
2017-06-14 18:41 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: Jamal Hadi Salim @ 2017-06-14 12:48 UTC (permalink / raw)
To: Cong Wang, netdev; +Cc: nicholashuber, labbott
On 17-06-13 04:36 PM, Cong Wang wrote:
> 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 <labbott@redhat.com>
> Reported-by: Nick Huber <nicholashuber@gmail.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> 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 f42008b..b062bc8 100644
> --- a/net/sched/act_police.c
> +++ b/net/sched/act_police.c
> @@ -132,21 +132,21 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
> }
> }
>
> - spin_lock_bh(&police->tcf_lock);
> if (est) {
> err = gen_replace_estimator(&police->tcf_bstats, NULL,
> &police->tcf_rate_est,
> &police->tcf_lock,
> NULL, est);
> if (err)
> - goto failure_unlock;
> + goto failure;
> } else if (tb[TCA_POLICE_AVRATE] &&
> (ret == ACT_P_CREATED ||
> !gen_estimator_active(&police->tcf_rate_est))) {
> err = -EINVAL;
> - goto failure_unlock;
> + goto failure;
> }
>
> + spin_lock_bh(&police->tcf_lock);
> /* No failure allowed after this point */
> police->tcfp_mtu = parm->mtu;
> if (police->tcfp_mtu == 0) {
> @@ -192,8 +192,6 @@ static int tcf_act_police_init(struct net *net, struct nlattr *nla,
>
> return ret;
>
> -failure_unlock:
> - spin_unlock_bh(&police->tcf_lock);
> failure:
> qdisc_put_rtab(P_tab);
> qdisc_put_rtab(R_tab);
>
Looks good to me.
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
cheers,
jamal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
2017-06-13 20:36 [Patch net] net_sched: move tcf_lock down after gen_replace_estimator() Cong Wang
2017-06-13 20:40 ` Yuval Shaia
2017-06-14 12:48 ` Jamal Hadi Salim
@ 2017-06-14 18:41 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-06-14 18:41 UTC (permalink / raw)
To: xiyou.wangcong; +Cc: netdev, nicholashuber, labbott, jhs
From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Tue, 13 Jun 2017 13:36:24 -0700
> 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 <labbott@redhat.com>
> Reported-by: Nick Huber <nicholashuber@gmail.com>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch net] net_sched: move tcf_lock down after gen_replace_estimator()
2017-06-13 20:40 ` Yuval Shaia
2017-06-13 20:45 ` Cong Wang
@ 2017-06-14 18:42 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2017-06-14 18:42 UTC (permalink / raw)
To: yuval.shaia; +Cc: xiyou.wangcong, netdev, nicholashuber, labbott, jhs
From: Yuval Shaia <yuval.shaia@oracle.com>
Date: Tue, 13 Jun 2017 23:40:41 +0300
> On Tue, Jun 13, 2017 at 01:36:24PM -0700, Cong Wang wrote:
>> Laura reported a sleep-in-atomic kernel warning inside
>
> Since you added a Reported-by tag below i don't see a reason to
> specifically mention it in commit log message.
That doesn't make any sense at all.
Part of telling the story is saying that someone reported a specific
kind of issue, and here is the problem, and here is how we solved it.
Just because there's a reported-by tag doesn't mean it's superfluous.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-06-14 18:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-13 20:36 [Patch net] net_sched: move tcf_lock down after gen_replace_estimator() Cong Wang
2017-06-13 20:40 ` Yuval Shaia
2017-06-13 20:45 ` Cong Wang
2017-06-14 18:42 ` David Miller
2017-06-14 12:48 ` Jamal Hadi Salim
2017-06-14 18:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).