From: John Fastabend <john.fastabend@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com
Subject: Re: [RFC Patch net-next 5/6] net_sched: use rcu in fast path
Date: Wed, 7 Sep 2016 23:04:55 -0700 [thread overview]
Message-ID: <57D0FF87.604@gmail.com> (raw)
In-Reply-To: <1473173528.10725.14.camel@edumazet-glaptop3.roam.corp.google.com>
On 16-09-06 07:52 AM, Eric Dumazet wrote:
> On Thu, 2016-09-01 at 22:57 -0700, Cong Wang wrote:
>
>
>
> Missing changelog ?
>
Yeah this stuff is a bit tricky more notes to walk us through
this would be helpful. (btw you can disregard my comment from
earlier this morning I've tracked most of this down now)
> Here I have no idea what you want to fix, since John already took care
> all this infra.
>
> Adding extra rcu_dereference() and rcu_read_lock() while the critical
> RCU dereferences already happen in callers is not needed.
>
Agreed drop all the extra rcu_read_lock/unlock here.
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>> ---
>> net/sched/act_api.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/sched/act_api.c b/net/sched/act_api.c
>> index 2f8db3c..fb6ff52 100644
>> --- a/net/sched/act_api.c
>> +++ b/net/sched/act_api.c
>> @@ -470,10 +470,14 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
>> goto exec_done;
>> }
>> for (i = 0; i < nr_actions; i++) {
>> - const struct tc_action *a = actions[i];
>> + const struct tc_action *a;
>>
>> + rcu_read_lock();
>
> But the caller already has rcu_read_lock() or rcu_read_lock_bh()
>
> This was done in commit 25d8c0d55f241ce2 ("net: rcu-ify tcf_proto")
>
>> + a = rcu_dereference(actions[i]);
>
>
> Add in your .config :
> CONFIG_SPARSE_RCU_POINTER=y
> make C=2 M=net/sched
>
>> repeat:
>> ret = a->ops->act(skb, a, res);
>> + rcu_read_unlock();
>> +
>> if (ret == TC_ACT_REPEAT)
>> goto repeat; /* we need a ttl - JHS */
>> if (ret != TC_ACT_PIPE)
>
>
>
> I do not believe this patch is necessary.
>
> Please add John as reviewer next time.
>
> Thanks.
>
>
So the actual issue as I see it is with the late binding actions the
ones created with the ill documented 'tc action' syntax.
If you add a rule here and then bind it to a filter (stealing Jamals
example),
tc actions add action skbedit mark 10 index 1
tc filter add dev $DEV parent ffff: protocol ip prio 1 u32\
match ip dst 17.0.0.1/32 flowid 1:10 action skbedit index 1
then you can modify this action later with the following
tc actions replace action ....
So for an action such as act_mirred we may end up running with a
partially updated state from this,
tcf_mirred_init(...)
[...]
m->tcf_action = parm->action;
m->tcfm_eaction = parm->eaction;
[...]
and then in the execution of the action,
tcf_mirred(...)
[...]
retval = READ_ONCE(m->tcf_action);
[...]
if (m->tcfm_eaction != TCA_EGRESS_MIRROR)
[...]
So its at least possible I think these could be interleaved on multiple
cpus.
Notice that some of the actions are fine though and don't have this
issue act_bpf for example is fine.
I think we can either fix it in the hash table create part of the
list as this series does or just let each action handle it on its own.
.John
next prev parent reply other threads:[~2016-09-08 6:16 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-02 5:57 [RFC Patch net-next 0/6] net_sched: really switch to RCU for tc actions Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 1/6] net_sched: use RCU for action hash table Cong Wang
2016-09-06 12:47 ` Jamal Hadi Salim
2016-09-06 22:37 ` Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 2/6] net_sched: introduce tcf_hash_replace() Cong Wang
2016-09-06 12:52 ` Jamal Hadi Salim
2016-09-06 22:34 ` Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 3/6] net_sched: return NULL in tcf_hash_check() Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 4/6] net_sched: introduce tcf_hash_copy() Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 5/6] net_sched: use rcu in fast path Cong Wang
2016-09-06 14:52 ` Eric Dumazet
2016-09-08 6:04 ` John Fastabend [this message]
2016-09-08 13:28 ` Eric Dumazet
2016-09-08 15:35 ` [PATCH net] net_sched: act_mirred: full rcu conversion Eric Dumazet
2016-09-08 15:47 ` John Fastabend
2016-09-08 15:51 ` Eric Dumazet
2016-09-09 5:26 ` Cong Wang
2016-09-09 12:23 ` Eric Dumazet
2016-09-09 15:52 ` John Fastabend
2016-09-12 6:12 ` Cong Wang
2016-09-12 15:34 ` John Fastabend
2016-09-09 5:24 ` Cong Wang
2016-09-09 5:48 ` Alexei Starovoitov
2016-09-09 5:59 ` Cong Wang
2016-09-09 12:25 ` Eric Dumazet
2016-09-09 12:23 ` Eric Dumazet
2016-09-12 5:46 ` Cong Wang
2016-09-08 15:49 ` [RFC Patch net-next 5/6] net_sched: use rcu in fast path John Fastabend
2016-09-09 5:54 ` Cong Wang
2016-09-09 15:25 ` John Fastabend
2016-09-09 5:49 ` Cong Wang
2016-09-02 5:57 ` [RFC Patch net-next 6/6] net_sched: switch to RCU API for act_mirred Cong Wang
2016-09-02 7:09 ` [RFC Patch net-next 0/6] net_sched: really switch to RCU for tc actions Jiri Pirko
2016-09-02 19:44 ` Cong Wang
2016-09-07 16:23 ` John Fastabend
2016-09-08 6:05 ` John Fastabend
2016-09-09 5:22 ` Cong Wang
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=57D0FF87.604@gmail.com \
--to=john.fastabend@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.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).