[PATCH 3/3] delayacct: remove delayacct_on to simplify the code
From: brookxu.cn
Date: Sun Oct 08 2023 - 06:50:00 EST
From: Chunguang Xu <chunguang.xu@xxxxxxxxxx>
Seems delayacct_on can be removed, so try to do it
to simplify the code.
Signed-off-by: Chunguang Xu <chunguang.xu@xxxxxxxxxx>
---
include/linux/delayacct.h | 1 -
kernel/delayacct.c | 14 ++++----------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 2f1dc6688a2f..caa7564a1a52 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -64,7 +64,6 @@ struct task_delay_info {
#ifdef CONFIG_TASK_DELAY_ACCT
DECLARE_STATIC_KEY_FALSE(delayacct_key);
-extern int delayacct_on; /* Delay accounting turned on/off */
extern void delayacct_init(void);
extern void __delayacct_tsk_init(struct task_struct *);
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 1a6b1d3e80af..397b36adb634 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -15,22 +15,18 @@
#include <linux/module.h>
DEFINE_STATIC_KEY_FALSE(delayacct_key);
-int delayacct_on __read_mostly; /* Delay accounting turned on/off */
static void set_delayacct(bool enabled)
{
- if (enabled) {
+ if (enabled)
static_branch_enable(&delayacct_key);
- delayacct_on = 1;
- } else {
- delayacct_on = 0;
+ else
static_branch_disable(&delayacct_key);
- }
}
static int __init delayacct_setup_enable(char *str)
{
- delayacct_on = 1;
+ set_delayacct(true);
return 1;
}
__setup("delayacct", delayacct_setup_enable);
@@ -38,16 +34,14 @@ __setup("delayacct", delayacct_setup_enable);
void delayacct_init(void)
{
delayacct_tsk_init(&init_task);
- set_delayacct(delayacct_on);
}
#ifdef CONFIG_PROC_SYSCTL
static int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
- int state = delayacct_on;
struct ctl_table t;
- int err;
+ int err, state;
if (write && !capable(CAP_SYS_ADMIN))
return -EPERM;
--
2.25.1