[40 points + 20 bonus points] In Part 2, you will modify your kernel module, perftop
, to: (a) track the time that both user and kernel tasks spend on a CPU and (b) print the 20 most scheduled tasks on the system using /proc
.
[20 points] Modify your kernel module from Part 1 to track tasks instead of PIDs. A task is defined as a unique user or kernel stack trace. The hash table key will now be a hash of a task stack trace, and the value will be the number of times the unique kernel stack trace is scheduled on the CPU. Particularly, referring to background reading stack trace and Jenkins Hash in Part 1 of the project (Assignment 6
).
Tasks:
In the Kprobes
event handler, get a given task's stack trace
stack_trace_save
function for a kernel taskstack_trace_save_user
function for a user taskkallsyms_lookup_name()
Modify the kernel modules hash table to store the stack trace instead of PID as the key (you can pass the stack trace buffer to Jenkins hash)
Increment the schedule count of each task (stack trace) in the hash table
Modify the open
function of the proc
file to print with cat /proc/perftop
the stack trace dump and its corresponding number of times it has been scheduled
Deliverables:
perftop
modulecat /proc/perftop
[20 points] Calculate the time spent by each kernel task scheduled on a CPU and store it.
Task:
Modify the Kprobes
event handler to measure the time spent by each task on CPU
(the time the task is actively running TASK_RUNNING)
rdtsc
counterModify the open function in the /proc
file to print the stack trace and the
cumulative time spent by the task on the cpu. The time can be in rdtsc ticks;
please denote this unit of measurement in your print line.
Deliverables:
perftop
modulecat /proc/perftop
[20 points] Modify the kernel module to print the 20 most scheduled tasks.
Note: This is an optional task. Credits are added to your total homework points, provided they do not cause your total to exceed the maximum points for the homework section.
Tasks:
Deliverables:
perftop
modulecat /proc/perftop