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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240821230539.168107-3-woodyzhang666@gmail.com>
Date: Thu, 22 Aug 2024 07:05:36 +0800
From: Woody Zhang <woodyzhang666@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>,
	Andrew Morton <akpm@...ux-foundation.org>
Cc: linux-kernel@...r.kernel.org,
	Woody Zhang <woodyzhang666@...il.com>
Subject: [PATCH 2/5] list_bl: add irq variant for hlist_bl lock API

This variant makes it easy to be used to protect hash list that can
be accessed from irq context.

Signed-off-by: Woody Zhang <woodyzhang666@...il.com>
---
 include/linux/list_bl.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/linux/list_bl.h b/include/linux/list_bl.h
index ae1b541446c9..7ce411567fe5 100644
--- a/include/linux/list_bl.h
+++ b/include/linux/list_bl.h
@@ -153,6 +153,27 @@ static inline void hlist_bl_unlock(struct hlist_bl_head *b)
 	__bit_spin_unlock(0, (unsigned long *)b);
 }
 
+#define hlist_bl_lock_irqsave(b, flags)				\
+do {								\
+	typecheck(struct hlist_bl_head*, b);			\
+	typecheck(unsigned long, flags);			\
+	bit_spin_lock_irqsave(0, (unsigned long *)b, flags);	\
+} while (0)
+
+#define hlist_bl_trylock_irqsave(b, flags)			\
+({								\
+	typecheck(struct hlist_bl_head*, b);			\
+	typecheck(unsigned long, flags);			\
+	bit_spin_trylock_irqsave(0, (unsigned long *)b, flags);	\
+})
+
+static inline void hlist_bl_unlock_irqrestore(struct hlist_bl_head *b,
+					unsigned long flags)
+{
+	__bit_spin_unlock_irqrestore(0, (unsigned long *)b, flags);
+}
+
+
 static inline bool hlist_bl_is_locked(struct hlist_bl_head *b)
 {
 	return bit_spin_is_locked(0, (unsigned long *)b);
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ