Commit 9667a23d authored by Thomas Gleixner's avatar Thomas Gleixner Committed by John Stultz

delayacct: Make accounting nanosecond based

Kill the timespec juggling and calculate with plain nanoseconds.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
parent ccbf62d8
...@@ -813,7 +813,7 @@ struct task_delay_info { ...@@ -813,7 +813,7 @@ struct task_delay_info {
* associated with the operation is added to XXX_delay. * associated with the operation is added to XXX_delay.
* XXX_delay contains the accumulated delay time in nanoseconds. * XXX_delay contains the accumulated delay time in nanoseconds.
*/ */
struct timespec blkio_start, blkio_end; /* Shared by blkio, swapin */ u64 blkio_start; /* Shared by blkio, swapin */
u64 blkio_delay; /* wait for sync block io completion */ u64 blkio_delay; /* wait for sync block io completion */
u64 swapin_delay; /* wait for swapin block io completion */ u64 swapin_delay; /* wait for swapin block io completion */
u32 blkio_count; /* total count of the number of sync block */ u32 blkio_count; /* total count of the number of sync block */
...@@ -821,7 +821,7 @@ struct task_delay_info { ...@@ -821,7 +821,7 @@ struct task_delay_info {
u32 swapin_count; /* total count of the number of swapin block */ u32 swapin_count; /* total count of the number of swapin block */
/* io operations performed */ /* io operations performed */
struct timespec freepages_start, freepages_end; u64 freepages_start;
u64 freepages_delay; /* wait for memory reclaim */ u64 freepages_delay; /* wait for memory reclaim */
u32 freepages_count; /* total count of memory reclaim */ u32 freepages_count; /* total count of memory reclaim */
}; };
......
...@@ -46,32 +46,25 @@ void __delayacct_tsk_init(struct task_struct *tsk) ...@@ -46,32 +46,25 @@ void __delayacct_tsk_init(struct task_struct *tsk)
} }
/* /*
* Finish delay accounting for a statistic using * Finish delay accounting for a statistic using its timestamps (@start),
* its timestamps (@start, @end), accumalator (@total) and @count * accumalator (@total) and @count
*/ */
static void delayacct_end(u64 *start, u64 *total, u32 *count)
static void delayacct_end(struct timespec *start, struct timespec *end,
u64 *total, u32 *count)
{ {
struct timespec ts; s64 ns = ktime_get_ns() - *start;
s64 ns;
unsigned long flags; unsigned long flags;
ktime_get_ts(end); if (ns > 0) {
ts = timespec_sub(*end, *start); spin_lock_irqsave(&current->delays->lock, flags);
ns = timespec_to_ns(&ts); *total += ns;
if (ns < 0) (*count)++;
return; spin_unlock_irqrestore(&current->delays->lock, flags);
}
spin_lock_irqsave(&current->delays->lock, flags);
*total += ns;
(*count)++;
spin_unlock_irqrestore(&current->delays->lock, flags);
} }
void __delayacct_blkio_start(void) void __delayacct_blkio_start(void)
{ {
ktime_get_ts(&current->delays->blkio_start); current->delays->blkio_start = ktime_get_ns();
} }
void __delayacct_blkio_end(void) void __delayacct_blkio_end(void)
...@@ -79,12 +72,10 @@ void __delayacct_blkio_end(void) ...@@ -79,12 +72,10 @@ void __delayacct_blkio_end(void)
if (current->delays->flags & DELAYACCT_PF_SWAPIN) if (current->delays->flags & DELAYACCT_PF_SWAPIN)
/* Swapin block I/O */ /* Swapin block I/O */
delayacct_end(&current->delays->blkio_start, delayacct_end(&current->delays->blkio_start,
&current->delays->blkio_end,
&current->delays->swapin_delay, &current->delays->swapin_delay,
&current->delays->swapin_count); &current->delays->swapin_count);
else /* Other block I/O */ else /* Other block I/O */
delayacct_end(&current->delays->blkio_start, delayacct_end(&current->delays->blkio_start,
&current->delays->blkio_end,
&current->delays->blkio_delay, &current->delays->blkio_delay,
&current->delays->blkio_count); &current->delays->blkio_count);
} }
...@@ -159,13 +150,12 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk) ...@@ -159,13 +150,12 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
void __delayacct_freepages_start(void) void __delayacct_freepages_start(void)
{ {
ktime_get_ts(&current->delays->freepages_start); current->delays->freepages_start = ktime_get_ns();
} }
void __delayacct_freepages_end(void) void __delayacct_freepages_end(void)
{ {
delayacct_end(&current->delays->freepages_start, delayacct_end(&current->delays->freepages_start,
&current->delays->freepages_end,
&current->delays->freepages_delay, &current->delays->freepages_delay,
&current->delays->freepages_count); &current->delays->freepages_count);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment