Subject: Re: [net-next PATCH v3 07/15] net: sched: RCU cls_route

From: John Fastabend <[email-masked]>
Date: Tue, 09 Sep 2014 09:24:02 -0700

On 09/09/2014 05:59 AM, Eric Dumazet wrote:
> On Mon, 2014-09-08 at 22:57 -0700, John Fastabend wrote:
>> RCUify the route classifier. For now however spinlock's are used to
>> protect fastmap cache.
>>
>> The issue here is the fastmap may be read by one CPU while the
>> cache is being updated by another. An array of pointers could be
>> one possible solution.
>
> Yep, this doesnt seem like an urgent issue anyway.
>
>>
>> Signed-off-by: John Fastabend <[email-masked]>
>> ---

[...]

>> @@ -296,27 +324,35 @@ static int route4_delete(struct tcf_proto *tp, unsigned long arg)
>>   	h = f->handle;
>>   	b = f->bkt;
>>
>> -	for (fp = &b->ht[from_hash(h >> 16)]; *fp; fp = &(*fp)->next) {
>> -		if (*fp == f) {
>> -			tcf_tree_lock(tp);
>> +	fp = &b->ht[from_hash(h >> 16)];
>> +	for (nf = rtnl_dereference(*fp); nf;
>> +	     fp = &nf->next, nf = rtnl_dereference(*fp)) {
>> +		if (nf == f) {
>> +			/* unlink it */
>>   			*fp = f->next;
>
> Strange you left this without annotations, while rest of your patches
> always use rcu_assign_pointer(*fp, rtnl_dereference(f->next)
>
> Note that it is absolutely fine to use *fp = f->next;
>
> ;)
>

I was just trying to be explicit in the other cases although I
chose rcu_assign_pointer in many cases instead of INIT_POINTER. So for
consistency I'll make this,

	RCU_INIT_POINTER(*fp, rtnl_dereference(f->next))

I also thought that sparse would warn about not wrapping f->next in
rtnl_dereference, but apparently that is not the case.

>> -			tcf_tree_unlock(tp);

-- 
John Fastabend         Intel Corporation