lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211007030947.460480-1-yang.yang29@zte.com.cn>
Date:   Thu,  7 Oct 2021 03:09:48 +0000
From:   cgel.zte@...il.com
To:     bsingharora@...il.com, john.stultz@...aro.org, tglx@...utronix.de,
        peterz@...radead.org
Cc:     linux-kernel@...r.kernel.org, Yang Yang <yang.yang29@....com.cn>
Subject: [PATCH] delayacct: make delayacct init more efficient

From: Yang Yang <yang.yang29@....com.cn>

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@....com.cn>
---
 kernel/delayacct.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 51530d5b15a8..1135a551edd1 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -18,17 +18,6 @@ DEFINE_STATIC_KEY_FALSE(delayacct_key);
 int delayacct_on __read_mostly;	/* Delay accounting turned on/off */
 struct kmem_cache *delayacct_cache;
 
-static void set_delayacct(bool enabled)
-{
-	if (enabled) {
-		static_branch_enable(&delayacct_key);
-		delayacct_on = 1;
-	} else {
-		delayacct_on = 0;
-		static_branch_disable(&delayacct_key);
-	}
-}
-
 static int __init delayacct_setup_enable(char *str)
 {
 	delayacct_on = 1;
@@ -39,11 +28,26 @@ __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
+static void set_delayacct(bool enabled)
+{
+	if (enabled) {
+		static_branch_enable(&delayacct_key);
+		delayacct_on = 1;
+	} else {
+		delayacct_on = 0;
+		static_branch_disable(&delayacct_key);
+	}
+}
+
 int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
 		     size_t *lenp, loff_t *ppos)
 {
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ