Re: AS spin lock bugs
From: Nick Piggin
Date:  Thu Nov 13 2003 - 06:18:29 EST
Jens Axboe wrote:
On Thu, Nov 13 2003, Jens Axboe wrote:
On Thu, Nov 13 2003, Nick Piggin wrote:
Jens Axboe wrote:
On Thu, Nov 13 2003, Jens Axboe wrote:
@@ -959,12 +960,12 @@
	if (!aic)
		return;
-	spin_lock(&aic->lock);
+	spin_lock_irqsave(&aic->lock, flags);
	if (arq->is_sync == REQ_SYNC) {
		set_bit(AS_TASK_IORUNNING, &aic->state);
		aic->last_end_request = jiffies;
	}
-	spin_unlock(&aic->lock);
+	spin_unlock_irqrestore(&aic->lock, flags);
	put_io_context(arq->io_context);
}
BTW, this looks bogus. Why do you need any locking there?
To prevent a request completion on another queue on another CPU from
racing with request insertion: last_end_request is undefined if the
flag is not set. I guess you could flip the statements and put a
smp_mb between them. Probably not worth the trouble though.
No better to make it explicit, probably doesn't matter much in
real-life. Thanks for the clarifications.
Ah, it would be clearer as:
	if (arq->is_sync == REQ_SYNC) {
		spin_lock(&aic->lock);
		set_bit(AS_TASK_IORUNNING, &aic->state);
		aic->last_end_request = jiffies;
		spin_unlock(&aic->lock);
	}
Then it doesn't need comments :)
Yeah thats was a bit silly of me I see why you got confused. I
have actually fixed this up in mm3. So it should get through to
Linus sometime after 2.6.0.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/