Fixing sysctl LOR

mdf at FreeBSD.org mdf at FreeBSD.org
Fri Nov 26 01:44:08 UTC 2010


My previous thought on the matter was incorrect.  This patch (and two
small cleanups before it) mean the sysctl lock is no longer held
across the call to oid_handler, which means that WITNESS will no
longer make entries where sysctl lock is taken before any random lock
in the handler.

The idea is simple; keep track of the number of threads running the
handler so that the oid is not deleted (and sysctl_ctx_free(9) doesn't
return) before all threads are drained.  It does unfortunately mean
that the sysctl lock is  only taken in exclusive mode, but since it's
held for less time I don't anticipate a significant loss of
concurrency.  If there is a simple benchmark someone can recommend I'd
be happy to check the difference.

I would like at some point to also reduce the number of calls to
sysctl(2) made by sysctl(8); this would also help performance.  Among
other things I wonder if eliminating the numerical array to describe
an oid would be acceptable; in a few circumstances it would mean
longer comparisons (strcmp versus integer comparison) but for many
uses it eliminates the name2oid step, and it would also mean there's
no longer a need for fixed numbered entries.

Cleanup:
http://people.freebsd.org/~mdf/0001-Use-the-SYSCTL_CHILDREN-macro-in-kern_sysctl.c-to-he.patch
http://people.freebsd.org/~mdf/0002-Slightly-modify-the-logic-in-sysctl_find_oid-to-redu.patch

The patch:
http://people.freebsd.org/~mdf/0003-Do-not-hold-the-sysctl-lock-across-a-call-to-the-han.patch

Thanks,
matthew


More information about the freebsd-arch mailing list