All of lore.kernel.org
 help / color / mirror / Atom feed
* [Kernel-janitors] [PATCH] yield() replaced with
@ 2004-05-20 15:50 Brendan Burns
  2004-05-20 20:41 ` Randy.Dunlap
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Brendan Burns @ 2004-05-20 15:50 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: TEXT/PLAIN, Size: 449 bytes --]

Hey folks,
sorry about the last empty message...  I'm still figuring out this whole
"e-mail" thing ;-P

Attached is a patch that replaces all instances of yield() in the drivers
section of the kernel.   I think my choices of schedule vs
schedule_timeout make sense.  I'd love someone to check them...  Plus
since I don't have all the appropriate hardware (read macintosh adb) it
would be great if they were tested by those who do!

thanks
--brendan

[-- Attachment #2: Type: TEXT/PLAIN, Size: 7824 bytes --]

diff -ur linux/drivers/cdrom/cdu31a.c linux-new/drivers/cdrom/cdu31a.c
--- linux/drivers/cdrom/cdu31a.c	2004-05-19 10:43:58.000000000 -0400
+++ linux-new/drivers/cdrom/cdu31a.c	2004-05-19 10:45:49.000000000 -0400
@@ -386,9 +386,10 @@
 	unsigned long flags;
 
 	if (cdu31a_irq <= 0) {
-		yield();
+	  set_current_state(TASK_INTERRUPTIBLE);
+	  schedule_timeout(1);
 	} else {		/* Interrupt driven */
-
+	  
 		save_flags(flags);
 		cli();
 		enable_interrupts();
diff -ur linux/drivers/cdrom/sonycd535.c linux-new/drivers/cdrom/sonycd535.c
--- linux/drivers/cdrom/sonycd535.c	2004-05-19 10:44:04.000000000 -0400
+++ linux-new/drivers/cdrom/sonycd535.c	2004-05-19 10:45:45.000000000 -0400
@@ -342,7 +342,8 @@
 sony_sleep(void)
 {
 	if (sony535_irq_used <= 0) {	/* poll */
-		yield();
+	  set_current_state(TASK_INTERRUPTIBLE);
+	  schedule_timeout(1);
 	} else {	/* Interrupt driven */
 		DEFINE_WAIT(wait);
 		
diff -ur linux/drivers/macintosh/adb.c linux-new/drivers/macintosh/adb.c
--- linux/drivers/macintosh/adb.c	2004-05-19 10:46:44.000000000 -0400
+++ linux-new/drivers/macintosh/adb.c	2004-05-19 10:49:24.000000000 -0400
@@ -553,7 +553,8 @@
 	if (adb_handler[index].handler) {
 		while(adb_handler[index].busy) {
 			write_unlock_irq(&adb_handler_lock);
-			yield();
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(10);
 			write_lock_irq(&adb_handler_lock);
 		}
 		ret = 0;
diff -ur linux/drivers/message/i2o/i2o_core.c linux-new/drivers/message/i2o/i2o_core.c
--- linux/drivers/message/i2o/i2o_core.c	2004-05-19 11:23:07.000000000 -0400
+++ linux-new/drivers/message/i2o/i2o_core.c	2004-05-19 10:54:14.000000000 -0400
@@ -1299,7 +1299,8 @@
 				c->name, why);
 			return 0xFFFFFFFF;
 		}
-		yield();
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(5*HZ);
 		barrier();
 	}
 	return m;
@@ -1818,7 +1819,7 @@
 			printk(KERN_ERR "%s: Get status timeout.\n",c->name);
 			return -ETIMEDOUT;
 		}
-		yield();
+		schedule();
 		barrier();
 	}
 
@@ -2252,7 +2253,8 @@
 			pci_free_consistent(c->pdev, 4, status, status_phys);
 			return -ETIMEDOUT;
 		}  
-		yield();
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(30*HZ);
 		barrier();
 	}  
 
diff -ur linux/drivers/mtd/chips/cfi_cmdset_0002.c linux-new/drivers/mtd/chips/cfi_cmdset_0002.c
--- linux/drivers/mtd/chips/cfi_cmdset_0002.c	2004-05-19 10:55:20.000000000 -0400
+++ linux-new/drivers/mtd/chips/cfi_cmdset_0002.c	2004-05-19 10:56:00.000000000 -0400
@@ -583,7 +583,7 @@
 
 		if (need_resched()) {
 			cfi_spin_unlock(chip->mutex);
-			yield();
+			schedule();
 			cfi_spin_lock(chip->mutex);
 		} else 
 			udelay(1);
diff -ur linux/drivers/mtd/nand/nand.c linux-new/drivers/mtd/nand/nand.c
--- linux/drivers/mtd/nand/nand.c	2004-05-19 10:56:32.000000000 -0400
+++ linux-new/drivers/mtd/nand/nand.c	2004-05-19 10:57:47.000000000 -0400
@@ -346,7 +346,8 @@
 			break;
 						
 		spin_unlock_bh (&this->chip_lock);
-		yield ();
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(1);
 		spin_lock_bh (&this->chip_lock);
 	}
 	status = (int) readb (this->IO_ADDR_R);
diff -ur linux/drivers/net/depca.c linux-new/drivers/net/depca.c
--- linux/drivers/net/depca.c	2004-05-19 10:58:25.000000000 -0400
+++ linux-new/drivers/net/depca.c	2004-05-19 11:02:14.000000000 -0400
@@ -762,8 +762,10 @@
 		outw(INEA | INIT, DEPCA_DATA);
 
 		delay = jiffies + HZ/50;
-		while (time_before(jiffies, delay))
-			yield();
+		while (time_before(jiffies, delay)) {
+		  set_current_state(TASK_INTERRUPTIBLE);
+		  schedule_timeout(delay);
+		}
 
 		irqnum = probe_irq_off(irq_mask);
 
diff -ur linux/drivers/net/sb1000.c linux-new/drivers/net/sb1000.c
--- linux/drivers/net/sb1000.c	2004-05-19 10:59:44.000000000 -0400
+++ linux-new/drivers/net/sb1000.c	2004-05-19 11:00:22.000000000 -0400
@@ -271,7 +271,7 @@
 	timeout = jiffies + TimeOutJiffies;
 	while (a & 0x80 || a & 0x40) {
 		/* a little sleep */
-		yield();
+		schedule();
 
 		a = inb(ioaddr[0] + 7);
 		if (time_after_eq(jiffies, timeout)) {
@@ -295,7 +295,7 @@
 	timeout = jiffies + TimeOutJiffies;
 	while (a & 0x80 || !(a & 0x40)) {
 		/* a little sleep */
-		yield();
+		schedule();
 
 		a = inb(ioaddr[1] + 6);
 		if (time_after_eq(jiffies, timeout)) {
diff -ur linux/drivers/net/sis900.c linux-new/drivers/net/sis900.c
--- linux/drivers/net/sis900.c	2004-05-19 11:00:32.000000000 -0400
+++ linux-new/drivers/net/sis900.c	2004-05-19 11:00:53.000000000 -0400
@@ -600,7 +600,7 @@
 
 	if(status & MII_STAT_LINK){
 		while (poll_bit) {
-			yield();
+			schedule();
 
 			poll_bit ^= (mdio_read(net_dev, sis_priv->cur_phy, MII_STATUS) & poll_bit);
 			if (time_after_eq(jiffies, timeout)) {
diff -ur linux/drivers/net/sungem.c linux-new/drivers/net/sungem.c
--- linux/drivers/net/sungem.c	2004-05-19 11:01:07.000000000 -0400
+++ linux-new/drivers/net/sungem.c	2004-05-19 11:02:34.000000000 -0400
@@ -2085,9 +2085,10 @@
 	del_timer_sync(&gp->link_timer);
 
 	/* Stop the reset task */
-	while (gp->reset_task_pending)
-		yield();
-	
+	while (gp->reset_task_pending) {
+	  set_current_state(TASK_INTERRUPTIBLE);
+	  schedule_timeout(1);
+	}
 	/* Actually stop the chip */
 	if (gp->pdev->vendor == PCI_VENDOR_ID_APPLE) {
 		gem_stop_phy(gp);
diff -ur linux/drivers/scsi/ibmmca.c linux-new/drivers/scsi/ibmmca.c
--- linux/drivers/scsi/ibmmca.c	2004-05-19 11:04:32.000000000 -0400
+++ linux-new/drivers/scsi/ibmmca.c	2004-05-19 11:05:25.000000000 -0400
@@ -2191,8 +2191,10 @@
 	printk("IBM MCA SCSI: Abort queued to adapter...\n");
 #endif
 	spin_unlock_irq(shpnt->host_lock);
-	while (!cmd->SCp.Status)
-		yield();
+	while (!cmd->SCp.Status) {
+	  set_current_state(TASK_INTERRUPTIBLE);
+	  schedule_timeout(1);
+	}
 	spin_lock_irq(shpnt->host_lock);
 	cmd->scsi_done = saved_done;
 #ifdef IM_DEBUG_PROBE
@@ -2259,7 +2261,8 @@
 		if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
 			break;
 		spin_unlock_irq(shpnt->host_lock);
-		yield();
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(1);
 		spin_lock_irq(shpnt->host_lock);
 	}
 	/*write registers and enable system interrupts */
diff -ur linux/drivers/scsi/megaraid.c linux-new/drivers/scsi/megaraid.c
--- linux/drivers/scsi/megaraid.c	2004-05-19 11:05:49.000000000 -0400
+++ linux-new/drivers/scsi/megaraid.c	2004-05-19 11:10:49.000000000 -0400
@@ -1686,12 +1686,13 @@
 __mega_busywait_mbox (adapter_t *adapter)
 {
 	volatile mbox_t *mbox = adapter->mbox;
-	long counter;
+	long time=jiffies;
 
-	for (counter = 0; counter < 10000; counter++) {
-		if (!mbox->m_in.busy)
-			return 0;
-		udelay(100); yield();
+	while (time-jiffies < HZ) {
+	  set_current_state(TASK_INTERRUPTIBLE);
+	  schedule_timeout((time+HZ)-jiffies);
+	  if (!mbox->m_in.busy)
+	    return 0;
 	}
 	return -1;		/* give up after 1 second */
 }
diff -ur linux/drivers/scsi/NCR5380.c linux-new/drivers/scsi/NCR5380.c
--- linux/drivers/scsi/NCR5380.c	2004-05-19 11:03:16.000000000 -0400
+++ linux-new/drivers/scsi/NCR5380.c	2004-05-19 11:04:12.000000000 -0400
@@ -382,8 +382,10 @@
 		r = NCR5380_read(reg);
 		if((r & bit) == val)
 			return 0;
-		if(!in_interrupt())
-			yield();
+		if(!in_interrupt()) {
+		  set_current_state(TASK_INTERRUPTIBLE);
+		  schedule_timeout(1);
+		}
 		else
 			cpu_relax();
 	}
diff -ur linux/drivers/usb/core/message.c linux-new/drivers/usb/core/message.c
--- linux/drivers/usb/core/message.c	2004-05-19 11:12:19.000000000 -0400
+++ linux-new/drivers/usb/core/message.c	2004-05-19 11:12:24.000000000 -0400
@@ -462,7 +462,7 @@
 			io->urbs [i]->dev = 0;
 			retval = 0;
 			i--;
-			yield ();
+			schedule ();
 			break;
 
 			/* no error? continue immediately.

[-- Attachment #3: Type: text/plain, Size: 167 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
http://lists.osdl.org/mailman/listinfo/kernel-janitors

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2004-05-24 15:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-20 15:50 [Kernel-janitors] [PATCH] yield() replaced with Brendan Burns
2004-05-20 20:41 ` Randy.Dunlap
2004-05-20 21:35 ` Greg KH
2004-05-21  0:47 ` [Kernel-janitors] [PATCH] yield() replaced Gustavo Franco
2004-05-21  2:33 ` [Kernel-janitors] [PATCH] yield() replaced with Randy.Dunlap
2004-05-21 10:23 ` [Kernel-janitors] [PATCH] yield() replaced Arnaldo Carvalho de Melo
2004-05-23 23:28 ` maximilian attems
2004-05-24  0:14 ` Gustavo Franco
2004-05-24  0:47 ` [Kernel-janitors] [PATCH] yield() replaced with Randy.Dunlap
2004-05-24  1:10 ` Gustavo Franco
2004-05-24 10:46 ` maximilian attems
2004-05-24 14:32 ` Greg KH
2004-05-24 15:57 ` maximilian attems

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.