History

delayacct: Account blkio completion on the correct task

Before commit: e33a9bba85a8 ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler") delayacct_blkio_end() was called after context-switching into the task which completed I/O. This resulted in double counting: the task would account a delay both waiting for I/O and for time spent in the runqueue. With e33a9bba85a8, delayacct_blkio_end() is called by try_to_wake_up(). In ttwu, we have not yet context-switched. This is more correct, in that the delay accounting ends when the I/O is complete. But delayacct_blkio_end() relies on 'get_current()', and we have not yet context-switched into the task whose I/O completed. This results in the wrong task having its delay accounting statistics updated. Instead of doing that, pass the task_struct being woken to delayacct_blkio_end(), so that it can update the statistics of the correct task.

Josh Snyder committed 8 years ago

Commit c96f5471 parent a8750dd3 files · +33 −23Browse files

Showing the changes to include/linux (1 of 3 files). Show all

Unified · Split

include/linux/delayacct.h+4−4
@@ -71,7 +71,7 @@ extern void delayacct_init(void); · 70 unmodified lines
7171 extern void __delayacct_tsk_init(struct task_struct *);
7272 extern void __delayacct_tsk_exit(struct task_struct *);
7373 extern void __delayacct_blkio_start(void);
74−extern void __delayacct_blkio_end(void);
74+extern void __delayacct_blkio_end(struct task_struct *);
7575 extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
7676 extern __u64 __delayacct_blkio_ticks(struct task_struct *);
7777 extern void __delayacct_freepages_start(void);
@@ -122,10 +122,10 @@ static inline void delayacct_blkio_start(void) · 44 unmodified lines
122122 __delayacct_blkio_start();
123123 }
124124
125−static inline void delayacct_blkio_end(void)
125+static inline void delayacct_blkio_end(struct task_struct *p)
126126 {
127127 if (current->delays)
128− __delayacct_blkio_end();
128+ __delayacct_blkio_end(p);
129129 delayacct_clear_flag(DELAYACCT_PF_BLKIO);
130130 }
131131
@@ -169,7 +169,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk) · 37 unmodified lines
169169 {}
170170 static inline void delayacct_blkio_start(void)
171171 {}
172−static inline void delayacct_blkio_end(void)
172+static inline void delayacct_blkio_end(struct task_struct *p)
173173 {}
174174 static inline int delayacct_add_tsk(struct taskstats *d,
175175 struct task_struct *tsk)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t