From: Jiri Pirko <jiri@resnulli.us>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@mellanox.com>,
John Fastabend <john.fastabend@gmail.com>
Subject: Re: [Patch net] net_sched: fix a missing rcu barrier in mini_qdisc_pair_swap()
Date: Thu, 21 Dec 2017 10:03:13 +0100 [thread overview]
Message-ID: <20171221090313.GB1930@nanopsycho> (raw)
In-Reply-To: <20171221072624.6204-1-xiyou.wangcong@gmail.com>
Thu, Dec 21, 2017 at 08:26:24AM CET, xiyou.wangcong@gmail.com wrote:
>The rcu_barrier_bh() in mini_qdisc_pair_swap() is to wait for
>flying RCU callback installed by a previous mini_qdisc_pair_swap(),
>however we miss it on the tp_head==NULL path, which leads to that
>the RCU callback still uses miniq_old->rcu after it is freed together
>with qdisc in qdisc_graft(). So just add it on that path too.
>
>Fixes: 46209401f8f6 ("net: core: introduce mini_Qdisc and eliminate usage of tp->q for clsact fastpath ")
This fixes:
752fbcc33405 ("net_sched: no need to free qdisc in RCU callback")
Before that, the issue was not there as the qdisc struct got removed
after a grace period.
>Reported-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>Tested-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>Cc: Jiri Pirko <jiri@mellanox.com>
>Cc: John Fastabend <john.fastabend@gmail.com>
>Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>---
> net/sched/sch_generic.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
>index cd1b200acae7..661c7144b53a 100644
>--- a/net/sched/sch_generic.c
>+++ b/net/sched/sch_generic.c
>@@ -1040,6 +1040,8 @@ void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
>
> if (!tp_head) {
> RCU_INIT_POINTER(*miniqp->p_miniq, NULL);
>+ /* Wait for flying RCU callback before it is freed. */
>+ rcu_barrier_bh();
> return;
> }
>
>@@ -1055,7 +1057,7 @@ void mini_qdisc_pair_swap(struct mini_Qdisc_pair *miniqp,
> rcu_assign_pointer(*miniqp->p_miniq, miniq);
>
> if (miniq_old)
>- /* This is counterpart of the rcu barrier above. We need to
>+ /* This is counterpart of the rcu barriers above. We need to
This is incorrect. Here we block in order to not use the same miniq
again in scenario
miniq1 (X)
miniq2
miniq1 (yet there are reader using X)
This call_rcu has 0 relation to the barrier you are adding.
But again, we don't we just free qdisc in call_rcu and avoid the
barrier?
next prev parent reply other threads:[~2017-12-21 9:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 7:26 [Patch net] net_sched: fix a missing rcu barrier in mini_qdisc_pair_swap() Cong Wang
2017-12-21 9:03 ` Jiri Pirko [this message]
2017-12-21 19:01 ` Cong Wang
2017-12-21 20:54 ` Cong Wang
2017-12-22 9:38 ` Jiri Pirko
2017-12-22 10:23 ` Jiri Pirko
2017-12-22 10:24 ` Jiri Pirko
2017-12-26 17:30 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171221090313.GB1930@nanopsycho \
--to=jiri@resnulli.us \
--cc=jiri@mellanox.com \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).