Commit 82065b72 authored by Yang Yang's avatar Yang Yang Committed by Linus Torvalds

delayacct: fix incomplete disable operation when switch enable to disable

When a task is created after delayacct is enabled, kernel will do all
the delay accountings for that task.  The problems is if user disables
delayacct by set /proc/sys/kernel/task_delayacct to zero, only blkio
delay accounting is disabled.

Now disable all the kinds of delay accountings when
/proc/sys/kernel/task_delayacct sets to zero.

Link: https://lkml.kernel.org/r/20211123140342.32962-1-ran.xiaokai@zte.com.cnSigned-off-by: default avatarYang Yang <yang.yang29@zte.com.cn>
Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a3d5dc90
...@@ -131,36 +131,54 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk) ...@@ -131,36 +131,54 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
static inline void delayacct_freepages_start(void) static inline void delayacct_freepages_start(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_freepages_start(); __delayacct_freepages_start();
} }
static inline void delayacct_freepages_end(void) static inline void delayacct_freepages_end(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_freepages_end(); __delayacct_freepages_end();
} }
static inline void delayacct_thrashing_start(void) static inline void delayacct_thrashing_start(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_thrashing_start(); __delayacct_thrashing_start();
} }
static inline void delayacct_thrashing_end(void) static inline void delayacct_thrashing_end(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_thrashing_end(); __delayacct_thrashing_end();
} }
static inline void delayacct_swapin_start(void) static inline void delayacct_swapin_start(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_swapin_start(); __delayacct_swapin_start();
} }
static inline void delayacct_swapin_end(void) static inline void delayacct_swapin_end(void)
{ {
if (!static_branch_unlikely(&delayacct_key))
return;
if (current->delays) if (current->delays)
__delayacct_swapin_end(); __delayacct_swapin_end();
} }
......
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