aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/sched.h4
-rw-r--r--kernel/delayacct.c34
2 files changed, 14 insertions, 24 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 10c6e829927f..653744ae8d27 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -813,7 +813,7 @@ struct task_delay_info {
813 * associated with the operation is added to XXX_delay. 813 * associated with the operation is added to XXX_delay.
814 * XXX_delay contains the accumulated delay time in nanoseconds. 814 * XXX_delay contains the accumulated delay time in nanoseconds.
815 */ 815 */
816 struct timespec blkio_start, blkio_end; /* Shared by blkio, swapin */ 816 u64 blkio_start; /* Shared by blkio, swapin */
817 u64 blkio_delay; /* wait for sync block io completion */ 817 u64 blkio_delay; /* wait for sync block io completion */
818 u64 swapin_delay; /* wait for swapin block io completion */ 818 u64 swapin_delay; /* wait for swapin block io completion */
819 u32 blkio_count; /* total count of the number of sync block */ 819 u32 blkio_count; /* total count of the number of sync block */
@@ -821,7 +821,7 @@ struct task_delay_info {
821 u32 swapin_count; /* total count of the number of swapin block */ 821 u32 swapin_count; /* total count of the number of swapin block */
822 /* io operations performed */ 822 /* io operations performed */
823 823
824 struct timespec freepages_start, freepages_end; 824 u64 freepages_start;
825 u64 freepages_delay; /* wait for memory reclaim */ 825 u64 freepages_delay; /* wait for memory reclaim */
826 u32 freepages_count; /* total count of memory reclaim */ 826 u32 freepages_count; /* total count of memory reclaim */
827}; 827};
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}