Skip to contentSkip to conversation

switch command completion queue to per-cpu data

PATCH New Christoph Hellwig 1 participant 1 message Sep 22, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 switch command completion queue to per-cpu data

- DEFINE_PER_CPU works in modules now, use it
- rename done_q to scsi_done_q - in the kernel we prefer descriptive prefixes even for statics..

drivers/scsi/scsi.c +4 -6
diff -Nru a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
@@ -535,7 +535,7 @@
 /*
  * Per-CPU I/O completion queue.
  */
-static struct list_head done_q[NR_CPUS] __cacheline_aligned;
+static DEFINE_PER_CPU(struct list_head, scsi_done_q);
 
 /**
  * scsi_done - Enqueue the finished SCSI command into the done queue.
@@ -553,7 +553,6 @@
 void scsi_done(struct scsi_cmnd *cmd)
 {
 	unsigned long flags;
-	int cpu;
 
 	/*
 	 * We don't have to worry about this one timing out any more.
@@ -580,8 +579,7 @@
 	 * and need no spinlock.
 	 */
 	local_irq_save(flags);
-	cpu = smp_processor_id();
-	list_add_tail(&cmd->eh_entry, &done_q[cpu]);
+	list_add_tail(&cmd->eh_entry, &__get_cpu_var(scsi_done_q));
 	raise_softirq_irqoff(SCSI_SOFTIRQ);
 	local_irq_restore(flags);
 }
@@ -600,7 +598,7 @@
 	LIST_HEAD(local_q);
 
 	local_irq_disable();
-	list_splice_init(&done_q[smp_processor_id()], &local_q);
+	list_splice_init(&__get_cpu_var(scsi_done_q), &local_q);
 	local_irq_enable();
 
 	while (!list_empty(&local_q)) {
@@ -1008,7 +1006,7 @@
 		goto cleanup_sysctl;
 
 	for (i = 0; i < NR_CPUS; i++)
-		INIT_LIST_HEAD(&done_q[i]);
+		INIT_LIST_HEAD(&per_cpu(scsi_done_q, i));
 
 	devfs_mk_dir("scsi");
 	open_softirq(SCSI_SOFTIRQ, scsi_softirq, NULL);