Skip to contentSkip to conversation

2.6.10-rc2-bk7 - Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

DISCUSSION Christopher S. Aker 2 participants 9 messages Nov 24, 2004 – Nov 27, 2004 Block layer

lore
Share & tools
lore
#0 lore raw

Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

 [<c025eed4>] cfq_put_request+0xcc/0x119
 [<c0252520>] elv_put_request+0x25/0x27
 [<c02553a5>] __blk_put_request+0x66/0xab
 [<c0256647>] end_that_request_last+0x6a/0x10b
 [<c029d836>] scsi_end_request+0xbf/0xe6
 [<c029db11>] scsi_io_completion+0x117/0x4b6
 [<c029b2e2>] scsi_delete_timer+0x1a/0x66
 [<c02a9290>] sd_rw_intr+0x89/0x30f
 [<c0114472>] rebalance_tick+0xac/0xbb
 [<c0298e8a>] scsi_finish_command+0x85/0xd9
 [<c0298d9d>] scsi_softirq+0xb7/0xdd
 [<c011cba7>] __do_softirq+0xb7/0xc6
 [<c011cbe3>] do_softirq+0x2d/0x2f
 [<c01046b6>] do_IRQ+0x1e/0x24
 [<c0102db2>] common_interrupt+0x1a/0x20
 [<c01005da>] mwait_idle+0x31/0x48
 [<c01005a0>] cpu_idle+0x33/0x3c
 [<c046aa49>] start_kernel+0x175/0x1b1
 [<c046a4bd>] unknown_bootoption+0x0/0x1ab

-Chris

#1 lore raw
Quoted 12 lines · Christopher S. Aker

Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

 [<c025eed4>] cfq_put_request+0xcc/0x119
 [<c0252520>] elv_put_request+0x25/0x27
 [<c02553a5>] __blk_put_request+0x66/0xab
 [<c0256647>] end_that_request_last+0x6a/0x10b
 [<c029d836>] scsi_end_request+0xbf/0xe6
 [<c029db11>] scsi_io_completion+0x117/0x4b6
 [<c029b2e2>] scsi_delete_timer+0x1a/0x66
 [<c02a9290>] sd_rw_intr+0x89/0x30f
 [<c0114472>] rebalance_tick+0xac/0xbb
 [<c0298e8a>] scsi_finish_command+0x85/0xd9
 [<c0298d9d>] scsi_softirq+0xb7/0xdd
Quoted 8 lines
 [<c011cba7>] __do_softirq+0xb7/0xc6
 [<c011cbe3>] do_softirq+0x2d/0x2f
 [<c01046b6>] do_IRQ+0x1e/0x24
 [<c0102db2>] common_interrupt+0x1a/0x20
 [<c01005da>] mwait_idle+0x31/0x48
 [<c01005a0>] cpu_idle+0x33/0x3c
 [<c046aa49>] start_kernel+0x175/0x1b1
 [<c046a4bd>] unknown_bootoption+0x0/0x1ab

It's a known issue, just not fixed yet... You can ignore the warning, cfq recovers the condition.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 22 lines · Jens Axboe
Quoted 12 lines · Christopher S. Aker

Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

 [<c025eed4>] cfq_put_request+0xcc/0x119
 [<c0252520>] elv_put_request+0x25/0x27
 [<c02553a5>] __blk_put_request+0x66/0xab
 [<c0256647>] end_that_request_last+0x6a/0x10b
 [<c029d836>] scsi_end_request+0xbf/0xe6
 [<c029db11>] scsi_io_completion+0x117/0x4b6
 [<c029b2e2>] scsi_delete_timer+0x1a/0x66
 [<c02a9290>] sd_rw_intr+0x89/0x30f
 [<c0114472>] rebalance_tick+0xac/0xbb
 [<c0298e8a>] scsi_finish_command+0x85/0xd9
 [<c0298d9d>] scsi_softirq+0xb7/0xdd
Quoted 8 lines
 [<c011cba7>] __do_softirq+0xb7/0xc6
 [<c011cbe3>] do_softirq+0x2d/0x2f
 [<c01046b6>] do_IRQ+0x1e/0x24
 [<c0102db2>] common_interrupt+0x1a/0x20
 [<c01005da>] mwait_idle+0x31/0x48
 [<c01005a0>] cpu_idle+0x33/0x3c
 [<c046aa49>] start_kernel+0x175/0x1b1
 [<c046a4bd>] unknown_bootoption+0x0/0x1ab
Quoted 2 lines

It's a known issue, just not fixed yet... You can ignore the warning, cfq recovers the condition.

Is this an SMP machine, btw?

Signature · 1 line
Jens Axboe
#3 lore raw
Quoted 23 lines · Jens Axboe
Quoted 22 lines · Christopher S. Aker
Quoted 20 lines

Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

 [<c025eed4>] cfq_put_request+0xcc/0x119
 [<c0252520>] elv_put_request+0x25/0x27
 [<c02553a5>] __blk_put_request+0x66/0xab
 [<c0256647>] end_that_request_last+0x6a/0x10b
 [<c029d836>] scsi_end_request+0xbf/0xe6
 [<c029db11>] scsi_io_completion+0x117/0x4b6
 [<c029b2e2>] scsi_delete_timer+0x1a/0x66
 [<c02a9290>] sd_rw_intr+0x89/0x30f
 [<c0114472>] rebalance_tick+0xac/0xbb
 [<c0298e8a>] scsi_finish_command+0x85/0xd9
 [<c0298d9d>] scsi_softirq+0xb7/0xdd
 [<c011cba7>] __do_softirq+0xb7/0xc6
 [<c011cbe3>] do_softirq+0x2d/0x2f
 [<c01046b6>] do_IRQ+0x1e/0x24
 [<c0102db2>] common_interrupt+0x1a/0x20
 [<c01005da>] mwait_idle+0x31/0x48
 [<c01005a0>] cpu_idle+0x33/0x3c
 [<c046aa49>] start_kernel+0x175/0x1b1
 [<c046a4bd>] unknown_bootoption+0x0/0x1ab
Quoted 4 lines
Quoted 2 lines

It's a known issue, just not fixed yet... You can ignore the warning, cfq recovers the condition.

Is this an SMP machine, btw?

Yep.

-Chris

#4 lore raw
Quoted 23 lines · Christopher S. Aker
Quoted 23 lines · Jens Axboe
Quoted 22 lines · Christopher S. Aker
Quoted 20 lines

Badness in cfq_put_request at drivers/block/cfq-iosched.c:1402

 [<c025eed4>] cfq_put_request+0xcc/0x119
 [<c0252520>] elv_put_request+0x25/0x27
 [<c02553a5>] __blk_put_request+0x66/0xab
 [<c0256647>] end_that_request_last+0x6a/0x10b
 [<c029d836>] scsi_end_request+0xbf/0xe6
 [<c029db11>] scsi_io_completion+0x117/0x4b6
 [<c029b2e2>] scsi_delete_timer+0x1a/0x66
 [<c02a9290>] sd_rw_intr+0x89/0x30f
 [<c0114472>] rebalance_tick+0xac/0xbb
 [<c0298e8a>] scsi_finish_command+0x85/0xd9
 [<c0298d9d>] scsi_softirq+0xb7/0xdd
 [<c011cba7>] __do_softirq+0xb7/0xc6
 [<c011cbe3>] do_softirq+0x2d/0x2f
 [<c01046b6>] do_IRQ+0x1e/0x24
 [<c0102db2>] common_interrupt+0x1a/0x20
 [<c01005da>] mwait_idle+0x31/0x48
 [<c01005a0>] cpu_idle+0x33/0x3c
 [<c046aa49>] start_kernel+0x175/0x1b1
 [<c046a4bd>] unknown_bootoption+0x0/0x1ab
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

It's a known issue, just not fixed yet... You can ignore the warning, cfq recovers the condition.

Is this an SMP machine, btw?

Yep.

Can you try this simple check to see if it triggers anything?

===== cfq-iosched.c 1.13 vs edited =====

cfq-iosched.c renamed from drivers/block/cfq-iosched.c +2 -0
@@ -1389,6 +1389,8 @@
 	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_rq *crq = RQ_DATA(rq);
 
+	WARN_ON(!spin_is_locked(q->queue_lock));
+
 	if (crq) {
 		struct cfq_queue *cfqq = crq->cfq_queue;
 
Signature · 1 line
Jens Axboe
#5 lore raw

cfq-iosched.c 2004-11-24 14:40:13 +01:00 line 1395

Quoted 13 lines

Can you try this simple check to see if it triggers anything?

===== cfq-iosched.c 1.13 vs edited =====

cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +2 -0
@@ -1389,6 +1389,8 @@
  struct cfq_data *cfqd = q->elevator->elevator_data;
  struct cfq_rq *crq = RQ_DATA(rq);
 
+ WARN_ON(!spin_is_locked(q->queue_lock));
+
  if (crq) {
  struct cfq_queue *cfqq = crq->cfq_queue;

I'd be happy to, but I won't have a free machine for a couple of days. I'll can probably give it a shot during the weekend...

-Chris

#6 lore raw
Quoted 9 lines · Christopher S. Aker
Quoted 9 lines

Can you try this simple check to see if it triggers anything?

===== cfq-iosched.c 1.13 vs edited =====

cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +0 -0
@@ -1389,6 +1389,8 @@
  struct cfq_data *cfqd = q->elevator->elevator_data;
  struct cfq_rq *crq = RQ_DATA(rq);
 
Quoted 7 lines

cfq-iosched.c 2004-11-24 14:40:13 +01:00 line 1395

Quoted 4 lines
cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +2 -0
+ WARN_ON(!spin_is_locked(q->queue_lock));
+
  if (crq) {
  struct cfq_queue *cfqq = crq->cfq_queue;

I'd be happy to, but I won't have a free machine for a couple of days. I'll can probably give it a shot during the weekend...

Nevermind, here's a patch to fix it. I was so focused on the decrement side of things that I forgot to check the increment, pretty silly error really.

===== drivers/block/cfq-iosched.c 1.12 vs edited =====

drivers/block/cfq-iosched.c +3 -5
@@ -1398,10 +1398,7 @@
 		if (crq->io_context)
 			put_io_context(crq->io_context->ioc);
 
-		if (!cfqq->allocated[crq->is_write]) {
-			WARN_ON(1);
-			cfqq->allocated[crq->is_write] = 1;
-		}
+		BUG_ON(!cfqq->allocated[crq->is_write]);
 		cfqq->allocated[crq->is_write]--;
 
 		mempool_free(crq, cfqd->crq_pool);
@@ -1442,6 +1439,7 @@
 	if (cfqq->allocated[rw] >= cfqd->max_queued)
 		goto out_lock;
 
+	cfqq->allocated[rw]++;
 	spin_unlock_irqrestore(q->queue_lock, flags);
 
 	/*
@@ -1465,7 +1463,6 @@
 		crq->in_flight = crq->accounted = crq->is_sync = 0;
 		crq->is_write = rw;
 		rq->elevator_private = crq;
-		cfqq->allocated[rw]++;
 		cfqq->alloc_limit[rw] = 0;
 		return 0;
 	}
@@ -1473,6 +1470,7 @@
 	put_io_context(cic->ioc);
 err:
 	spin_lock_irqsave(q->queue_lock, flags);
+	cfqq->allocated[rw]--;
 	cfq_put_queue(cfqq);
 out_lock:
 	spin_unlock_irqrestore(q->queue_lock, flags);
Signature · 1 line
Jens Axboe
#7 lore raw
Quoted 18 lines · Jens Axboe
Quoted 9 lines · Christopher S. Aker
Quoted 9 lines

Can you try this simple check to see if it triggers anything?

===== cfq-iosched.c 1.13 vs edited =====

cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +0 -0
@@ -1389,6 +1389,8 @@
  struct cfq_data *cfqd = q->elevator->elevator_data;
  struct cfq_rq *crq = RQ_DATA(rq);
 
Quoted 7 lines

cfq-iosched.c 2004-11-24 14:40:13 +01:00 line 1395

Quoted 4 lines
cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +2 -0
+ WARN_ON(!spin_is_locked(q->queue_lock));
+
  if (crq) {
  struct cfq_queue *cfqq = crq->cfq_queue;

I'd be happy to, but I won't have a free machine for a couple of days. I'll can probably give it a shot during the weekend...

Quoted 3 lines

Nevermind, here's a patch to fix it. I was so focused on the decrement side of things that I forgot to check the increment, pretty silly error really.

And a small fix is needed on top of that, in case of hash type changes (writing to hash_key).

===== drivers/block/cfq-iosched.c 1.13 vs edited =====

drivers/block/cfq-iosched.c +15 -8
@@ -1398,10 +1398,7 @@
 		if (crq->io_context)
 			put_io_context(crq->io_context->ioc);
 
-		if (!cfqq->allocated[crq->is_write]) {
-			WARN_ON(1);
-			cfqq->allocated[crq->is_write] = 1;
-		}
+		BUG_ON(!cfqq->allocated[crq->is_write]);
 		cfqq->allocated[crq->is_write]--;
 
 		mempool_free(crq, cfqd->crq_pool);
@@ -1439,20 +1436,30 @@
 #endif
 	}
 
+repeat:
 	if (cfqq->allocated[rw] >= cfqd->max_queued)
 		goto out_lock;
 
+	cfqq->allocated[rw]++;
 	spin_unlock_irqrestore(q->queue_lock, flags);
 
 	/*
-	 * if hashing type has changed, the cfq_queue might change here. we
-	 * don't bother rechecking ->allocated since it should be a rare
-	 * event
+	 * if hashing type has changed, the cfq_queue might change here.
 	 */
 	cic = cfq_get_io_context(&cfqq, gfp_mask);
 	if (!cic)
 		goto err;
 
+	/*
+	 * repeat allocation checks on queue change
+	 */
+	if (unlikely(cic->cfqq != cfqq)) {
+		spin_lock_irqsave(q->queue_lock, flags);
+		cfqq->allocated[rw]--;
+		cfqq = cic->cfqq;
+		goto repeat;
+	}
+
 	crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
 	if (crq) {
 		RB_CLEAR(&crq->rb_node);
@@ -1465,7 +1472,6 @@
 		crq->in_flight = crq->accounted = crq->is_sync = 0;
 		crq->is_write = rw;
 		rq->elevator_private = crq;
-		cfqq->allocated[rw]++;
 		cfqq->alloc_limit[rw] = 0;
 		return 0;
 	}
@@ -1473,6 +1479,7 @@
 	put_io_context(cic->ioc);
 err:
 	spin_lock_irqsave(q->queue_lock, flags);
+	cfqq->allocated[rw]--;
 	cfq_put_queue(cfqq);
 out_lock:
 	spin_unlock_irqrestore(q->queue_lock, flags);
Signature · 1 line
Jens Axboe
#8 lore raw
Quoted 19 lines · Jens Axboe
Quoted 18 lines · Jens Axboe
Quoted 16 lines · Christopher S. Aker

cfq-iosched.c 2004-11-24 14:40:13 +01:00 line 1395

Quoted 13 lines

Can you try this simple check to see if it triggers anything?

===== cfq-iosched.c 1.13 vs edited =====

cfq-iosched.c 2004-11-24 14:40:13 +01:00 renamed from drivers/block/cfq-iosched.c 2004-10-30 01:35:21 +02:00 +2 -0
@@ -1389,6 +1389,8 @@
  struct cfq_data *cfqd = q->elevator->elevator_data;
  struct cfq_rq *crq = RQ_DATA(rq);
 
+ WARN_ON(!spin_is_locked(q->queue_lock));
+
  if (crq) {
  struct cfq_queue *cfqq = crq->cfq_queue;

I'd be happy to, but I won't have a free machine for a couple of days. I'll can probably give it a shot during the weekend...

Quoted 6 lines
Quoted 3 lines

Nevermind, here's a patch to fix it. I was so focused on the decrement side of things that I forgot to check the increment, pretty silly error really.

And a small fix is needed on top of that, in case of hash type changes (writing to hash_key).

... And that one relied on another hashing change I made locally. 3rd time is the charm,.

===== drivers/block/cfq-iosched.c 1.13 vs edited =====

drivers/block/cfq-iosched.c +16 -9
@@ -1398,10 +1398,7 @@
 		if (crq->io_context)
 			put_io_context(crq->io_context->ioc);
 
-		if (!cfqq->allocated[crq->is_write]) {
-			WARN_ON(1);
-			cfqq->allocated[crq->is_write] = 1;
-		}
+		BUG_ON(!cfqq->allocated[crq->is_write]);
 		cfqq->allocated[crq->is_write]--;
 
 		mempool_free(crq, cfqd->crq_pool);
@@ -1421,7 +1418,7 @@
 	struct cfq_data *cfqd = q->elevator->elevator_data;
 	struct cfq_io_context *cic;
 	const int rw = rq_data_dir(rq);
-	struct cfq_queue *cfqq;
+	struct cfq_queue *cfqq, *saved_cfqq;
 	struct cfq_rq *crq;
 	unsigned long flags;
 
@@ -1439,20 +1436,30 @@
 #endif
 	}
 
+repeat:
 	if (cfqq->allocated[rw] >= cfqd->max_queued)
 		goto out_lock;
 
+	cfqq->allocated[rw]++;
 	spin_unlock_irqrestore(q->queue_lock, flags);
 
 	/*
-	 * if hashing type has changed, the cfq_queue might change here. we
-	 * don't bother rechecking ->allocated since it should be a rare
-	 * event
+	 * if hashing type has changed, the cfq_queue might change here.
 	 */
+	saved_cfqq = cfqq;
 	cic = cfq_get_io_context(&cfqq, gfp_mask);
 	if (!cic)
 		goto err;
 
+	/*
+	 * repeat allocation checks on queue change
+	 */
+	if (unlikely(saved_cfqq != cfqq)) {
+		spin_lock_irqsave(q->queue_lock, flags);
+		saved_cfqq->allocated[rw]--;
+		goto repeat;
+	}
+
 	crq = mempool_alloc(cfqd->crq_pool, gfp_mask);
 	if (crq) {
 		RB_CLEAR(&crq->rb_node);
@@ -1465,7 +1472,6 @@
 		crq->in_flight = crq->accounted = crq->is_sync = 0;
 		crq->is_write = rw;
 		rq->elevator_private = crq;
-		cfqq->allocated[rw]++;
 		cfqq->alloc_limit[rw] = 0;
 		return 0;
 	}
@@ -1473,6 +1479,7 @@
 	put_io_context(cic->ioc);
 err:
 	spin_lock_irqsave(q->queue_lock, flags);
+	cfqq->allocated[rw]--;
 	cfq_put_queue(cfqq);
 out_lock:
 	spin_unlock_irqrestore(q->queue_lock, flags);
Signature · 1 line
Jens Axboe