Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: locking: Discourage from calling disable_irq() in atomic

Correct the example in the documentation so that disable_irq() is not being
called in atomic context.

disable_irq() calls sleeping synchronize_irq(), it's not allowed to call
them in atomic context.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@siemens.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Manfred Spraul <manfred@colorfullife.com>
Cc: linux-doc@vger.kernel.org
Link: https://lore.kernel.org/lkml/87k02wbs2n.ffs@tglx/
Link: https://lore.kernel.org/r/20221212163715.830315-1-alexander.sverdlin@siemens.com

authored by

Alexander Sverdlin and committed by
Thomas Gleixner
379af13b 17549b0f

+4 -4
+2 -2
Documentation/kernel-hacking/locking.rst
··· 1277 1277 is very occasionally accessed in user context or softirqs/tasklets. The 1278 1278 irq handler doesn't use a lock, and all other accesses are done as so:: 1279 1279 1280 - spin_lock(&lock); 1280 + mutex_lock(&lock); 1281 1281 disable_irq(irq); 1282 1282 ... 1283 1283 enable_irq(irq); 1284 - spin_unlock(&lock); 1284 + mutex_unlock(&lock); 1285 1285 1286 1286 The disable_irq() prevents the irq handler from running 1287 1287 (and waits for it to finish if it's currently running on other CPUs).
+2 -2
Documentation/translations/it_IT/kernel-hacking/locking.rst
··· 1307 1307 da un'interruzione software. Il gestore d'interruzione non utilizza alcun 1308 1308 *lock*, e tutti gli altri accessi verranno fatti così:: 1309 1309 1310 - spin_lock(&lock); 1310 + mutex_lock(&lock); 1311 1311 disable_irq(irq); 1312 1312 ... 1313 1313 enable_irq(irq); 1314 - spin_unlock(&lock); 1314 + mutex_unlock(&lock); 1315 1315 1316 1316 La funzione disable_irq() impedisce al gestore d'interruzioni 1317 1317 d'essere eseguito (e aspetta che finisca nel caso fosse in esecuzione su