[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 09 Sep 2010 14:57:38 +0200
From: Eric Dumazet <eric.dumazet@...il.com>
To: Jarek Poplawski <jarkao2@...il.com>
Cc: David Miller <davem@...emloft.net>, jesse@...ira.com,
netdev@...r.kernel.org
Subject: Re: [PATCH net-next-2.6] net: inet_add_protocol() can use cmpxchg()
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 ...)
/**
* 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;
...
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists