summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-07-28 02:36:01 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-08-08 04:55:11 +0200
commit7a0031ac07b250d2696248305738054f6b3b3adf (patch)
tree7875812b2ef96ee8d61131b05296156994520515
parent86b9f8ae939ca04cd9abd893272c8fb06293ef41 (diff)
downloadcryptodev-linux-7a0031ac07b250d2696248305738054f6b3b3adf.tar.gz
cryptodev-linux-7a0031ac07b250d2696248305738054f6b3b3adf.tar.xz
cryptodev-linux-7a0031ac07b250d2696248305738054f6b3b3adf.zip
Stop looking in the hash table after the first match.
There should be only one entry anyway. This reduces the average lookup time when there are hash collisions roughly by half.
-rw-r--r--ncr-limits.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ncr-limits.c b/ncr-limits.c
index 0545c87..ff8ff59 100644
--- a/ncr-limits.c
+++ b/ncr-limits.c
@@ -140,6 +140,7 @@ int ret;
mutex_unlock(&user_limit_mutex);
return -EPERM;
}
+ break;
}
}
@@ -175,6 +176,7 @@ int ret;
ret = -EPERM;
goto restore_user;
}
+ break;
}
}
@@ -203,8 +205,10 @@ int ret;
restore_user:
mutex_lock(&user_limit_mutex);
hlist_for_each_entry(uitem, pos, user_head, hlist) {
- if (uitem->uid == uid)
+ if (uitem->uid == uid) {
atomic_dec(&uitem->cnt[type]);
+ break;
+ }
}
mutex_unlock(&user_limit_mutex);
return ret;
@@ -223,6 +227,7 @@ struct hlist_node *pos;
hlist_for_each_entry(uitem, pos, hhead, hlist) {
if (uitem->uid == uid) {
atomic_dec(&uitem->cnt[type]);
+ break;
}
}
mutex_unlock(&user_limit_mutex);
@@ -233,6 +238,7 @@ struct hlist_node *pos;
hlist_for_each_entry(pitem, pos, hhead, hlist) {
if (pitem->pid == pid) {
atomic_dec(&pitem->cnt[type]);
+ break;
}
}
mutex_unlock(&process_limit_mutex);