From: Eric Dumazet <eric.dumazet@gmail.com>
To: Priyanka Jain <Priyanka.Jain@freescale.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH][XFRM] Replace rwlock on xfrm_policy_afinfo with rcu
Date: Wed, 08 Aug 2012 08:25:47 +0200 [thread overview]
Message-ID: <1344407147.28967.212.camel@edumazet-glaptop> (raw)
In-Reply-To: <1344316904-2544-1-git-send-email-Priyanka.Jain@freescale.com>
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.
Really, RCU conversion should be the right moment to spot those bugs and
first fix them (for stable trees)
next prev parent reply other threads:[~2012-08-08 6:25 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 [this message]
2012-08-08 6:44 ` Fan Du
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=1344407147.28967.212.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=Priyanka.Jain@freescale.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox