Skip to content

Commit

Permalink
delayacct: fix incomplete disable operation when switch enable to dis…
Browse files Browse the repository at this point in the history
…able

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.cn
Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Reported-by: Zeal 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
yangyang20220519 authored and torvalds committed Jan 20, 2022
1 parent a3d5dc9 commit 82065b7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions include/linux/delayacct.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,36 +131,54 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)

static inline void delayacct_freepages_start(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_freepages_start();
}

static inline void delayacct_freepages_end(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_freepages_end();
}

static inline void delayacct_thrashing_start(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_thrashing_start();
}

static inline void delayacct_thrashing_end(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_thrashing_end();
}

static inline void delayacct_swapin_start(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_swapin_start();
}

static inline void delayacct_swapin_end(void)
{
if (!static_branch_unlikely(&delayacct_key))
return;

if (current->delays)
__delayacct_swapin_end();
}
Expand Down

0 comments on commit 82065b7

Please sign in to comment.