Commit 02dd83ba authored by Martin Blix Grydeland's avatar Martin Blix Grydeland Committed by Dridi Boukelmoune

Reduce locking in HSH_Lookup()

Make use of the new hsh_deref_objhead_unlock() in HSH_Lookup() to reduce
the number of times the objhead mutex is taken during cache hits.
parent e4c30267
......@@ -459,10 +459,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
oc->hits++;
retval = HSH_HIT;
}
Lck_Unlock(&oh->mtx);
*ocp = oc;
if (*bocp == NULL)
assert(hsh_deref_objhead(wrk, &oh));
AN(hsh_deref_objhead_unlock(wrk, &oh));
else
Lck_Unlock(&oh->mtx);
switch (retval) {
case HSH_HITPASS:
......@@ -539,12 +540,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
assert(oh->refcnt > 1);
assert(exp_oc->objhead == oh);
exp_oc->refcnt++;
Lck_Unlock(&oh->mtx);
*ocp = exp_oc;
assert(hsh_deref_objhead(wrk, &oh));
if (exp_oc->hits < LONG_MAX)
exp_oc->hits++;
AN(hsh_deref_objhead_unlock(wrk, &oh));
return (HSH_GRACE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment