aboutsummaryrefslogtreecommitdiff
path: root/net/llc/llc_proc.c
diff options
context:
space:
mode:
authorOctavian Purdila <opurdila@ixiacom.com>2009-12-26 11:51:05 +0000
committerDavid S. Miller <davem@davemloft.net>2009-12-26 20:45:32 -0800
commit52d58aef5ee460fedd7f250f05e79081019f2c79 (patch)
tree9c8d2bf8374570038820a47325a2305bcb83111d /net/llc/llc_proc.c
parent6d2e3ea284463d5ab34e9cf2a41d0b8627b95d02 (diff)
llc: replace the socket list with a local address based hash
For the cases where a lot of interfaces are used in conjunction with a lot of LLC sockets bound to the same SAP, the iteration of the socket list becomes prohibitively expensive. Replacing the list with a a local address based hash significantly improves the bind and listener lookup operations as well as the datagram delivery. Connected sockets delivery is also improved, but this patch does not address the case where we have lots of sockets with the same local address connected to different remote addresses. In order to keep the socket sanity checks alive and fast a socket counter was added to the SAP structure. Signed-off-by: Octavian Purdila <opurdila@ixiacom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/llc/llc_proc.c')
-rw-r--r--net/llc/llc_proc.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 6b3d033b323..09dec630720 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -34,17 +34,22 @@ static struct sock *llc_get_sk_idx(loff_t pos)
{
struct list_head *sap_entry;
struct llc_sap *sap;
- struct hlist_nulls_node *node;
struct sock *sk = NULL;
+ int i;
list_for_each(sap_entry, &llc_sap_list) {
sap = list_entry(sap_entry, struct llc_sap, node);
spin_lock_bh(&sap->sk_lock);
- sk_nulls_for_each(sk, node, &sap->sk_list) {
- if (!pos)
- goto found;
- --pos;
+ for (i = 0; i < LLC_SK_LADDR_HASH_ENTRIES; i++) {
+ struct hlist_nulls_head *head = &sap->sk_laddr_hash[i];
+ struct hlist_nulls_node *node;
+
+ sk_nulls_for_each(sk, node, head) {
+ if (!pos)
+ goto found; /* keep the lock */
+ --pos;
+ }
}
spin_unlock_bh(&sap->sk_lock);
}
@@ -61,6 +66,19 @@ static void *llc_seq_start(struct seq_file *seq, loff_t *pos)
return l ? llc_get_sk_idx(--l) : SEQ_START_TOKEN;
}
+static struct sock *laddr_hash_next(struct llc_sap *sap, int bucket)
+{
+ struct hlist_nulls_node *node;
+ struct sock *sk = NULL;
+
+ while (++bucket < LLC_SK_LADDR_HASH_ENTRIES)
+ sk_nulls_for_each(sk, node, &sap->sk_laddr_hash[bucket])
+ goto out;
+
+out:
+ return sk;
+}
+
static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct sock* sk, *next;
@@ -80,17 +98,15 @@ static void *llc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
}
llc = llc_sk(sk);
sap = llc->sap;
+ sk = laddr_hash_next(sap, llc_sk_laddr_hashfn(sap, &llc->laddr));
+ if (sk)
+ goto out;
spin_unlock_bh(&sap->sk_lock);
- sk = NULL;
- for (;;) {
- if (sap->node.next == &llc_sap_list)
- break;
- sap = list_entry(sap->node.next, struct llc_sap, node);
+ list_for_each_entry_continue(sap, &llc_sap_list, node) {
spin_lock_bh(&sap->sk_lock);
- if (!hlist_nulls_empty(&sap->sk_list)) {
- sk = sk_nulls_head(&sap->sk_list);
- break;
- }
+ sk = laddr_hash_next(sap, -1);
+ if (sk)
+ break; /* keep the lock */
spin_unlock_bh(&sap->sk_lock);
}
out: