The core patch introduces pointers to individual resource class objects in the task_struct. These objects are created by the resource controllers and contain controller-specific data. The task struct also contains a pointer to user-specified tag that the classification module could choose to use for classification.
The core patch defines dummy functions for each of the cpu, mem, io and net classes for testing. It declares a class struct per resource (the cpu resource being shown for concreteness)
struct ckrm_cpu_class { ulong share, ulong usage }
and allocates a default instance of it (ckrm_dflt_cpu_classobj). The dummy function definitions allocate and free instances of ckrm_cpu_class, set its share, get its usage or assign a task's cpu class to it. However, there is no enforcement of the share specification of these dummy classes and the usage information is always zero.
A real cpu controller that enforces per-class shares and records per-class usage would need to comment out the dummy definitions for the cpu resource (leaving the rest alone) and replace it with its own declaration of a ckrm_cpu_class and definitions for the functions above and a default ckrm_cpu_class object.
The same requirements hold for mem, io and net controllers.
The core patch defines a table of callback functions that can be populated by a classification module. The patch also modifies the appropriate kernel functions to ensure that they call the callback functions if they are defined.
The classification callback API consists of:
ckrm_register_engine(cbs): populate the callback table using the functions supplied in cbs.
ckrm_unregister_engine : clear the callback table
ckrm_cb_fork : on fork/clone/vfork
ckrm_cb_exit : on sys_exit
ckrm_cb_exec : on sys_execve
ckrm_cb_login : on a new user login. Hook not implemented yet.
ckrm_cb_id : single callback from all functions changing the real or effective uid, gid of a task
ckrm_cb_useradd : on user addition
ckrm_cb_userdel : on user deletion
A classification module needs to define its own table of callback functions and register it. It can choose to implement only a subset of the callbacks - the undefined ones are never called.