Locking question (was: [CHECKER] 9 potential copy_*_user bugs in 2.4.1)

From: Nigel Gamble (nigel@nrg.org)
Date: Fri Mar 16 2001 - 15:56:26 EST


On Thu, 15 Mar 2001, Dawson Engler wrote:
> 2. And, unrelated: given the current locking discipline, is
> it bad to hold any type of lock (not just a spin lock) when you
> call a potentially blocking function? (It at least seems bad
> for performance, since you'll hold the lock for milliseconds.)

In general, yes. The lock may be held for much longer than milliseconds
if the potentially blocking function is waiting for I/O from a network,
or a terminal, potentially causing all threads to block on the lock
until someone presses a key, in this extreme example. If the lock is a
spinlock, then complete deadlock can occur.

You're probably aware that semaphores are used both as blocking mutex
locks, where the down (lock) and up (unlock) calls are made by the same
thread to protect critical data, and as a synchronization mechanism,
where the down and up calls are made by different threads. The former
use is a "lock", while the latter down() use is a "potentially blocking
function" in terms of your question. I don't know how easy it would be
for your analysis tools to distinguish between them.

Nigel Gamble nigel@nrg.org
Mountain View, CA, USA. http://www.nrg.org/

MontaVista Software nigel@mvista.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 23 2001 - 21:00:09 EST