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: <20240620175703.605111-35-yury.norov@gmail.com>
Date: Thu, 20 Jun 2024 10:56:57 -0700
From: Yury Norov <yury.norov@...il.com>
To: linux-kernel@...r.kernel.org,
	Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
	Yury Norov <yury.norov@...il.com>,
	Florian Fainelli <f.fainelli@...il.com>,
	linux-mips@...r.kernel.org
Cc: Alexey Klimov <alexey.klimov@...aro.org>,
	Bart Van Assche <bvanassche@....org>,
	Jan Kara <jack@...e.cz>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Matthew Wilcox <willy@...radead.org>,
	Mirsad Todorovac <mirsad.todorovac@....unizg.hr>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Sergey Shtylyov <s.shtylyov@....ru>
Subject: [PATCH v4 34/40] MIPS: sgi-ip27: optimize alloc_level()

Simplify alloc_level by using a dedicated atomic find() API, and make
it a nice one-liner wrappers.

Signed-off-by: Yury Norov <yury.norov@...il.com>
---
 arch/mips/sgi-ip27/ip27-irq.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 00e63e9ef61d..fc29252860a3 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -13,6 +13,7 @@
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/bitops.h>
+#include <linux/find_atomic.h>
 #include <linux/sched.h>
 
 #include <asm/io.h>
@@ -36,17 +37,9 @@ static DEFINE_PER_CPU(unsigned long [2], irq_enable_mask);
 
 static inline int alloc_level(void)
 {
-	int level;
+	int level = find_and_set_bit(hub_irq_map, IP27_HUB_IRQ_COUNT);
 
-again:
-	level = find_first_zero_bit(hub_irq_map, IP27_HUB_IRQ_COUNT);
-	if (level >= IP27_HUB_IRQ_COUNT)
-		return -ENOSPC;
-
-	if (test_and_set_bit(level, hub_irq_map))
-		goto again;
-
-	return level;
+	return level < IP27_HUB_IRQ_COUNT ? level : -ENOSPC;
 }
 
 static void enable_hub_irq(struct irq_data *d)
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ