diff options
Diffstat (limited to 'arch/ia64/kernel/time.c')
-rw-r--r-- | arch/ia64/kernel/time.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/arch/ia64/kernel/time.c b/arch/ia64/kernel/time.c index 17fda5293c67..48e15a51782f 100644 --- a/arch/ia64/kernel/time.c +++ b/arch/ia64/kernel/time.c | |||
@@ -59,6 +59,84 @@ static struct clocksource clocksource_itc = { | |||
59 | }; | 59 | }; |
60 | static struct clocksource *itc_clocksource; | 60 | static struct clocksource *itc_clocksource; |
61 | 61 | ||
62 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | ||
63 | |||
64 | #include <linux/kernel_stat.h> | ||
65 | |||
66 | extern cputime_t cycle_to_cputime(u64 cyc); | ||
67 | |||
68 | /* | ||
69 | * Called from the context switch with interrupts disabled, to charge all | ||
70 | * accumulated times to the current process, and to prepare accounting on | ||
71 | * the next process. | ||
72 | */ | ||
73 | void ia64_account_on_switch(struct task_struct *prev, struct task_struct *next) | ||
74 | { | ||
75 | struct thread_info *pi = task_thread_info(prev); | ||
76 | struct thread_info *ni = task_thread_info(next); | ||
77 | cputime_t delta_stime, delta_utime; | ||
78 | __u64 now; | ||
79 | |||
80 | now = ia64_get_itc(); | ||
81 | |||
82 | delta_stime = cycle_to_cputime(pi->ac_stime + (now - pi->ac_stamp)); | ||
83 | account_system_time(prev, 0, delta_stime); | ||
84 | account_system_time_scaled(prev, delta_stime); | ||
85 | |||
86 | if (pi->ac_utime) { | ||
87 | delta_utime = cycle_to_cputime(pi->ac_utime); | ||
88 | account_user_time(prev, delta_utime); | ||
89 | account_user_time_scaled(prev, delta_utime); | ||
90 | } | ||
91 | |||
92 | pi->ac_stamp = ni->ac_stamp = now; | ||
93 | ni->ac_stime = ni->ac_utime = 0; | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Account time for a transition between system, hard irq or soft irq state. | ||
98 | * Note that this function is called with interrupts enabled. | ||
99 | */ | ||
100 | void account_system_vtime(struct task_struct *tsk) | ||
101 | { | ||
102 | struct thread_info *ti = task_thread_info(tsk); | ||
103 | unsigned long flags; | ||
104 | cputime_t delta_stime; | ||
105 | __u64 now; | ||
106 | |||
107 | local_irq_save(flags); | ||
108 | |||
109 | now = ia64_get_itc(); | ||
110 | |||
111 | delta_stime = cycle_to_cputime(ti->ac_stime + (now - ti->ac_stamp)); | ||
112 | account_system_time(tsk, 0, delta_stime); | ||
113 | account_system_time_scaled(tsk, delta_stime); | ||
114 | ti->ac_stime = 0; | ||
115 | |||
116 | ti->ac_stamp = now; | ||
117 | |||
118 | local_irq_restore(flags); | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * Called from the timer interrupt handler to charge accumulated user time | ||
123 | * to the current process. Must be called with interrupts disabled. | ||
124 | */ | ||
125 | void account_process_tick(struct task_struct *p, int user_tick) | ||
126 | { | ||
127 | struct thread_info *ti = task_thread_info(p); | ||
128 | cputime_t delta_utime; | ||
129 | |||
130 | if (ti->ac_utime) { | ||
131 | delta_utime = cycle_to_cputime(ti->ac_utime); | ||
132 | account_user_time(p, delta_utime); | ||
133 | account_user_time_scaled(p, delta_utime); | ||
134 | ti->ac_utime = 0; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | #endif /* CONFIG_VIRT_CPU_ACCOUNTING */ | ||
139 | |||
62 | static irqreturn_t | 140 | static irqreturn_t |
63 | timer_interrupt (int irq, void *dev_id) | 141 | timer_interrupt (int irq, void *dev_id) |
64 | { | 142 | { |