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]
Date:   Wed, 9 Feb 2022 18:13:07 +0300
From:   stsp <stsp2@...dex.ru>
To:     Linux kernel <linux-kernel@...r.kernel.org>
Subject: Q: is spin_lock() good outside of irq handler?

Hi kernel developers!

Just a quick question.
Kernel doc says this:
https://www.kernel.org/doc/Documentation/locking/spinlocks.txt
---

IFF you know that the spinlocks are
never used in interrupt handlers, you can use the non-irq versions:

     spin_lock(&lock);
     ...
     spin_unlock(&lock);

(and the equivalent read-write versions too, of course). The spinlock will
guarantee the same kind of exclusive access, and it will be much faster.

---

But in this case the interrupt is possible
inside the locked section, which can make
that section much longer than expected,
and will make other CPU cores to spin longer
while waiting for that lock.

So my question is: is spin_lock() actually
preferred to spin_lock_irq() when it is known
that the inthandler doesn't get the same lock?
Or maybe I should still use spin_lock_irq()
just to make sure my critical section doesn't
get an interrupt, causing other cores to spin
longer?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ