OpenSolaris

  subsites   code review   repo   packages   bugs   defect   polls   planet

Energy Star Guidelines for Kernel Programmers

When deploying a new kernel thread in Solaris, please be aware that it is necessary to follow a protocol which allows the thread to be quiesced in a safe manner when cpr is suspending the system. The protocol was developed so that kernel threads are given notice that the system is going to be shut down. Cpr requires that ALL threads in the system be quiesced so that kernel memory doesn't change as the pages are being written to the statefile.

The operation of fsflush() is a good illustration of how the callback protocol works:

#include <sys/callb.h>

In the initialization of the fsflush thread, before the main service loop is entered, it invokes the CALLB_CPR_INIT macro. This initializes a data structure and enters the thread in the callback table (see callb.c):

For example,

The lock which was passed as the first argument of the CALLB_CPR_INIT macro invocation must be held when CALLB_CPR_EXIT is invoked. *** NOTE *** CALLB_CPR_EXIT does a mutex_exit() on the lock which is passed in as an argument. If an existing kernel thread is being modified to comply with the cpr protocol, and if the thread shares an existing lock to also protect the cprinfo structure, BE CAREFUL NOT TO RELEASE THE LOCK TWICE! If there is an existing mutex_exit for the shared lock, it may need to be removed.

Note: The macro definitions in callb.h contain some references to an obsolete flag. This will be cleaned up shortly. Also, comments will be added to thread.h and thread.c explaining the need to conform to the protocol described here.


If you have comments or questions about this, please contact estar-dev at sun dot com.