From: John Fastabend <john.fastabend@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: xiyou.wangcong@gmail.com, davem@davemloft.net, jhs@mojatatu.com,
netdev@vger.kernel.org, paulmck@linux.vnet.ibm.com,
brouer@redhat.com
Subject: Re: [net-next PATCH v4 02/16] net: rcu-ify tcf_proto
Date: Fri, 12 Sep 2014 08:03:29 -0700 [thread overview]
Message-ID: <54130B41.4090409@gmail.com> (raw)
In-Reply-To: <1410397004.7106.41.camel@edumazet-glaptop2.roam.corp.google.com>
On 09/10/2014 05:56 PM, Eric Dumazet wrote:
> On Wed, 2014-09-10 at 08:47 -0700, John Fastabend wrote:
>> rcu'ify tcf_proto this allows calling tc_classify() without holding
>> any locks. Updaters are protected by RTNL.
>>
>> This patch prepares the core net_sched infrastracture for running
>> the classifier/action chains without holding the qdisc lock however
>> it does nothing to ensure cls_xxx and act_xxx types also work without
>> locking. Additional patches are required to address the fall out.
>>
>> Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
>> ---
> ...
>> diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
>> index ed30e43..4b52b70 100644
>> --- a/net/sched/sch_choke.c
>> +++ b/net/sched/sch_choke.c
>> @@ -57,7 +57,7 @@ struct choke_sched_data {
>>
>> /* Variables */
>> struct red_vars vars;
>> - struct tcf_proto *filter_list;
>> + struct tcf_proto __rcu *filter_list;
>> struct {
>> u32 prob_drop; /* Early probability drops */
>> u32 prob_mark; /* Early probability marks */
>> @@ -193,9 +193,11 @@ static bool choke_classify(struct sk_buff *skb,
>> {
>> struct choke_sched_data *q = qdisc_priv(sch);
>> struct tcf_result res;
>> + struct tcf_proto *fl;
>> int result;
>>
>> - result = tc_classify(skb, q->filter_list, &res);
>> + fl = rcu_dereference_bh(q->filter_list);
>
> Hmm... please change the caller to pass fl.
>
> Idea is to read q->filter_list once.
>
I'll just use rcu_access_pointer() in the caller and leave this
rcu_dereference_bh() here.
>> + result = tc_classify(skb, fl, &res);
>> if (result >= 0) {
>> #ifdef CONFIG_NET_CLS_ACT
>> switch (result) {
>> @@ -244,12 +246,14 @@ static bool choke_match_random(const struct choke_sched_data *q,
>> unsigned int *pidx)
>> {
>> struct sk_buff *oskb;
>> + struct tcf_proto *fl;
>>
>> if (q->head == q->tail)
>> return false;
>>
>> oskb = choke_peek_random(q, pidx);
>> - if (q->filter_list)
>> + fl = rcu_dereference_bh(q->filter_list);
>
> You could use rcu_access_pointer() and not have this fl variable.
>
done thanks.
>> + if (fl)
>> return choke_get_classid(nskb) == choke_get_classid(oskb);
>>
>> return choke_match_flow(oskb, nskb);
>> @@ -259,9 +263,11 @@ static int choke_enqueue(struct sk_buff *skb, struct Qdisc *sch)
>> {
>> struct choke_sched_data *q = qdisc_priv(sch);
>> const struct red_parms *p = &q->parms;
>> + struct tcf_proto *fl;
>> int ret = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
>>
>> - if (q->filter_list) {
>> + fl = rcu_dereference_bh(q->filter_list);
>> + if (fl) {
>> /* If using external classifiers, get result and record it. */
>> if (!choke_classify(skb, sch, &ret))
>
> Here I think you should pass fl as an additional parameter to
> choke_classify()
>
>
> OR, just use rcu_access_pointer() here as you do not deref
> q->filter_list here.
>
Went with rcu_access_pointer.
>
>> goto other_drop; /* Packet was eaten by filter */
>> @@ -554,7 +560,8 @@ static unsigned long choke_bind(struct Qdisc *sch, unsigned long parent,
>> return 0;
>> }
>>
>> -static struct tcf_proto **choke_find_tcf(struct Qdisc *sch, unsigned long cl)
>> +static struct tcf_proto __rcu **choke_find_tcf(struct Qdisc *sch,
>> + unsigned long cl)
>> {
>> struct choke_sched_data *q = qdisc_priv(sch);
>>
>
> remaining part seems fine.
>
>
--
John Fastabend Intel Corporation
next prev parent reply other threads:[~2014-09-12 15:03 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 15:46 [net-next PATCH v4 00/16] net/sched use rcu filters John Fastabend
2014-09-10 15:47 ` [net-next PATCH v4 01/16] net: qdisc: use rcu prefix and silence sparse warnings John Fastabend
2014-09-11 0:23 ` Eric Dumazet
2014-09-10 15:47 ` [net-next PATCH v4 02/16] net: rcu-ify tcf_proto John Fastabend
2014-09-11 0:56 ` Eric Dumazet
2014-09-12 15:03 ` John Fastabend [this message]
2014-09-10 15:47 ` [net-next PATCH v4 03/16] net: sched: cls_basic use RCU John Fastabend
2014-09-10 15:48 ` [net-next PATCH v4 04/16] net: sched: cls_cgroup " John Fastabend
2014-09-10 15:48 ` [net-next PATCH v4 05/16] net: sched: cls_flow " John Fastabend
2014-09-11 0:58 ` Eric Dumazet
2014-09-10 15:49 ` [net-next PATCH v4 06/16] net: sched: fw " John Fastabend
2014-09-11 1:03 ` Eric Dumazet
2014-09-10 15:49 ` [net-next PATCH v4 07/16] net: sched: RCU cls_route John Fastabend
2014-09-11 1:12 ` Eric Dumazet
2014-09-10 15:50 ` [net-next PATCH v4 08/16] net: sched: RCU cls_tcindex John Fastabend
2014-09-11 1:17 ` Eric Dumazet
2014-09-10 15:50 ` [net-next PATCH v4 09/16] net: sched: make cls_u32 per cpu John Fastabend
2014-09-11 1:19 ` Eric Dumazet
2014-09-10 15:50 ` [net-next PATCH v4 10/16] net: sched: make cls_u32 lockless John Fastabend
2014-09-11 1:26 ` Eric Dumazet
2014-09-10 15:51 ` [net-next PATCH v4 11/16] net: sched: rcu'ify cls_rsvp John Fastabend
2014-09-11 1:30 ` Eric Dumazet
2014-09-12 15:13 ` John Fastabend
2014-09-10 15:51 ` [net-next PATCH v4 12/16] net: sched: rcu'ify cls_bpf John Fastabend
2014-09-11 2:28 ` Eric Dumazet
2014-09-12 15:16 ` John Fastabend
2014-09-10 15:52 ` [net-next PATCH v4 13/16] net: sched: make tc_action safe to walk under RCU John Fastabend
2014-09-10 15:52 ` [net-next PATCH v4 14/16] net: sched: make bstats per cpu and estimator RCU safe John Fastabend
2014-09-10 15:52 ` [net-next PATCH v4 15/16] net: sched: make qstats per cpu John Fastabend
2014-09-10 15:53 ` [net-next PATCH v4 16/16] net: sched: drop ingress qdisc lock John Fastabend
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=54130B41.4090409@gmail.com \
--to=john.fastabend@gmail.com \
--cc=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--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).