Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 111256
b: refs/heads/master
c: 6eac560
h: refs/heads/master
v: v3
  • Loading branch information
Andi Kleen authored and David S. Miller committed Aug 28, 2008
1 parent ff790e0 commit 3a4e7c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 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: 4d40555250320520c5398569457962b3984fc75e
refs/heads/master: 6eac56040787c3ff604fe7d48bbbb7897cd1387c
26 changes: 19 additions & 7 deletions trunk/net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1946,6 +1946,12 @@ static void *listening_get_idx(struct seq_file *seq, loff_t *pos)
return rc;
}

static inline int empty_bucket(struct tcp_iter_state *st)
{
return hlist_empty(&tcp_hashinfo.ehash[st->bucket].chain) &&
hlist_empty(&tcp_hashinfo.ehash[st->bucket].twchain);
}

static void *established_get_first(struct seq_file *seq)
{
struct tcp_iter_state* st = seq->private;
Expand All @@ -1958,6 +1964,10 @@ static void *established_get_first(struct seq_file *seq)
struct inet_timewait_sock *tw;
rwlock_t *lock = inet_ehash_lockp(&tcp_hashinfo, st->bucket);

/* Lockless fast path for the common case of empty buckets */
if (empty_bucket(st))
continue;

read_lock_bh(lock);
sk_for_each(sk, node, &tcp_hashinfo.ehash[st->bucket].chain) {
if (sk->sk_family != st->family ||
Expand Down Expand Up @@ -2008,13 +2018,15 @@ static void *established_get_next(struct seq_file *seq, void *cur)
read_unlock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
st->state = TCP_SEQ_STATE_ESTABLISHED;

if (++st->bucket < tcp_hashinfo.ehash_size) {
read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain);
} else {
cur = NULL;
goto out;
}
/* Look for next non empty bucket */
while (++st->bucket < tcp_hashinfo.ehash_size &&
empty_bucket(st))
;
if (st->bucket >= tcp_hashinfo.ehash_size)
return NULL;

read_lock_bh(inet_ehash_lockp(&tcp_hashinfo, st->bucket));
sk = sk_head(&tcp_hashinfo.ehash[st->bucket].chain);
} else
sk = sk_next(sk);

Expand Down

0 comments on commit 3a4e7c9

Please sign in to comment.