Skip to content

Commit 82065b7

Browse files
yangyang20220519torvalds
authored andcommitted
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.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>
1 parent a3d5dc9 commit 82065b7

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

include/linux/delayacct.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,36 +131,54 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
131131

132132
static inline void delayacct_freepages_start(void)
133133
{
134+
if (!static_branch_unlikely(&delayacct_key))
135+
return;
136+
134137
if (current->delays)
135138
__delayacct_freepages_start();
136139
}
137140

138141
static inline void delayacct_freepages_end(void)
139142
{
143+
if (!static_branch_unlikely(&delayacct_key))
144+
return;
145+
140146
if (current->delays)
141147
__delayacct_freepages_end();
142148
}
143149

144150
static inline void delayacct_thrashing_start(void)
145151
{
152+
if (!static_branch_unlikely(&delayacct_key))
153+
return;
154+
146155
if (current->delays)
147156
__delayacct_thrashing_start();
148157
}
149158

150159
static inline void delayacct_thrashing_end(void)
151160
{
161+
if (!static_branch_unlikely(&delayacct_key))
162+
return;
163+
152164
if (current->delays)
153165
__delayacct_thrashing_end();
154166
}
155167

156168
static inline void delayacct_swapin_start(void)
157169
{
170+
if (!static_branch_unlikely(&delayacct_key))
171+
return;
172+
158173
if (current->delays)
159174
__delayacct_swapin_start();
160175
}
161176

162177
static inline void delayacct_swapin_end(void)
163178
{
179+
if (!static_branch_unlikely(&delayacct_key))
180+
return;
181+
164182
if (current->delays)
165183
__delayacct_swapin_end();
166184
}

0 commit comments

Comments
 (0)