summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2017-05-14 14:21:11 +0000
committermarius <marius@FreeBSD.org>2017-05-14 14:21:11 +0000
commit74e270956788070442f46a99e73af3b8bcfb769c (patch)
tree9b7a7da29aabef3116f921e038e19e7023283d89 /sys/kern
parent3ac3c3d1cff21197a89173e97a5392094cc31cf7 (diff)
downloadFreeBSD-src-74e270956788070442f46a99e73af3b8bcfb769c.zip
FreeBSD-src-74e270956788070442f46a99e73af3b8bcfb769c.tar.gz
MFC: r317982
- Also outside of the KOBJOPLOOKUP macro - which in turn is used by the code auto-generated for *.m - kobj_lookup_method(9) is useful; for example in back-ends or base class device drivers in order to determine whether a default method has been overridden. Thus, allow for the kobj_method_t pointer argument - used by KOBJOPLOOKUP in order to update the cache entry - of kobj_lookup_method(9), to be NULL. Actually, that pointer is redundant as it's just set to the same kobj_method_t that the kobj_lookup_method(9) function returns in the first place, but probably it serves to reduce the number of instructions generated for KOBJOPLOOKUP. - For the same reason, move updating kobj_lookup_{hits,misses} (if KOBJ_STATS is defined) from kobj_lookup_method(9) to KOBJOPLOOKUP. As a side-effect, this gets rid of the convoluted approach of always incrementing kobj_lookup_hits in KOBJOPLOOKUP and then in case of a cache miss, decrementing it in kobj_lookup_method(9) again.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/subr_kobj.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c
index 5be746a..15a7b8a 100644
--- a/sys/kern/subr_kobj.c
+++ b/sys/kern/subr_kobj.c
@@ -213,19 +213,11 @@ kobj_lookup_method(kobj_class_t cls,
{
kobj_method_t *ce;
-#ifdef KOBJ_STATS
- /*
- * Correct for the 'hit' assumption in KOBJOPLOOKUP and record
- * a 'miss'.
- */
- kobj_lookup_hits--;
- kobj_lookup_misses++;
-#endif
-
ce = kobj_lookup_method_mi(cls, desc);
if (!ce)
ce = &desc->deflt;
- *cep = ce;
+ if (cep)
+ *cep = ce;
return ce;
}
OpenPOWER on IntegriCloud