aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-07-16 17:04:35 -0400
committerJohn Stultz <john.stultz@linaro.org>2014-07-23 13:18:06 -0400
commit9667a23db0dc0bd4892f0ada7e4e71528eaeed62 (patch)
tree412d0676a0157467442c4d02e646f8272ccd620e /kernel
parentccbf62d8a284cf181ac28c8e8407dd077d90dd4b (diff)
delayacct: Make accounting nanosecond based
Kill the timespec juggling and calculate with plain nanoseconds. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/delayacct.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index de699f42f9bc..cf2e65dddb19 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -46,32 +46,25 @@ void __delayacct_tsk_init(struct task_struct *tsk)
46} 46}
47 47
48/* 48/*
49 * Finish delay accounting for a statistic using 49 * Finish delay accounting for a statistic using its timestamps (@start),
50 * its timestamps (@start, @end), accumalator (@total) and @count 50 * accumalator (@total) and @count
51 */ 51 */
52 52static void delayacct_end(u64 *start, u64 *total, u32 *count)
53static void delayacct_end(struct timespec *start, struct timespec *end,
54 u64 *total, u32 *count)
55{ 53{
56 struct timespec ts; 54 s64 ns = ktime_get_ns() - *start;
57 s64 ns;
58 unsigned long flags; 55 unsigned long flags;
59 56
60 ktime_get_ts(end); 57 if (ns > 0) {
61 ts = timespec_sub(*end, *start); 58 spin_lock_irqsave(&current->delays->lock, flags);
62 ns = timespec_to_ns(&ts); 59 *total += ns;
63 if (ns < 0) 60 (*count)++;
64 return; 61 spin_unlock_irqrestore(&current->delays->lock, flags);
65 62 }
66 spin_lock_irqsave(&current->delays->lock, flags);
67 *total += ns;
68 (*count)++;
69 spin_unlock_irqrestore(&current->delays->lock, flags);
70} 63}
71 64
72void __delayacct_blkio_start(void) 65void __delayacct_blkio_start(void)
73{ 66{
74 ktime_get_ts(&current->delays->blkio_start); 67 current->delays->blkio_start = ktime_get_ns();
75} 68}
76 69
77void __delayacct_blkio_end(void) 70void __delayacct_blkio_end(void)
@@ -79,12 +72,10 @@ void __delayacct_blkio_end(void)
79 if (current->delays->flags & DELAYACCT_PF_SWAPIN) 72 if (current->delays->flags & DELAYACCT_PF_SWAPIN)
80 /* Swapin block I/O */ 73 /* Swapin block I/O */
81 delayacct_end(&current->delays->blkio_start, 74 delayacct_end(&current->delays->blkio_start,
82 &current->delays->blkio_end,
83 &current->delays->swapin_delay, 75 &current->delays->swapin_delay,
84 &current->delays->swapin_count); 76 &current->delays->swapin_count);
85 else /* Other block I/O */ 77 else /* Other block I/O */
86 delayacct_end(&current->delays->blkio_start, 78 delayacct_end(&current->delays->blkio_start,
87 &current->delays->blkio_end,
88 &current->delays->blkio_delay, 79 &current->delays->blkio_delay,
89 &current->delays->blkio_count); 80 &current->delays->blkio_count);
90} 81}
@@ -159,13 +150,12 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
159 150
160void __delayacct_freepages_start(void) 151void __delayacct_freepages_start(void)
161{ 152{
162 ktime_get_ts(&current->delays->freepages_start); 153 current->delays->freepages_start = ktime_get_ns();
163} 154}
164 155
165void __delayacct_freepages_end(void) 156void __delayacct_freepages_end(void)
166{ 157{
167 delayacct_end(&current->delays->freepages_start, 158 delayacct_end(&current->delays->freepages_start,
168 &current->delays->freepages_end,
169 &current->delays->freepages_delay, 159 &current->delays->freepages_delay,
170 &current->delays->freepages_count); 160 &current->delays->freepages_count);
171} 161}