From: Gao feng <gaofeng@cn.fujitsu.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] nfnetlink: use rcu_assign_pointer in nfnetlink_subsys_unregister
Date: Wed, 09 Oct 2013 11:28:32 +0800 [thread overview]
Message-ID: <5254CD60.3030306@cn.fujitsu.com> (raw)
In-Reply-To: <1381245834.12191.37.camel@edumazet-glaptop.roam.corp.google.com>
On 10/08/2013 11:23 PM, Eric Dumazet wrote:
> On Tue, 2013-10-08 at 18:04 +0800, Gao feng wrote:
>> Though I don't face an oops, but it is more safer to
>> set table's subsys through rcu_assign_pointer.
>>
>> Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
>> ---
>> net/netfilter/nfnetlink.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
>> index 572d87d..3cd2fe6 100644
>> --- a/net/netfilter/nfnetlink.c
>> +++ b/net/netfilter/nfnetlink.c
>> @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
>> int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n)
>> {
>> nfnl_lock(n->subsys_id);
>> - table[n->subsys_id].subsys = NULL;
>> + rcu_assign_pointer(table[n->subsys_id].subsys, NULL);
>> nfnl_unlock(n->subsys_id);
>> synchronize_rcu();
>> return 0;
>
> Certainly not.
>
> Assigning a NULL pointer do not require rcu_assign_pointer() but this,
> if you want to be really really clean.
>
The reason assigning a NULL pointer do not require rcu_assign_pointer
is it's impossible for a reader to access to uninitialized content?
So we don't need write barrier here to make sure the resource being
initialized before reader accessing it. Right?
> diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
> index 572d87d..649958b 100644
> --- a/net/netfilter/nfnetlink.c
> +++ b/net/netfilter/nfnetlink.c
> @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(nfnetlink_subsys_register);
> int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n)
> {
> nfnl_lock(n->subsys_id);
> - table[n->subsys_id].subsys = NULL;
> + RCU_INIT_POINTER(table[n->subsys_id].subsys, NULL);
> nfnl_unlock(n->subsys_id);
> synchronize_rcu();
> return 0;
>
>
>
>
>
prev parent reply other threads:[~2013-10-09 3:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-08 10:04 [PATCH] nfnetlink: use rcu_assign_pointer in nfnetlink_subsys_unregister Gao feng
2013-10-08 15:23 ` Eric Dumazet
2013-10-09 3:28 ` Gao feng [this message]
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=5254CD60.3030306@cn.fujitsu.com \
--to=gaofeng@cn.fujitsu.com \
--cc=eric.dumazet@gmail.com \
--cc=netfilter-devel@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;
as well as URLs for NNTP newsgroup(s).