* [PATCH net-next] inetpeer: inetpeer_invalidate_tree() cleanup
@ 2012-06-20 14:02 Eric Dumazet
2012-06-20 21:39 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2012-06-20 14:02 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Steffen Klassert
From: Eric Dumazet <edumazet@google.com>
No need to use cmpxchg() in inetpeer_invalidate_tree() since we hold
base lock.
Also use correct rcu annotations to remove sparse errors
(CONFIG_SPARSE_RCU_POINTER=y)
net/ipv4/inetpeer.c:144:19: error: incompatible types in comparison
expression (different address spaces)
net/ipv4/inetpeer.c:149:20: error: incompatible types in comparison
expression (different address spaces)
net/ipv4/inetpeer.c:595:10: error: incompatible types in comparison
expression (different address spaces)
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/inetpeer.c | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index cac02ad..da90a8c 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -126,7 +126,7 @@ int inet_peer_maxttl __read_mostly = 10 * 60 * HZ; /* usual time to live: 10 min
static void inetpeer_gc_worker(struct work_struct *work)
{
- struct inet_peer *p, *n;
+ struct inet_peer *p, *n, *c;
LIST_HEAD(list);
spin_lock_bh(&gc_lock);
@@ -138,17 +138,19 @@ static void inetpeer_gc_worker(struct work_struct *work)
list_for_each_entry_safe(p, n, &list, gc_list) {
- if(need_resched())
+ if (need_resched())
cond_resched();
- if (p->avl_left != peer_avl_empty) {
- list_add_tail(&p->avl_left->gc_list, &list);
- p->avl_left = peer_avl_empty;
+ c = rcu_dereference_protected(p->avl_left, 1);
+ if (c != peer_avl_empty) {
+ list_add_tail(&c->gc_list, &list);
+ p->avl_left = peer_avl_empty_rcu;
}
- if (p->avl_right != peer_avl_empty) {
- list_add_tail(&p->avl_right->gc_list, &list);
- p->avl_right = peer_avl_empty;
+ c = rcu_dereference_protected(p->avl_right, 1);
+ if (c != peer_avl_empty) {
+ list_add_tail(&c->gc_list, &list);
+ p->avl_right = peer_avl_empty_rcu;
}
n = list_entry(p->gc_list.next, struct inet_peer, gc_list);
@@ -587,23 +589,17 @@ static void inetpeer_inval_rcu(struct rcu_head *head)
void inetpeer_invalidate_tree(struct inet_peer_base *base)
{
- struct inet_peer *old, *new, *prev;
+ struct inet_peer *root;
write_seqlock_bh(&base->lock);
- old = base->root;
- if (old == peer_avl_empty_rcu)
- goto out;
-
- new = peer_avl_empty_rcu;
-
- prev = cmpxchg(&base->root, old, new);
- if (prev == old) {
+ root = rcu_deref_locked(base->root, base);
+ if (root != peer_avl_empty) {
+ base->root = peer_avl_empty_rcu;
base->total = 0;
- call_rcu(&prev->gc_rcu, inetpeer_inval_rcu);
+ call_rcu(&root->gc_rcu, inetpeer_inval_rcu);
}
-out:
write_sequnlock_bh(&base->lock);
}
EXPORT_SYMBOL(inetpeer_invalidate_tree);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] inetpeer: inetpeer_invalidate_tree() cleanup
2012-06-20 14:02 [PATCH net-next] inetpeer: inetpeer_invalidate_tree() cleanup Eric Dumazet
@ 2012-06-20 21:39 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-06-20 21:39 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, steffen.klassert
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 20 Jun 2012 16:02:10 +0200
> From: Eric Dumazet <edumazet@google.com>
>
> No need to use cmpxchg() in inetpeer_invalidate_tree() since we hold
> base lock.
>
> Also use correct rcu annotations to remove sparse errors
> (CONFIG_SPARSE_RCU_POINTER=y)
>
> net/ipv4/inetpeer.c:144:19: error: incompatible types in comparison
> expression (different address spaces)
> net/ipv4/inetpeer.c:149:20: error: incompatible types in comparison
> expression (different address spaces)
> net/ipv4/inetpeer.c:595:10: error: incompatible types in comparison
> expression (different address spaces)
>
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-20 21:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-20 14:02 [PATCH net-next] inetpeer: inetpeer_invalidate_tree() cleanup Eric Dumazet
2012-06-20 21:39 ` David Miller
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).