coretemp(4)/amdtemp(4) and sysctl nodes

mdf at FreeBSD.org mdf at FreeBSD.org
Fri Dec 3 18:05:03 UTC 2010


There are very few uses in FreeBSD mainline code of
sysctl_remove_oid(), and I was looking at potentially removing them.
However, the use in coretemp/amdtemp has me slightly stumped.

Each device provides a device_get_sysctl_ctx sysctl_ctx that is
automatically cleaned up when the device goes away.  Yet the sysctl
nodes for both amdtemp and coretemp use the context of other devices,
rather than their own.  I can't quite figure out why, though the two
are slightly different enough that they may have different reasons.

For coretmp(4) I don't see how the parent device can be removed first,
since we are a child device.  So from my understanding it makes no
sense to have an explicit sysctl_remove_oid() and attach in the
parent's sysctl_ctx.

For amdtemp, the "temperature" sysctl is added to the nexus.acpi.cpu
device, which I suppose it's possible could be removed while the
amdtemp sysctl was still present, causing errors.  This case could be
dealt with by orphaning sysctl nodes at sysctl_ctx_free if there were
any not removed, presuming that whoever created them will clean them
up (or leak the memory).

Thoughts and explanations of the use of the parent's sysctl context?

Thanks,
matthew


More information about the freebsd-hackers mailing list