This is a tradeoff. If the total running time is "short", use (1) for
performance.
If the running time is "long" use (2) to avoid lock contention.
"long" time happens when the time wasted by other processors spinning
typically exceed the time wasted by repeated lock+unlock, or there
is excessive latency on some irq-blocking lock.
You can get the best of both worlds (low latency and few lock operations)
like this:
while(more work to do) {
spin_lock(&lock);
process one suitably sized batch of items
spin_unlock(&lock);
}
This sort of thing certainly helped the VM system.
Helge Hafting
-
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/