diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-07-16 17:04:35 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2014-07-23 13:18:06 -0400 |
commit | 9667a23db0dc0bd4892f0ada7e4e71528eaeed62 (patch) | |
tree | 412d0676a0157467442c4d02e646f8272ccd620e /kernel | |
parent | ccbf62d8a284cf181ac28c8e8407dd077d90dd4b (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.c | 34 |
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 | 52 | static void delayacct_end(u64 *start, u64 *total, u32 *count) | |
53 | static 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(¤t->delays->lock, flags); |
62 | ns = timespec_to_ns(&ts); | 59 | *total += ns; |
63 | if (ns < 0) | 60 | (*count)++; |
64 | return; | 61 | spin_unlock_irqrestore(¤t->delays->lock, flags); |
65 | 62 | } | |
66 | spin_lock_irqsave(¤t->delays->lock, flags); | ||
67 | *total += ns; | ||
68 | (*count)++; | ||
69 | spin_unlock_irqrestore(¤t->delays->lock, flags); | ||
70 | } | 63 | } |
71 | 64 | ||
72 | void __delayacct_blkio_start(void) | 65 | void __delayacct_blkio_start(void) |
73 | { | 66 | { |
74 | ktime_get_ts(¤t->delays->blkio_start); | 67 | current->delays->blkio_start = ktime_get_ns(); |
75 | } | 68 | } |
76 | 69 | ||
77 | void __delayacct_blkio_end(void) | 70 | void __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(¤t->delays->blkio_start, | 74 | delayacct_end(¤t->delays->blkio_start, |
82 | ¤t->delays->blkio_end, | ||
83 | ¤t->delays->swapin_delay, | 75 | ¤t->delays->swapin_delay, |
84 | ¤t->delays->swapin_count); | 76 | ¤t->delays->swapin_count); |
85 | else /* Other block I/O */ | 77 | else /* Other block I/O */ |
86 | delayacct_end(¤t->delays->blkio_start, | 78 | delayacct_end(¤t->delays->blkio_start, |
87 | ¤t->delays->blkio_end, | ||
88 | ¤t->delays->blkio_delay, | 79 | ¤t->delays->blkio_delay, |
89 | ¤t->delays->blkio_count); | 80 | ¤t->delays->blkio_count); |
90 | } | 81 | } |
@@ -159,13 +150,12 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk) | |||
159 | 150 | ||
160 | void __delayacct_freepages_start(void) | 151 | void __delayacct_freepages_start(void) |
161 | { | 152 | { |
162 | ktime_get_ts(¤t->delays->freepages_start); | 153 | current->delays->freepages_start = ktime_get_ns(); |
163 | } | 154 | } |
164 | 155 | ||
165 | void __delayacct_freepages_end(void) | 156 | void __delayacct_freepages_end(void) |
166 | { | 157 | { |
167 | delayacct_end(¤t->delays->freepages_start, | 158 | delayacct_end(¤t->delays->freepages_start, |
168 | ¤t->delays->freepages_end, | ||
169 | ¤t->delays->freepages_delay, | 159 | ¤t->delays->freepages_delay, |
170 | ¤t->delays->freepages_count); | 160 | ¤t->delays->freepages_count); |
171 | } | 161 | } |