From: Jarek Poplawski <jarkao2@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Miller <davem@davemloft.net>,
jesse@nicira.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next-2.6] net: inet_add_protocol() can use cmpxchg()
Date: Thu, 9 Sep 2010 17:38:07 +0200 [thread overview]
Message-ID: <20100909153807.GA2055@del.dom.local> (raw)
In-Reply-To: <1284037058.2589.169.camel@edumazet-laptop>
On Thu, Sep 09, 2010 at 02:57:38PM +0200, Eric Dumazet wrote:
> Le jeudi 09 septembre 2010 ?? 09:59 +0000, Jarek Poplawski a écrit :
>
> > Btw, I wonder if for readability and debuging it shouldn't be made
> > generic as rcu_cmpxchg_pointer() etc.?
>
> There are a lot of things to do in this area (with proper __rcu sparse
> annotations, this can be not very readable ...)
Well, this is more than I could dream ;-) The main point to me was
autodocumentation in use, similarly to rcu_assign_pointer(). But, of
course, with the description below it's much better.
Thanks,
Jarek P.
>
> /**
> * rcu_cmpxchg - atomic compare and exchange, SMP & rcu safe
> * @p: pointer to value
> * @old: old value
> * @new: new value
> *
> * Equivalent to :
> * ATOMIC_BEGIN
> * ret = *p;
> * if (ret == old)
> * rcu_assign_pointer(*p, new);
> * ATOMIC_END
> * return ret;
> *
> * cmpxpchg() contains full memory barriers, so can be used
> * in rcu write side without additional smp_wmb() barrier
> */
> #define rcu_cmpxchg(p, old, new) cmpxchg(p, old, new)
>
>
> const struct net_protocol __rcu *
> inet_protos[MAX_INET_PROTOS] __read_mostly;
>
> ...
>
> return !rcu_cmpxchg(&inet_protos[hash],
> NULL,
> (const struct net_protocol __force __rcu *)prot) ?
> 0 : -1;
>
> ...
>
next prev parent reply other threads:[~2010-09-09 15:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-08 22:56 [PATCH net-next-2.6] net: inet_add_protocol() can use cmpxchg() Eric Dumazet
2010-09-08 23:49 ` Jesse Gross
2010-09-09 4:30 ` David Miller
2010-09-09 6:42 ` Jarek Poplawski
2010-09-09 6:55 ` Eric Dumazet
2010-09-09 7:09 ` Jarek Poplawski
2010-09-09 7:24 ` Jarek Poplawski
2010-09-09 9:08 ` Jarek Poplawski
2010-09-09 9:23 ` Eric Dumazet
2010-09-09 9:42 ` Jarek Poplawski
2010-09-09 9:59 ` Jarek Poplawski
2010-09-09 12:57 ` Eric Dumazet
2010-09-09 15:38 ` Jarek Poplawski [this message]
2010-09-09 5:23 ` Eric Dumazet
2010-09-09 4:31 ` David Miller
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=20100909153807.GA2055@del.dom.local \
--to=jarkao2@gmail.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=jesse@nicira.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;
as well as URLs for NNTP newsgroup(s).