[PATCH] delayacct: optimize delayacct init
From: cgel . zte
Date: Sat Sep 11 2021 - 03:41:55 EST
From: Yang Yang <yang.yang29@xxxxxxxxxx>
In delayacct_init(), first there is no need to assign delayacct_on to
delayacct_on in set_delayacct(). Second if delayacct_on is 0, there
is no need call delayacct_tsk_init().
Signed-off-by: Yang Yang <yang.yang29@xxxxxxxxxx>
---
kernel/delayacct.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 51530d5b15a8..cbf80273be6d 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -39,8 +39,13 @@ __setup("delayacct", delayacct_setup_enable);
void delayacct_init(void)
{
delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC|SLAB_ACCOUNT);
+
+ if (delayacct_on)
+ static_branch_enable(&delayacct_key);
+ else
+ return;
+
delayacct_tsk_init(&init_task);
- set_delayacct(delayacct_on);
}
#ifdef CONFIG_PROC_SYSCTL
--
2.25.1