netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock
@ 2022-08-26  1:39 Zhengchao Shao
  2022-08-30 10:00 ` patchwork-bot+netdevbpf
  2022-09-05 18:13 ` Cong Wang
  0 siblings, 2 replies; 4+ messages in thread
From: Zhengchao Shao @ 2022-08-26  1:39 UTC (permalink / raw)
  To: netdev, linux-kernel, davem, edumazet, kuba, pabeni, jhs,
	xiyou.wangcong, jiri
  Cc: vladbu, weiyongjun1, yuehaibing, shaozhengchao

The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
holding sch tree spinlock, which results sleeping-while-atomic BUG.

Fixes: c266f64dbfa2 ("net: sched: protect block state with mutex")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
v1: The subject needs to be changed to [PATCH net].
---
 net/sched/sch_tbf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c
index 72102277449e..36079fdde2cb 100644
--- a/net/sched/sch_tbf.c
+++ b/net/sched/sch_tbf.c
@@ -356,6 +356,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	struct nlattr *tb[TCA_TBF_MAX + 1];
 	struct tc_tbf_qopt *qopt;
 	struct Qdisc *child = NULL;
+	struct Qdisc *old = NULL;
 	struct psched_ratecfg rate;
 	struct psched_ratecfg peak;
 	u64 max_size;
@@ -447,7 +448,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	sch_tree_lock(sch);
 	if (child) {
 		qdisc_tree_flush_backlog(q->qdisc);
-		qdisc_put(q->qdisc);
+		old = q->qdisc;
 		q->qdisc = child;
 	}
 	q->limit = qopt->limit;
@@ -467,6 +468,7 @@ static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
 	memcpy(&q->peak, &peak, sizeof(struct psched_ratecfg));
 
 	sch_tree_unlock(sch);
+	qdisc_put(old);
 	err = 0;
 
 	tbf_offload_change(sch);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock
  2022-08-26  1:39 [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock Zhengchao Shao
@ 2022-08-30 10:00 ` patchwork-bot+netdevbpf
  2022-09-05 18:13 ` Cong Wang
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-30 10:00 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, linux-kernel, davem, edumazet, kuba, pabeni, jhs,
	xiyou.wangcong, jiri, vladbu, weiyongjun1, yuehaibing

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Fri, 26 Aug 2022 09:39:30 +0800 you wrote:
> The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
> call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
> holding sch tree spinlock, which results sleeping-while-atomic BUG.
> 
> Fixes: c266f64dbfa2 ("net: sched: protect block state with mutex")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> 
> [...]

Here is the summary with links:
  - [net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock
    https://git.kernel.org/netdev/net/c/b05972f01e7d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock
  2022-08-26  1:39 [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock Zhengchao Shao
  2022-08-30 10:00 ` patchwork-bot+netdevbpf
@ 2022-09-05 18:13 ` Cong Wang
  2022-09-07  1:24   ` shaozhengchao
  1 sibling, 1 reply; 4+ messages in thread
From: Cong Wang @ 2022-09-05 18:13 UTC (permalink / raw)
  To: Zhengchao Shao
  Cc: netdev, linux-kernel, davem, edumazet, kuba, pabeni, jhs, jiri,
	vladbu, weiyongjun1, yuehaibing

On Fri, Aug 26, 2022 at 09:39:30AM +0800, Zhengchao Shao wrote:
> The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
> call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
> holding sch tree spinlock, which results sleeping-while-atomic BUG.
> 

Hm, did you see an actual warning here??

The commit you mentioned above is a classful Qdisc which accepts
user-specified child Qdisc, but TBF technically does not, I don't think
you can change its default fifo.

Thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock
  2022-09-05 18:13 ` Cong Wang
@ 2022-09-07  1:24   ` shaozhengchao
  0 siblings, 0 replies; 4+ messages in thread
From: shaozhengchao @ 2022-09-07  1:24 UTC (permalink / raw)
  To: Cong Wang
  Cc: netdev, linux-kernel, davem, edumazet, kuba, pabeni, jhs, jiri,
	vladbu, weiyongjun1, yuehaibing



On 2022/9/6 2:13, Cong Wang wrote:
> On Fri, Aug 26, 2022 at 09:39:30AM +0800, Zhengchao Shao wrote:
>> The issue is the same to commit c2999f7fb05b ("net: sched: multiq: don't
>> call qdisc_put() while holding tree lock"). Qdiscs call qdisc_put() while
>> holding sch tree spinlock, which results sleeping-while-atomic BUG.
>>
> 
> Hm, did you see an actual warning here??
> 
> The commit you mentioned above is a classful Qdisc which accepts
> user-specified child Qdisc, but TBF technically does not, I don't think
> you can change its default fifo.
> 
> Thanks.

Hi Wang:
	Thank you for your reply. My apologise. I don't see the
warning here. Yes, TBF is classless qdisc, its default fifo is
bfifo and reset or destroy process will not sleep. So, it's not
a issue. Should I revert it, or keep it in this format(qdisc_put
out of holding sch tree spinlock).


Zhengchao Shao

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-07  1:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-26  1:39 [PATCH net,v2] net: sched: tbf: don't call qdisc_put() while holding tree lock Zhengchao Shao
2022-08-30 10:00 ` patchwork-bot+netdevbpf
2022-09-05 18:13 ` Cong Wang
2022-09-07  1:24   ` shaozhengchao

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).