* [PATCH] net_sched: fix order of queue length updates in qdisc_replace()
@ 2017-08-19 12:37 Konstantin Khlebnikov
2017-08-19 12:42 ` Konstantin Khlebnikov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Konstantin Khlebnikov @ 2017-08-19 12:37 UTC (permalink / raw)
To: netdev, David S. Miller; +Cc: Cong Wang, Jiri Pirko, stable
This important to call qdisc_tree_reduce_backlog() after changing queue
length. Parent qdisc should deactivate class in ->qlen_notify() called from
qdisc_tree_reduce_backlog() but this happens only if qdisc->q.qlen in zero.
Missed class deactivations leads to crashes/warnings at picking packets
from empty qdisc and corrupting state at reactivating this class in future.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Fixes: 86a7996cc8a0 ("net_sched: introduce qdisc_replace() helper")
Cc: Stable <stable@vger.kernel.org>
---
include/net/sch_generic.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 1c123e2b2415..67f815e5d525 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -806,8 +806,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
old = *pold;
*pold = new;
if (old != NULL) {
- qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
+ unsigned int qlen = old->q.qlen;
+ unsigned int backlog = old->qstats.backlog;
+
qdisc_reset(old);
+ qdisc_tree_reduce_backlog(old, qlen, backlog);
}
sch_tree_unlock(sch);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net_sched: fix order of queue length updates in qdisc_replace()
2017-08-19 12:37 [PATCH] net_sched: fix order of queue length updates in qdisc_replace() Konstantin Khlebnikov
@ 2017-08-19 12:42 ` Konstantin Khlebnikov
2017-08-19 17:58 ` Cong Wang
2017-08-21 3:01 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khlebnikov @ 2017-08-19 12:42 UTC (permalink / raw)
To: netdev, David S. Miller; +Cc: Cong Wang, Jiri Pirko, stable
I've seen this as loops in hfsc rb-trees and hungs in hfsc_dequeue() -> rb_first().
Simple debug catched insering already inserted rb-tree nodes and similar mess.
Most likely this could explain warning in hfsc_dequeue()
https://bugzilla.kernel.org/show_bug.cgi?id=109581
On 19.08.2017 15:37, Konstantin Khlebnikov wrote:
> This important to call qdisc_tree_reduce_backlog() after changing queue
> length. Parent qdisc should deactivate class in ->qlen_notify() called from
> qdisc_tree_reduce_backlog() but this happens only if qdisc->q.qlen in zero.
>
> Missed class deactivations leads to crashes/warnings at picking packets
> from empty qdisc and corrupting state at reactivating this class in future.
>
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Fixes: 86a7996cc8a0 ("net_sched: introduce qdisc_replace() helper")hfsc_dequeue
> Cc: Stable <stable@vger.kernel.org>
> ---
> include/net/sch_generic.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
> index 1c123e2b2415..67f815e5d525 100644
> --- a/include/net/sch_generic.h
> +++ b/include/net/sch_generic.h
> @@ -806,8 +806,11 @@ static inline struct Qdisc *qdisc_replace(struct Qdisc *sch, struct Qdisc *new,
> old = *pold;
> *pold = new;
> if (old != NULL) {
> - qdisc_tree_reduce_backlog(old, old->q.qlen, old->qstats.backlog);
> + unsigned int qlen = old->q.qlen;
> + unsigned int backlog = old->qstats.backlog;
> +
> qdisc_reset(old);
> + qdisc_tree_reduce_backlog(old, qlen, backlog);
> }
> sch_tree_unlock(sch);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net_sched: fix order of queue length updates in qdisc_replace()
2017-08-19 12:37 [PATCH] net_sched: fix order of queue length updates in qdisc_replace() Konstantin Khlebnikov
2017-08-19 12:42 ` Konstantin Khlebnikov
@ 2017-08-19 17:58 ` Cong Wang
2017-08-21 3:01 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2017-08-19 17:58 UTC (permalink / raw)
To: Konstantin Khlebnikov
Cc: Linux Kernel Network Developers, David S. Miller, Jiri Pirko, stable
On Sat, Aug 19, 2017 at 5:37 AM, Konstantin Khlebnikov
<khlebnikov@yandex-team.ru> wrote:
> This important to call qdisc_tree_reduce_backlog() after changing queue
> length. Parent qdisc should deactivate class in ->qlen_notify() called from
> qdisc_tree_reduce_backlog() but this happens only if qdisc->q.qlen in zero.
Good catch! I didn't realize qdisc_reset() actually resets all classes...
Acked-by: Cong Wang <xiyou.wangcong@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net_sched: fix order of queue length updates in qdisc_replace()
2017-08-19 12:37 [PATCH] net_sched: fix order of queue length updates in qdisc_replace() Konstantin Khlebnikov
2017-08-19 12:42 ` Konstantin Khlebnikov
2017-08-19 17:58 ` Cong Wang
@ 2017-08-21 3:01 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-08-21 3:01 UTC (permalink / raw)
To: khlebnikov; +Cc: netdev, xiyou.wangcong, jiri
From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date: Sat, 19 Aug 2017 15:37:07 +0300
> This important to call qdisc_tree_reduce_backlog() after changing queue
> length. Parent qdisc should deactivate class in ->qlen_notify() called from
> qdisc_tree_reduce_backlog() but this happens only if qdisc->q.qlen in zero.
>
> Missed class deactivations leads to crashes/warnings at picking packets
> from empty qdisc and corrupting state at reactivating this class in future.
>
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> Fixes: 86a7996cc8a0 ("net_sched: introduce qdisc_replace() helper")
Applied and queued up for -stable, thanks.
Please do not add an explict "CC: stable" to networking patches, simply
ask me to queue it up as I handle all networking -stable submissions
myself by hand.
Thank you.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-21 3:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-19 12:37 [PATCH] net_sched: fix order of queue length updates in qdisc_replace() Konstantin Khlebnikov
2017-08-19 12:42 ` Konstantin Khlebnikov
2017-08-19 17:58 ` Cong Wang
2017-08-21 3:01 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.