Process state change tracker - system call
I want to create a new system call that gets the process state changes in the last T seconds for the requested process(with PID).
Example: sys_task_state_changes(pid, tsec) returns array R, S, R, S.
My plan was to add a new linked list in the task_struct structure that will save the process states and the time of change. When the system call is called it would read the list and return the states that are in the requested time.
My problem is how and where to save the states in this linked list?
Is this approach good or there is a better one?