All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: xiyou.wangcong@gmail.com, jhs@mojatatu.com,
	eric.dumazet@gmail.com, netdev@vger.kernel.org,
	paulmck@linux.vnet.ibm.com, brouer@redhat.com
Subject: Re: [net-next PATCH v2 02/15] net: rcu-ify tcf_proto
Date: Mon, 01 Sep 2014 18:39:13 -0700	[thread overview]
Message-ID: <54051FC1.6030106@gmail.com> (raw)
In-Reply-To: <20140824.223133.170922940598584254.davem@davemloft.net>

On 08/24/2014 10:31 PM, David Miller wrote:
> From: John Fastabend <john.fastabend@gmail.com>
> Date: Sun, 24 Aug 2014 17:48:31 -0700
>
>> @@ -722,8 +724,9 @@ static void sfq_free(void *addr)
>>   static void sfq_destroy(struct Qdisc *sch)
>>   {
>>   	struct sfq_sched_data *q = qdisc_priv(sch);
>> +	struct tcf_proto *fl = rtnl_dereference(q->filter_list);
>>
>> -	tcf_destroy_chain(&q->filter_list);
>> +	tcf_destroy_chain(&fl);

Sorry for the delayed reply...

>
> This will cause tcf_destroy_chain() to set the local variable
> 'fl' to NULL rather than q->filter_list.
>
> I don't see how this can be correct at all.

Right now (without these patches) nothing sets q->filter_list
to NULL and we only call this when the qdisc is being destroyed.
In all cases there is a rcu_assign_pointer() to detach the qdisc
from the netdev_queue followed by a synchronize_net().

	dev_deactivate_many
	   [...]
	   dev_deactivate_queue
		rcu_assign_pointer(dev_queue->qdisc, qdisc_default)

  	   [...]
	   synchronize_net()

After the synchronize_net there should be no other references
to q->filter_list other then in the destroy path so I think it
works and the rtnl_dereference in my patch is there for annotation
to make sparse happy but doesn't change the logic.

Does that make sense?

>
> You need to make tcf_destroy_chain() take a pointer to an __rcu
> pointer, and do the proper dereferencing and RCU assignments in
> that chain destroy loop.
>
> This might be why you're getting annotation warnings.
>

The annotation warnings comes from the find_tcf blocks for example
here is the block in the sfq scheduler,

     struct sfq_sched_data *q = qdisc_priv(sch);

     if (cl)
         return NULL;
     return &q->filter_list;

This is called inside the rtnl lock but filter list is rcu protected
fixing the function types like this seems to resolve it,

     static struct tcf_proto * __rcu *sfq_find_tcf(struct Qdisc *sch, 
unsigned long cl)

and similarly the ops struct,

     struct tcf_proto * __rcu * (*tcf_chain)(struct Qdisc *, unsigned long);

This fixes the sparse warnings and looks correct to me. I'll send
an update with these fixes.

Thanks!
John



-- 
John Fastabend         Intel Corporation

  reply	other threads:[~2014-09-02  1:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-25  0:47 [net-next PATCH v2 00/15] net/sched: use rcu filters John Fastabend
2014-08-25  0:48 ` [net-next PATCH v2 01/15] net: qdisc: use rcu prefix and silence sparse warnings John Fastabend
2014-08-25  0:48 ` [net-next PATCH v2 02/15] net: rcu-ify tcf_proto John Fastabend
2014-08-25  5:31   ` David Miller
2014-09-02  1:39     ` John Fastabend [this message]
2014-09-02 20:52       ` David Miller
2014-09-03  6:23         ` John Fastabend
2014-08-25  0:49 ` [net-next PATCH v2 03/15] net: sched: cls_basic use RCU John Fastabend
2014-08-25  0:49 ` [net-next PATCH v2 04/15] net: sched: cls_cgroup " John Fastabend
2014-08-25  0:49 ` [net-next PATCH v2 05/15] net: sched: cls_flow " John Fastabend
2014-08-25  0:50 ` [net-next PATCH v2 06/15] net: sched: fw " John Fastabend
2014-08-25  0:50 ` [net-next PATCH v2 07/15] net: sched: RCU cls_route John Fastabend
2014-08-25  0:51 ` [net-next PATCH v2 08/15] net: sched: RCU cls_tcindex John Fastabend
2014-08-25  0:51 ` [net-next PATCH v2 09/15] net: sched: make cls_u32 lockless John Fastabend
2014-08-25  0:52 ` [net-next PATCH v2 10/15] net: sched: rcu'ify cls_rsvp John Fastabend
2014-08-25  0:52 ` [net-next PATCH v2 11/15] net: sched: rcu'ify cls_bpf John Fastabend
2014-08-25  0:53 ` [net-next PATCH v2 12/15] net: sched: make tc_action safe to walk under RCU John Fastabend
2014-08-25  0:53 ` [net-next PATCH v2 13/15] net: sched: make bstats per cpu and estimator RCU safe John Fastabend
2014-08-25  0:53 ` [net-next PATCH v2 14/15] net: sched: make qstats per cpu John Fastabend
2014-08-25  0:54 ` [net-next PATCH v2 15/15] 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=54051FC1.6030106@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 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.