All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fan Du <fan.du@windriver.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Priyanka Jain <Priyanka.Jain@freescale.com>, <netdev@vger.kernel.org>
Subject: Re: [PATCH][XFRM] Replace rwlock on xfrm_policy_afinfo with rcu
Date: Wed, 8 Aug 2012 14:44:02 +0800	[thread overview]
Message-ID: <50220AB2.5030504@windriver.com> (raw)
In-Reply-To: <1344407147.28967.212.camel@edumazet-glaptop>

First, sorry to jump in.

On 2012年08月08日 14:25, Eric Dumazet wrote:
> On Tue, 2012-08-07 at 10:51 +0530, Priyanka Jain wrote:
>> xfrm_policy_afinfo is read mosly data structure.
>> Write on xfrm_policy_afinfo is done only at the
>> time of configuration.
>> So rwlocks can be safely replaced with RCU.
>>
>> RCUs usage optimizes the performance.
>
>
>>   static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family)
>> @@ -2530,16 +2535,16 @@ static struct xfrm_policy_afinfo *xfrm_policy_get_afinfo(unsigned short family)
>>   	struct xfrm_policy_afinfo *afinfo;
>>   	if (unlikely(family>= NPROTO))
>>   		return NULL;
>> -	read_lock(&xfrm_policy_afinfo_lock);
>> -	afinfo = xfrm_policy_afinfo[family];
>> +	rcu_read_lock();
>> +	afinfo = rcu_dereference(xfrm_policy_afinfo[family]);
>>   	if (unlikely(!afinfo))
>> -		read_unlock(&xfrm_policy_afinfo_lock);
>> +		rcu_read_unlock();
>
> This makes no sense to me : We cant safely return afinfo here.
>
> Note the current code is buggy as well, this is worrying.
>
> As soon as we exit from xfrm_policy_get_afinfo(), pointer might be
> invalid.
>
Yes, it might be invalid, but all the callers have checked the return
value, thus use it in a sane way.
So I don't follow "Note the current code is buggy as well".

Am I missing something here?


> Really, RCU conversion should be the right moment to spot those bugs and
> first fix them (for stable trees)
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 

Love each day!
--fan

  reply	other threads:[~2012-08-08  6:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-07  5:21 [PATCH][XFRM] Replace rwlock on xfrm_policy_afinfo with rcu Priyanka Jain
2012-08-07 23:21 ` David Miller
2012-08-08  4:53   ` Jain Priyanka-B32167
2012-08-08  5:55     ` David Miller
2012-08-08  9:41       ` Jain Priyanka-B32167
2012-08-08  6:25 ` Eric Dumazet
2012-08-08  6:44   ` Fan Du [this message]
2012-08-10  4:28     ` Jain Priyanka-B32167
2012-08-10  6:26       ` Eric Dumazet

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=50220AB2.5030504@windriver.com \
    --to=fan.du@windriver.com \
    --cc=Priyanka.Jain@freescale.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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.