[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <399a361ec136d972991fe84e9aad00e3c302f37a.1696761522.git.chunguang.xu@shopee.com>
Date: Sun, 8 Oct 2023 18:49:38 +0800
From: "brookxu.cn" <brookxu.cn@...il.com>
To: bsingharora@...il.com, juri.lelli@...hat.com, peterz@...radead.org,
vincent.guittot@...aro.org
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH 3/3] delayacct: remove delayacct_on to simplify the code
From: Chunguang Xu <chunguang.xu@...pee.com>
Seems delayacct_on can be removed, so try to do it
to simplify the code.
Signed-off-by: Chunguang Xu <chunguang.xu@...pee.com>
---
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
Powered by blists - more mailing lists