Repository navigation
Expand file tree
/
Copy pathprofiler_patch.diff
More file actions
53 lines (49 loc) · 1.69 KB
/
Copy pathprofiler_patch.diff
File metadata and controls
53 lines (49 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
diff --git a/kernel/time/posix-cpu-timers.c.orig b/kernel/time/posix-cpu-timers.c
index 6bcee47..830dfb9 100644
--- a/kernel/time/posix-cpu-timers.c.orig
+++ b/kernel/time/posix-cpu-timers.c
@@ -12,6 +12,7 @@
#include <linux/kernel_stat.h>
#include <trace/events/timer.h>
#include <linux/tick.h>
+#include <linux/timekeeping.h>
#include <linux/workqueue.h>
#include <linux/compat.h>
#include <linux/sched/deadline.h>
@@ -1292,10 +1293,15 @@ static void handle_posix_cpu_timers(struct task_struct *tsk)
struct k_itimer *timer, *next;
unsigned long flags, start;
LIST_HEAD(firing);
+ u64 profile_t0 = 0, profile_t1 = 0;
if (!lock_task_sighand(tsk, &flags))
return;
+ // Faith: Set this bools up after `lock_task_sighand()` so
+ // that they don't accidentally increase the race window somehow
+ const bool profile = !strcmp(tsk->comm, "PROFILE");
+
do {
/*
* On RT locking sighand lock does not disable interrupts,
@@ -1356,6 +1362,10 @@ static void handle_posix_cpu_timers(struct task_struct *tsk)
*/
unlock_task_sighand(tsk, &flags);
+ // Faith: profile the time taken to handle the timers
+ if (profile)
+ profile_t0 = ktime_get_mono_fast_ns();
+
/*
* Now that all the timers on our list have the firing flag,
* no one will touch their list entries but us. We'll take
@@ -1387,6 +1397,13 @@ static void handle_posix_cpu_timers(struct task_struct *tsk)
rcu_assign_pointer(timer->it.cpu.handling, NULL);
spin_unlock(&timer->it_lock);
}
+
+ // Faith: profile the time taken to handle the timers
+ if (profile) {
+ profile_t1 = ktime_get_mono_fast_ns();
+ printk("handle_posix_cpu_timers: delta_ns=%llu\n",
+ (unsigned long long)(profile_t1 - profile_t0));
+ }
}
/*