Skip to content

Commit e4042ad

Browse files
author
Peter Zijlstra
committed
delayacct: Default disabled
Assuming this stuff isn't actually used much; disable it by default and avoid allocating and tracking the task_delay_info structure. taskstats is changed to still report the regular sched and sched_info and only skip the missing task_delay_info fields instead of not reporting anything. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Thomas Gleixner <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent eee4d9f commit e4042ad

File tree

4 files changed

+20
-25
lines changed

4 files changed

+20
-25
lines changed

Documentation/accounting/delay-accounting.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ Compile the kernel with::
6969
CONFIG_TASK_DELAY_ACCT=y
7070
CONFIG_TASKSTATS=y
7171

72-
Delay accounting is enabled by default at boot up.
73-
To disable, add::
72+
Delay accounting is disabled by default at boot up.
73+
To enable, add::
7474

75-
nodelayacct
75+
delayacct
7676

7777
to the kernel boot options. The rest of the instructions
78-
below assume this has not been done.
78+
below assume this has been done.
7979

8080
After the system has booted up, use a utility
8181
similar to getdelays.c to access the delays

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3244,7 +3244,7 @@
32443244

32453245
noclflush [BUGS=X86] Don't use the CLFLUSH instruction
32463246

3247-
nodelayacct [KNL] Disable per-task delay accounting
3247+
delayacct [KNL] Enable per-task delay accounting
32483248

32493249
nodsp [SH] Disable hardware DSP at boot time.
32503250

include/linux/delayacct.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ struct task_delay_info {
6161
#include <linux/jump_label.h>
6262

6363
#ifdef CONFIG_TASK_DELAY_ACCT
64-
DECLARE_STATIC_KEY_TRUE(delayacct_key);
64+
DECLARE_STATIC_KEY_FALSE(delayacct_key);
6565
extern int delayacct_on; /* Delay accounting turned on/off */
6666
extern struct kmem_cache *delayacct_cache;
6767
extern void delayacct_init(void);
6868
extern void __delayacct_tsk_init(struct task_struct *);
6969
extern void __delayacct_tsk_exit(struct task_struct *);
7070
extern void __delayacct_blkio_start(void);
7171
extern void __delayacct_blkio_end(struct task_struct *);
72-
extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
72+
extern int delayacct_add_tsk(struct taskstats *, struct task_struct *);
7373
extern __u64 __delayacct_blkio_ticks(struct task_struct *);
7474
extern void __delayacct_freepages_start(void);
7575
extern void __delayacct_freepages_end(void);
@@ -116,7 +116,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk)
116116

117117
static inline void delayacct_blkio_start(void)
118118
{
119-
if (!static_branch_likely(&delayacct_key))
119+
if (!static_branch_unlikely(&delayacct_key))
120120
return;
121121

122122
delayacct_set_flag(current, DELAYACCT_PF_BLKIO);
@@ -126,22 +126,14 @@ static inline void delayacct_blkio_start(void)
126126

127127
static inline void delayacct_blkio_end(struct task_struct *p)
128128
{
129-
if (!static_branch_likely(&delayacct_key))
129+
if (!static_branch_unlikely(&delayacct_key))
130130
return;
131131

132132
if (p->delays)
133133
__delayacct_blkio_end(p);
134134
delayacct_clear_flag(p, DELAYACCT_PF_BLKIO);
135135
}
136136

137-
static inline int delayacct_add_tsk(struct taskstats *d,
138-
struct task_struct *tsk)
139-
{
140-
if (!delayacct_on || !tsk->delays)
141-
return 0;
142-
return __delayacct_add_tsk(d, tsk);
143-
}
144-
145137
static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
146138
{
147139
if (tsk->delays)

kernel/delayacct.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
#include <linux/delayacct.h>
1515
#include <linux/module.h>
1616

17-
DEFINE_STATIC_KEY_TRUE(delayacct_key);
18-
int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */
17+
DEFINE_STATIC_KEY_FALSE(delayacct_key);
18+
int delayacct_on __read_mostly; /* Delay accounting turned on/off */
1919
struct kmem_cache *delayacct_cache;
2020

21-
static int __init delayacct_setup_disable(char *str)
21+
static int __init delayacct_setup_enable(char *str)
2222
{
23-
delayacct_on = 0;
23+
delayacct_on = 1;
2424
return 1;
2525
}
26-
__setup("nodelayacct", delayacct_setup_disable);
26+
__setup("delayacct", delayacct_setup_enable);
2727

2828
void delayacct_init(void)
2929
{
3030
delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC|SLAB_ACCOUNT);
3131
delayacct_tsk_init(&init_task);
32-
if (!delayacct_on)
33-
static_branch_disable(&delayacct_key);
32+
if (delayacct_on)
33+
static_branch_enable(&delayacct_key);
3434
}
3535

3636
void __delayacct_tsk_init(struct task_struct *tsk)
@@ -83,7 +83,7 @@ void __delayacct_blkio_end(struct task_struct *p)
8383
delayacct_end(&delays->lock, &delays->blkio_start, total, count);
8484
}
8585

86-
int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
86+
int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
8787
{
8888
u64 utime, stime, stimescaled, utimescaled;
8989
unsigned long long t2, t3;
@@ -118,6 +118,9 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
118118
d->cpu_run_virtual_total =
119119
(tmp < (s64)d->cpu_run_virtual_total) ? 0 : tmp;
120120

121+
if (!tsk->delays)
122+
return 0;
123+
121124
/* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */
122125

123126
raw_spin_lock_irqsave(&tsk->delays->lock, flags);

0 commit comments

Comments
 (0)