|
@@ -51,16 +51,16 @@ void __delayacct_tsk_init(struct task_struct *tsk)
|
|
|
* Finish delay accounting for a statistic using its timestamps (@start),
|
|
|
* accumalator (@total) and @count
|
|
|
*/
|
|
|
-static void delayacct_end(u64 *start, u64 *total, u32 *count)
|
|
|
+static void delayacct_end(spinlock_t *lock, u64 *start, u64 *total, u32 *count)
|
|
|
{
|
|
|
s64 ns = ktime_get_ns() - *start;
|
|
|
unsigned long flags;
|
|
|
|
|
|
if (ns > 0) {
|
|
|
- spin_lock_irqsave(¤t->delays->lock, flags);
|
|
|
+ spin_lock_irqsave(lock, flags);
|
|
|
*total += ns;
|
|
|
(*count)++;
|
|
|
- spin_unlock_irqrestore(¤t->delays->lock, flags);
|
|
|
+ spin_unlock_irqrestore(lock, flags);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -69,17 +69,25 @@ void __delayacct_blkio_start(void)
|
|
|
current->delays->blkio_start = ktime_get_ns();
|
|
|
}
|
|
|
|
|
|
-void __delayacct_blkio_end(void)
|
|
|
+/*
|
|
|
+ * We cannot rely on the `current` macro, as we haven't yet switched back to
|
|
|
+ * the process being woken.
|
|
|
+ */
|
|
|
+void __delayacct_blkio_end(struct task_struct *p)
|
|
|
{
|
|
|
- if (current->delays->flags & DELAYACCT_PF_SWAPIN)
|
|
|
- /* Swapin block I/O */
|
|
|
- delayacct_end(¤t->delays->blkio_start,
|
|
|
- ¤t->delays->swapin_delay,
|
|
|
- ¤t->delays->swapin_count);
|
|
|
- else /* Other block I/O */
|
|
|
- delayacct_end(¤t->delays->blkio_start,
|
|
|
- ¤t->delays->blkio_delay,
|
|
|
- ¤t->delays->blkio_count);
|
|
|
+ struct task_delay_info *delays = p->delays;
|
|
|
+ u64 *total;
|
|
|
+ u32 *count;
|
|
|
+
|
|
|
+ if (p->delays->flags & DELAYACCT_PF_SWAPIN) {
|
|
|
+ total = &delays->swapin_delay;
|
|
|
+ count = &delays->swapin_count;
|
|
|
+ } else {
|
|
|
+ total = &delays->blkio_delay;
|
|
|
+ count = &delays->blkio_count;
|
|
|
+ }
|
|
|
+
|
|
|
+ delayacct_end(&delays->lock, &delays->blkio_start, total, count);
|
|
|
}
|
|
|
|
|
|
int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
|
|
@@ -153,8 +161,10 @@ void __delayacct_freepages_start(void)
|
|
|
|
|
|
void __delayacct_freepages_end(void)
|
|
|
{
|
|
|
- delayacct_end(¤t->delays->freepages_start,
|
|
|
- ¤t->delays->freepages_delay,
|
|
|
- ¤t->delays->freepages_count);
|
|
|
+ delayacct_end(
|
|
|
+ ¤t->delays->lock,
|
|
|
+ ¤t->delays->freepages_start,
|
|
|
+ ¤t->delays->freepages_delay,
|
|
|
+ ¤t->delays->freepages_count);
|
|
|
}
|
|
|
|