Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 314525
b: refs/heads/master
c: da55737
h: refs/heads/master
i:
  314523: e1ff58e
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 20, 2012
1 parent 601accd commit c243633
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6dab015cf8c9d2fabb13d0332998bc440e9c6555
refs/heads/master: da55737467c1c3bc02271039c088171d82e0796f
34 changes: 15 additions & 19 deletions trunk/net/ipv4/inetpeer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);

0 comments on commit c243633

Please sign in to comment.