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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210430122521.13957-1-cainiao666999@gmail.com>
Date:   Fri, 30 Apr 2021 20:25:21 +0800
From:   Mingzhe Yang <cainiao666999@...il.com>
To:     tglx@...utronix.de, peterz@...radead.org
Cc:     linux-kernel@...r.kernel.org, yuxin.wooo@...il.com,
        becausehan@...il.com, huan.xie@...e.com,
        Mingzhe Yang <cainiao666999@...il.com>
Subject: [PATCH] tasklets: simplify code in tasklet_action_common()

Use tasklet_is_disabled() to simplify the code in tasklet_action_common.

Signed-off-by: Mingzhe Yang <cainiao666999@...il.com>
---
 include/linux/interrupt.h | 11 +++++++++++
 kernel/softirq.c          | 14 +++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 4777850..b0fba4d 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -721,6 +721,17 @@ static inline void tasklet_enable(struct tasklet_struct *t)
 	atomic_dec(&t->count);
 }
 
+static inline bool tasklet_is_enabled(struct tasklet_struct *t)
+{
+	smp_rmb();
+	return !atomic_read(&t->count);
+}
+
+static inline bool tasklet_is_disabled(struct tasklet_struct *t)
+{
+	return !tasklet_is_enabled(t);
+}
+
 extern void tasklet_kill(struct tasklet_struct *t);
 extern void tasklet_init(struct tasklet_struct *t,
 			 void (*func)(unsigned long), unsigned long data);
diff --git a/kernel/softirq.c b/kernel/softirq.c
index 4992853..ee36b15 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -778,16 +778,16 @@ static void tasklet_action_common(struct softirq_action *a,
 		list = list->next;
 
 		if (tasklet_trylock(t)) {
-			if (!atomic_read(&t->count)) {
-				if (tasklet_clear_sched(t)) {
-					if (t->use_callback)
-						t->callback(t);
-					else
-						t->func(t->data);
-				}
+			if (tasklet_is_disabled(t) || !tasklet_clear_sched(t)) {
 				tasklet_unlock(t);
 				continue;
 			}
+
+			if (t->use_callback)
+				t->callback(t);
+			else
+				t->func(t->data);
+
 			tasklet_unlock(t);
 		}
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ