azet/kitten — pull request #1 by azet (2014-11-05 03:04:59+00:00)
Title: Add per-task energy stats tracking.

If CONFIG_TASK_MEAS is turned on, Kitten tracks the energy use of
each task. The task_struct structure is extended to include fields
tracking the energy use of the task. Kitten's periodic timer tick
is updated to query the processor's energy counter and attribute the
energy energy consumed since the last read to the currently running
task. Similarly, the context switch code is updated to read the
processor's energy counter before and after switching to a new task,
and to properly attribute the energy used by the previous task to
the previous task_struct, and set the energy baseline for the new
task.

A new system call is added, task_meas() to allow a user-space process
to query the energy stats of any task in the system.

int sys_task_meas(
id_t aspace_id, id_t task_id, uint64_t __user *time,
uint64_t __user *energy, uint64_t __user *unit_energy);

The hello_world example init_task is updated to include a test
of this API (see task_meas_api_test()).

Currently on Intel Sandy Bridge and Ivy Bridge RAPL are supported.
Haswell might work but has not been tested.