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: <20250321172024.3372381-1-eleanor15x@gmail.com>
Date: Sat, 22 Mar 2025 01:20:24 +0800
From: Yu-Chun Lin <eleanor15x@...il.com>
To: isdn@...ux-pingi.de,
	kuba@...nel.org
Cc: netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	jserv@...s.ncku.edu.tw,
	visitorckw@...il.com,
	Yu-Chun Lin <eleanor15x@...il.com>
Subject: [PATCH] mISDN: hfcsusb: Optimize performance by replacing rw_lock with spinlock

The 'HFClock', an rwlock, is only used by writers, making it functionally
equivalent to a spinlock.

According to Documentation/locking/spinlocks.rst:

"Reader-writer locks require more atomic memory operations than simple
spinlocks. Unless the reader critical section is long, you are better
off just using spinlocks."

Since read_lock() is never called, switching to a spinlock reduces
overhead and improves efficiency.

Signed-off-by: Yu-Chun Lin <eleanor15x@...il.com>
---
Build tested only, as I don't have the hardware. 
Ensured all rw_lock -> spinlock conversions are complete, and replacing
rw_lock with spinlock should always be safe.

 drivers/isdn/hardware/mISDN/hfcsusb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
index e54419a4e731..5041d635ef7f 100644
--- a/drivers/isdn/hardware/mISDN/hfcsusb.c
+++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
@@ -27,7 +27,7 @@ static unsigned int debug;
 static int poll = DEFAULT_TRANSP_BURST_SZ;
 
 static LIST_HEAD(HFClist);
-static DEFINE_RWLOCK(HFClock);
+static DEFINE_SPINLOCK(HFClock);
 
 
 MODULE_AUTHOR("Martin Bachem");
@@ -1895,9 +1895,9 @@ setup_instance(struct hfcsusb *hw, struct device *parent)
 		goto out;
 
 	hfcsusb_cnt++;
-	write_lock_irqsave(&HFClock, flags);
+	spin_lock_irqsave(&HFClock, flags);
 	list_add_tail(&hw->list, &HFClist);
-	write_unlock_irqrestore(&HFClock, flags);
+	spin_unlock_irqrestore(&HFClock, flags);
 	return 0;
 
 out:
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ