Pass the task_struct explicitly to delayacct_blkio_end
Subsystems (4)
PATCH 1/1 Pass the task_struct explicitly to delayacct_blkio_end
Before e33a9bba85a8, 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 upon 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_struct.
--- include/linux/delayacct.h | 8 ++++---- kernel/delayacct.c | 42 ++++++++++++++++++++++++++---------------- kernel/sched/core.c | 6 +++--- 3 files changed, 33 insertions(+), 23 deletions(-)
include/linux/delayacct.h +4 -4
@@ -71,7 +71,7 @@ extern void delayacct_init(void);extern void __delayacct_tsk_init (struct task_struct *);extern void __delayacct_tsk_exit (struct task_struct *);extern void __delayacct_blkio_start (void ); -extern void __delayacct_blkio_end (void ); +extern void __delayacct_blkio_end (struct task_struct *);extern int __delayacct_add_tsk (struct taskstats *,struct task_struct *);extern __u64 __delayacct_blkio_ticks (struct task_struct *);extern void __delayacct_freepages_start (void );
@@ -122,10 +122,10 @@ static inline void delayacct_blkio_start(void)__delayacct_blkio_start (); } -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {if (current->delays) -__delayacct_blkio_end (); +__delayacct_blkio_end (p);delayacct_clear_flag (DELAYACCT_PF_BLKIO ); }
@@ -169,7 +169,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk) {}static inline void delayacct_blkio_start (void ) {} -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {}static inline int delayacct_add_tsk (struct taskstats *d,struct task_struct *tsk)
kernel/delayacct.c +26 -16
67 lines not on this page · raw message
kernel/sched/core.c +3 -3
@@ -2056,7 +2056,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) p->state =TASK_WAKING ;if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2069,7 +2069,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)#else /* CONFIG_SMP */ if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2122,7 +2122,7 @@ static void try_to_wake_up_local(struct task_struct *p, struct rq_flags *rf)if (!task_on_rq_queued (p)) {if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&rq->nr_iowait); }ttwu_activate (rq, p,ENQUEUE_WAKEUP |ENQUEUE_NOCLOCK );
Signature · 1 line
2.7.4
Peter Zijlstra
maintainerQuoted 1 line · Josh Snyder
Subject: [PATCH] Pass the
task_structexplicitly todelayacct_blkio_end
That subject is crap; it needs a subsystem prefix and it needs to describe what is done, not how its done.
Something like:
delayacct: Fix double accounting for blk-io
Quoted 11 lines
Before
e33a9bba85a8,delayacct_blkio_endwas 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_endis called bytry_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. Butdelayacct_blkio_endrelies uponget_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.
The correct way to quote a commit is like:
e33a9bba85a8 ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler")
Quoted 3 lines
Instead of doing that, pass the
task_structbeing woken todelayacct_blkio_end, so that it can update the statistics of the correcttask_struct.
PATCH v2 1/1 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 upon 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.
--- include/linux/delayacct.h | 8 ++++---- kernel/delayacct.c | 42 ++++++++++++++++++++++++++---------------- kernel/sched/core.c | 6 +++--- 3 files changed, 33 insertions(+), 23 deletions(-)
include/linux/delayacct.h +4 -4
@@ -71,7 +71,7 @@ extern void delayacct_init(void);extern void __delayacct_tsk_init (struct task_struct *);extern void __delayacct_tsk_exit (struct task_struct *);extern void __delayacct_blkio_start (void ); -extern void __delayacct_blkio_end (void ); +extern void __delayacct_blkio_end (struct task_struct *);extern int __delayacct_add_tsk (struct taskstats *,struct task_struct *);extern __u64 __delayacct_blkio_ticks (struct task_struct *);extern void __delayacct_freepages_start (void );
@@ -122,10 +122,10 @@ static inline void delayacct_blkio_start(void)__delayacct_blkio_start (); } -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {if (current->delays) -__delayacct_blkio_end (); +__delayacct_blkio_end (p);delayacct_clear_flag (DELAYACCT_PF_BLKIO ); }
@@ -169,7 +169,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk) {}static inline void delayacct_blkio_start (void ) {} -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {}static inline int delayacct_add_tsk (struct taskstats *d,struct task_struct *tsk)
kernel/delayacct.c +26 -16
67 lines not on this page · raw message
kernel/sched/core.c +3 -3
@@ -2056,7 +2056,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) p->state =TASK_WAKING ;if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2069,7 +2069,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)#else /* CONFIG_SMP */ if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2122,7 +2122,7 @@ static void try_to_wake_up_local(struct task_struct *p, struct rq_flags *rf)if (!task_on_rq_queued (p)) {if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&rq->nr_iowait); }ttwu_activate (rq, p,ENQUEUE_WAKEUP |ENQUEUE_NOCLOCK );
Signature · 1 line
2.7.4
Re: [PATCH v2] delayacct: Account blkio completion on the correct task
Hello,
Quoted 13 lines · Josh Snyder
Before commit
e33a9bba85a8("sched/core: move IO scheduling accounting fromio_schedule_timeout()into scheduler"),delayacct_blkio_endwas 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_endis called bytry_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. Butdelayacct_blkio_endrelies uponget_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.
Quoted 6 lines
Instead of doing that, pass the
task_structbeing woken todelayacct_blkio_end, so that it can update the statistics of the correct task.Fixes e33a9bba85a8 ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler")Signed-off-by Josh Snyder <[email protected]>
Thanks.
Signature · 1 line
tejun
Re: [PATCH v2] delayacct: Account blkio completion on the correct task
In reply to Josh SnyderQuoted 6 lines · Josh Snyder
Before commit
e33a9bba85a8("sched/core: move IO scheduling accounting fromio_schedule_timeout()into scheduler"),delayacct_blkio_endwas 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.
Yes, we included the time spent in the runqueue to delays on account of I/O.
Quoted 7 lines
With
e33a9bba85a8,delayacct_blkio_endis called bytry_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. Butdelayacct_blkio_endrelies uponget_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.
Quoted 7 lines
Instead of doing that, pass the
task_structbeing woken todelayacct_blkio_end, so that it can update the statistics of the correct task.Fixes e33a9bba85a8 ("sched/core: move IO scheduling accounting from io_schedule_timeout() into scheduler")Signed-off-by Josh Snyder <[email protected]>---
tip-bot for Josh Snyder
merge bot[tip:sched/urgent] delayacct: Account blkio completion on the correct task
In reply to Josh Snyderdelayacct: Account blkio completion on the correct task
Commit-ID: c96f5471ce7d2aefd0dda560cc23f08ab00bc65d Gitweb: https://git.kernel.org/tip/c96f5471ce7d2aefd0dda560cc23f08ab00bc65d Author: Josh Snyder <[email protected]> AuthorDate: Mon, 18 Dec 2017 16:15:10 +0000 Committer: Ingo Molnar <[email protected]> CommitDate: Tue, 16 Jan 2018 03:29:36 +0100
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.
--- include/linux/delayacct.h | 8 ++++---- kernel/delayacct.c | 42 ++++++++++++++++++++++++++---------------- kernel/sched/core.c | 6 +++--- 3 files changed, 33 insertions(+), 23 deletions(-)
include/linux/delayacct.h +4 -4
@@ -71,7 +71,7 @@ extern void delayacct_init(void);extern void __delayacct_tsk_init (struct task_struct *);extern void __delayacct_tsk_exit (struct task_struct *);extern void __delayacct_blkio_start (void ); -extern void __delayacct_blkio_end (void ); +extern void __delayacct_blkio_end (struct task_struct *);extern int __delayacct_add_tsk (struct taskstats *,struct task_struct *);extern __u64 __delayacct_blkio_ticks (struct task_struct *);extern void __delayacct_freepages_start (void );
@@ -122,10 +122,10 @@ static inline void delayacct_blkio_start(void)__delayacct_blkio_start (); } -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {if (current->delays) -__delayacct_blkio_end (); +__delayacct_blkio_end (p);delayacct_clear_flag (DELAYACCT_PF_BLKIO ); }
@@ -169,7 +169,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk) {}static inline void delayacct_blkio_start (void ) {} -static inline void delayacct_blkio_end (void ) +static inline void delayacct_blkio_end (struct task_struct *p) {}static inline int delayacct_add_tsk (struct taskstats *d,struct task_struct *tsk)
kernel/delayacct.c +26 -16
67 lines not on this page · raw message
kernel/sched/core.c +3 -3
@@ -2056,7 +2056,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags) p->state =TASK_WAKING ;if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2069,7 +2069,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)#else /* CONFIG_SMP */ if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&task_rq (p)->nr_iowait); }
@@ -2122,7 +2122,7 @@ static void try_to_wake_up_local(struct task_struct *p, struct rq_flags *rf)if (!task_on_rq_queued (p)) {if (p->in_iowait) { -delayacct_blkio_end (); +delayacct_blkio_end (p);atomic_dec (&rq->nr_iowait); }ttwu_activate (rq, p,ENQUEUE_WAKEUP |ENQUEUE_NOCLOCK );