Skip to contentSkip to conversation

task->state cleanup: pilot

RFC PATCH In review Paul P Komkoff Jr 3 participants 3 messages Apr 6, 2002 – Apr 7, 2002 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 task->state cleanup: pilot

This is the pilot of task->state cleanup in 2.4.x. Feel free to blame me for incorrect use of set_task_state vs. __set_task_state

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.310 -> 1.311
# drivers/char/drm-4.0/radeon_drv.c 1.1 -> 1.2
# drivers/char/drm-4.0/tdfx_drv.c 1.1 -> 1.2
# drivers/char/drm/drm_lock.h 1.2 -> 1.3
# drivers/char/drm-4.0/i810_drv.c 1.1 -> 1.2
# drivers/char/drm-4.0/lists.c 1.1 -> 1.2
# drivers/char/drm/drm_drv.h 1.3 -> 1.4
# drivers/char/drm/drm_lists.h 1.2 -> 1.3
# drivers/char/drm/i810_dma.c 1.6 -> 1.7
# drivers/char/drm-4.0/r128_drv.c 1.1 -> 1.2
# drivers/char/drm-4.0/gamma_dma.c 1.1 -> 1.2
# drivers/char/drm-4.0/mga_dma.c 1.1 -> 1.2
# drivers/char/drm-4.0/dma.c 1.1 -> 1.2
# drivers/char/drm-4.0/i810_dma.c 1.2 -> 1.3
# drivers/char/drm-4.0/ffb_drv.c 1.2 -> 1.3
# drivers/char/drm/drm_dma.h 1.3 -> 1.4
# drivers/char/drm-4.0/lock.c 1.1 -> 1.2
# drivers/char/drm-4.0/mga_drv.c 1.1 -> 1.2
# drivers/char/drm/gamma_dma.c 1.2 -> 1.3
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/04/07 [email protected] 1.311
# task->state cleanup part 1
# --------------------------------------------
#

drivers/char/drm/drm_dma.h +2 -2
diff -Nru a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h
@@ -359,7 +359,7 @@
 		add_wait_queue(&q->write_queue, &entry);
 		atomic_inc(&q->block_count);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!atomic_read(&q->block_write)) break;
 			schedule();
 			if (signal_pending(current)) {
@@ -369,7 +369,7 @@
 			}
 		}
 		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&q->write_queue, &entry);
 	}
 
drivers/char/drm/drm_drv.h +4 -4
diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
@@ -790,7 +790,7 @@
 		DECLARE_WAITQUEUE( entry, current );
 		add_wait_queue( &dev->lock.lock_queue, &entry );
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if ( !dev->lock.hw_lock ) {
 				/* Device has been unregistered */
 				retcode = -EINTR;
@@ -813,7 +813,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue( &dev->lock.lock_queue, &entry );
 		if( !retcode ) {
 			DRIVER_RELEASE();
@@ -962,7 +962,7 @@
         if ( !ret ) {
                 add_wait_queue( &dev->lock.lock_queue, &entry );
                 for (;;) {
-                        current->state = TASK_INTERRUPTIBLE;
+                        set_current_state(TASK_INTERRUPTIBLE);
                         if ( !dev->lock.hw_lock ) {
                                 /* Device has been unregistered */
                                 ret = -EINTR;
@@ -983,7 +983,7 @@
                                 break;
                         }
                 }
-                current->state = TASK_RUNNING;
+                set_current_state(TASK_RUNNING);
                 remove_wait_queue( &dev->lock.lock_queue, &entry );
         }
 
drivers/char/drm/drm_lists.h +2 -2
diff -Nru a/drivers/char/drm/drm_lists.h b/drivers/char/drm/drm_lists.h
@@ -212,13 +212,13 @@
 		if (block) {
 			add_wait_queue(&bl->waiting, &entry);
 			for (;;) {
-				current->state = TASK_INTERRUPTIBLE;
+				set_current_state(TASK_INTERRUPTIBLE);
 				if (!atomic_read(&bl->wfh)
 				    && (buf = DRM(freelist_try)(bl))) break;
 				schedule();
 				if (signal_pending(current)) break;
 			}
-			current->state = TASK_RUNNING;
+			set_current_state(TASK_RUNNING);
 			remove_wait_queue(&bl->waiting, &entry);
 		}
 		return buf;
drivers/char/drm/drm_lock.h +2 -2
diff -Nru a/drivers/char/drm/drm_lock.h b/drivers/char/drm/drm_lock.h
@@ -125,7 +125,7 @@
 		add_wait_queue(&q->flush_queue, &entry);
 		atomic_inc(&q->block_count);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!DRM_BUFCOUNT(&q->waitlist)) break;
 			schedule();
 			if (signal_pending(current)) {
@@ -134,7 +134,7 @@
 			}
 		}
 		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&q->flush_queue, &entry);
 	}
 	atomic_dec(&q->use_count);
drivers/char/drm/gamma_dma.c +4 -4
diff -Nru a/drivers/char/drm/gamma_dma.c b/drivers/char/drm/gamma_dma.c
@@ -428,7 +428,7 @@
 		    && !(dev->queuelist[buf->context]->flags
 			 & _DRM_CONTEXT_PRESERVED)) {
 			add_wait_queue(&dev->context_wait, &entry);
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 				/* PRE: dev->last_context != buf->context */
 			DRM(context_switch)(dev, dev->last_context,
 					    buf->context);
@@ -438,7 +438,7 @@
 				   NOTE WE HOLD THE LOCK THROUGHOUT THIS
 				   TIME! */
 			schedule();
-			current->state = TASK_RUNNING;
+			set_current_state(TASK_RUNNING);
 			remove_wait_queue(&dev->context_wait, &entry);
 			if (signal_pending(current)) {
 				retcode = -EINTR;
@@ -505,7 +505,7 @@
 	if (d->flags & _DRM_DMA_BLOCK) {
 		DRM_DEBUG("%d waiting\n", current->pid);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!last_buf->waiting && !last_buf->pending)
 				break; /* finished */
 			schedule();
@@ -514,7 +514,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		DRM_DEBUG("%d running\n", current->pid);
 		remove_wait_queue(&last_buf->dma_wait, &entry);
 		if (!retcode
drivers/char/drm/i810_dma.c +4 -4
diff -Nru a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
@@ -975,7 +975,7 @@
    	end = jiffies + (HZ*3);
 
    	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 	      	i810_dma_quiescent_emit(dev);
 	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
 		if((signed)(end - jiffies) <= 0) {
@@ -988,7 +988,7 @@
 		}
 	}
 
-   	current->state = TASK_RUNNING;
+   	set_current_state(TASK_RUNNING);
    	remove_wait_queue(&dev_priv->flush_queue, &entry);
 
    	return;
@@ -1009,7 +1009,7 @@
    	add_wait_queue(&dev_priv->flush_queue, &entry);
    	end = jiffies + (HZ*3);
    	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 	      	i810_dma_emit_flush(dev);
 	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
 		if((signed)(end - jiffies) <= 0) {
@@ -1023,7 +1023,7 @@
 		}
 	}
 
-   	current->state = TASK_RUNNING;
+   	set_current_state(TASK_RUNNING);
    	remove_wait_queue(&dev_priv->flush_queue, &entry);
 
 
drivers/char/drm-4.0/dma.c +2 -2
diff -Nru a/drivers/char/drm-4.0/dma.c b/drivers/char/drm-4.0/dma.c
@@ -403,7 +403,7 @@
 		add_wait_queue(&q->write_queue, &entry);
 		atomic_inc(&q->block_count);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!atomic_read(&q->block_write)) break;
 			schedule();
 			if (signal_pending(current)) {
@@ -413,7 +413,7 @@
 			}
 		}
 		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&q->write_queue, &entry);
 	}
 	
drivers/char/drm-4.0/ffb_drv.c +2 -2
diff -Nru a/drivers/char/drm-4.0/ffb_drv.c b/drivers/char/drm-4.0/ffb_drv.c
@@ -709,7 +709,7 @@
                         
 		/* Contention */
 		atomic_inc(&dev->total_sleeps);
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 		current->policy |= SCHED_YIELD;
 		schedule();
 		if (signal_pending(current)) {
@@ -717,7 +717,7 @@
 			break;
 		}
 	}
-	current->state = TASK_RUNNING;
+	set_current_state(TASK_RUNNING);
 	remove_wait_queue(&dev->lock.lock_queue, &entry);
 
         if (!ret) {
drivers/char/drm-4.0/gamma_dma.c +7 -7
diff -Nru a/drivers/char/drm-4.0/gamma_dma.c b/drivers/char/drm-4.0/gamma_dma.c
@@ -466,7 +466,7 @@
 		    && !(dev->queuelist[buf->context]->flags
 			 & _DRM_CONTEXT_PRESERVED)) {
 			add_wait_queue(&dev->context_wait, &entry);
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 				/* PRE: dev->last_context != buf->context */
 			drm_context_switch(dev, dev->last_context,
 					   buf->context);
@@ -476,7 +476,7 @@
 				   NOTE WE HOLD THE LOCK THROUGHOUT THIS
 				   TIME! */
 			schedule();
-			current->state = TASK_RUNNING;
+			set_current_state(TASK_RUNNING);
 			remove_wait_queue(&dev->context_wait, &entry);
 			if (signal_pending(current)) {
 				retcode = -EINTR;
@@ -543,7 +543,7 @@
 	if (d->flags & _DRM_DMA_BLOCK) {
 		DRM_DEBUG("%d waiting\n", current->pid);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!last_buf->waiting && !last_buf->pending)
 				break; /* finished */
 			schedule();
@@ -552,7 +552,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		DRM_DEBUG("%d running\n", current->pid);
 		remove_wait_queue(&last_buf->dma_wait, &entry);
 		if (!retcode
@@ -771,13 +771,13 @@
 			if (j > 0 && j <= DRM_LOCK_SLICE) {
 				/* Can't take lock if we just had it and
 				   there is contention. */
-				current->state = TASK_INTERRUPTIBLE;
+				set_current_state(TASK_INTERRUPTIBLE);
 				schedule_timeout(j);
 			}
 		}
 		add_wait_queue(&dev->lock.lock_queue, &entry);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!dev->lock.hw_lock) {
 				/* Device has been unregistered */
 				ret = -EINTR;
@@ -800,7 +800,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&dev->lock.lock_queue, &entry);
 	}
 
drivers/char/drm-4.0/i810_dma.c +6 -6
diff -Nru a/drivers/char/drm-4.0/i810_dma.c b/drivers/char/drm-4.0/i810_dma.c
@@ -1071,7 +1071,7 @@
    	end = jiffies + (HZ*3);
    
    	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 	      	i810_dma_quiescent_emit(dev);
 	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
 		if((signed)(end - jiffies) <= 0) {
@@ -1084,7 +1084,7 @@
 		}
 	}
    
-   	current->state = TASK_RUNNING;
+   	set_current_state(TASK_RUNNING);
    	remove_wait_queue(&dev_priv->flush_queue, &entry);
    
    	return;
@@ -1105,7 +1105,7 @@
    	add_wait_queue(&dev_priv->flush_queue, &entry);
    	end = jiffies + (HZ*3);
    	for (;;) {
-		current->state = TASK_INTERRUPTIBLE;
+		set_current_state(TASK_INTERRUPTIBLE);
 	      	i810_dma_emit_flush(dev);
 	   	if (atomic_read(&dev_priv->flush_done) == 1) break;
 		if((signed)(end - jiffies) <= 0) {
@@ -1119,7 +1119,7 @@
 		}
 	}
    
-   	current->state = TASK_RUNNING;
+   	set_current_state(TASK_RUNNING);
    	remove_wait_queue(&dev_priv->flush_queue, &entry);
 
 
@@ -1199,7 +1199,7 @@
 	if (!ret) {
 		add_wait_queue(&dev->lock.lock_queue, &entry);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!dev->lock.hw_lock) {
 				/* Device has been unregistered */
 				ret = -EINTR;
@@ -1222,7 +1222,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&dev->lock.lock_queue, &entry);
 	}
 	
drivers/char/drm-4.0/i810_drv.c +2 -2
diff -Nru a/drivers/char/drm-4.0/i810_drv.c b/drivers/char/drm-4.0/i810_drv.c
@@ -508,7 +508,7 @@
 	   	DECLARE_WAITQUEUE(entry, current);
 	   	add_wait_queue(&dev->lock.lock_queue, &entry);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!dev->lock.hw_lock) {
 				/* Device has been unregistered */
 				retcode = -EINTR;
@@ -529,7 +529,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&dev->lock.lock_queue, &entry);
 	   	if(!retcode) {
 		   	i810_reclaim_buffers(dev, priv->pid);
drivers/char/drm-4.0/lists.c +2 -2
diff -Nru a/drivers/char/drm-4.0/lists.c b/drivers/char/drm-4.0/lists.c
@@ -202,13 +202,13 @@
 		if (block) {
 			add_wait_queue(&bl->waiting, &entry);
 			for (;;) {
-				current->state = TASK_INTERRUPTIBLE;
+				set_current_state(TASK_INTERRUPTIBLE);
 				if (!atomic_read(&bl->wfh)
 				    && (buf = drm_freelist_try(bl))) break;
 				schedule();
 				if (signal_pending(current)) break;
 			}
-			current->state = TASK_RUNNING;
+			set_current_state(TASK_RUNNING);
 			remove_wait_queue(&bl->waiting, &entry);
 		}
 		return buf;
drivers/char/drm-4.0/lock.c +2 -2
diff -Nru a/drivers/char/drm-4.0/lock.c b/drivers/char/drm-4.0/lock.c
@@ -125,7 +125,7 @@
 		add_wait_queue(&q->flush_queue, &entry);
 		atomic_inc(&q->block_count);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!DRM_BUFCOUNT(&q->waitlist)) break;
 			schedule();
 			if (signal_pending(current)) {
@@ -134,7 +134,7 @@
 			}
 		}
 		atomic_dec(&q->block_count);
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&q->flush_queue, &entry);
 	}
 	atomic_dec(&q->use_count);
drivers/char/drm-4.0/mga_dma.c +8 -8
diff -Nru a/drivers/char/drm-4.0/mga_dma.c b/drivers/char/drm-4.0/mga_dma.c
@@ -217,7 +217,7 @@
 	   	add_wait_queue(&dev_priv->buf_queue, &entry);
 		set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
 	   	for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 		   	mga_dma_schedule(dev, 0);
 			if(dev_priv->tail->age < dev_priv->last_prim_age)
 				break;
@@ -229,7 +229,7 @@
 			}
 		}
 		clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 	   	remove_wait_queue(&dev_priv->buf_queue, &entry);
 		if (return_null) return NULL;
 	}
@@ -446,7 +446,7 @@
    	if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) {
 	   	add_wait_queue(&dev_priv->wait_queue, &entry);
 	   	for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 		   	mga_dma_schedule(dev, 0);
 		   	if(!test_and_set_bit(MGA_BUF_IN_USE,
 					     &prim_buffer->buffer_status))
@@ -459,7 +459,7 @@
 			   	break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 	   	remove_wait_queue(&dev_priv->wait_queue, &entry);
 	   	if(ret) return ret;
 	}
@@ -894,7 +894,7 @@
 		set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
 		mga_dma_schedule(dev, 0);
    		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 	   		if (!test_bit(MGA_IN_FLUSH,
 				      &dev_priv->dispatch_status))
 				break;
@@ -907,7 +907,7 @@
 		   		break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
    		remove_wait_queue(&dev_priv->flush_queue, &entry);
 	}
    	return ret;
@@ -967,7 +967,7 @@
 	if (!ret) {
 		add_wait_queue(&dev->lock.lock_queue, &entry);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!dev->lock.hw_lock) {
 				/* Device has been unregistered */
 				ret = -EINTR;
@@ -989,7 +989,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&dev->lock.lock_queue, &entry);
 	}
 
drivers/char/drm-4.0/mga_drv.c +2 -2
diff -Nru a/drivers/char/drm-4.0/mga_drv.c b/drivers/char/drm-4.0/mga_drv.c
@@ -523,7 +523,7 @@
 	   	DECLARE_WAITQUEUE(entry, current);
 	   	add_wait_queue(&dev->lock.lock_queue, &entry);
 		for (;;) {
-			current->state = TASK_INTERRUPTIBLE;
+			set_current_state(TASK_INTERRUPTIBLE);
 			if (!dev->lock.hw_lock) {
 				/* Device has been unregistered */
 				retcode = -EINTR;
@@ -544,7 +544,7 @@
 				break;
 			}
 		}
-		current->state = TASK_RUNNING;
+		set_current_state(TASK_RUNNING);
 		remove_wait_queue(&dev->lock.lock_queue, &entry);
 	   	if(!retcode) {
 		   	mga_reclaim_buffers(dev, priv->pid);
drivers/char/drm-4.0/r128_drv.c +2 -2
diff -Nru a/drivers/char/drm-4.0/r128_drv.c b/drivers/char/drm-4.0/r128_drv.c
@@ -595,7 +595,7 @@
         if (!ret) {
                 add_wait_queue(&dev->lock.lock_queue, &entry);
                 for (;;) {
-                        current->state = TASK_INTERRUPTIBLE;
+                        set_current_state(TASK_INTERRUPTIBLE);
                         if (!dev->lock.hw_lock) {
                                 /* Device has been unregistered */
                                 ret = -EINTR;
@@ -617,7 +617,7 @@
                                 break;
                         }
                 }
-                current->state = TASK_RUNNING;
+                set_current_state(TASK_RUNNING);
                 remove_wait_queue(&dev->lock.lock_queue, &entry);
         }
 
drivers/char/drm-4.0/radeon_drv.c +2 -2
diff -Nru a/drivers/char/drm-4.0/radeon_drv.c b/drivers/char/drm-4.0/radeon_drv.c
@@ -598,7 +598,7 @@
         if (!ret) {
                 add_wait_queue(&dev->lock.lock_queue, &entry);
                 for (;;) {
-                        current->state = TASK_INTERRUPTIBLE;
+                        set_current_state(TASK_INTERRUPTIBLE);
                         if (!dev->lock.hw_lock) {
                                 /* Device has been unregistered */
                                 ret = -EINTR;
@@ -620,7 +620,7 @@
                                 break;
                         }
                 }
-                current->state = TASK_RUNNING;
+                set_current_state(TASK_RUNNING);
                 remove_wait_queue(&dev->lock.lock_queue, &entry);
         }
 
drivers/char/drm-4.0/tdfx_drv.c +5 -5
diff -Nru a/drivers/char/drm-4.0/tdfx_drv.c b/drivers/char/drm-4.0/tdfx_drv.c
@@ -553,7 +553,7 @@
                                 DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n",
 					lock.context, current->pid, j,
 					dev->lock.lock_time, jiffies);
-                                current->state = TASK_INTERRUPTIBLE;
+                                set_current_state(TASK_INTERRUPTIBLE);
 				current->policy |= SCHED_YIELD;
                                 schedule_timeout(DRM_LOCK_SLICE-j);
 				DRM_DEBUG("jiffies=%d\n", jiffies);
@@ -562,7 +562,7 @@
 #endif
                 add_wait_queue(&dev->lock.lock_queue, &entry);
                 for (;;) {
-                        current->state = TASK_INTERRUPTIBLE;
+                        set_current_state(TASK_INTERRUPTIBLE);
                         if (!dev->lock.hw_lock) {
                                 /* Device has been unregistered */
                                 ret = -EINTR;
@@ -587,7 +587,7 @@
                                 break;
                         }
                 }
-                current->state = TASK_RUNNING;
+                set_current_state(TASK_RUNNING);
                 remove_wait_queue(&dev->lock.lock_queue, &entry);
         }
 
@@ -596,7 +596,7 @@
 		lock.context != tdfx_res_ctx.handle &&
 		dev->last_context != tdfx_res_ctx.handle) {
 		add_wait_queue(&dev->context_wait, &entry);
-	        current->state = TASK_INTERRUPTIBLE;
+	        set_current_state(TASK_INTERRUPTIBLE);
                 /* PRE: dev->last_context != lock.context */
 	        tdfx_context_switch(dev, dev->last_context, lock.context);
 		/* POST: we will wait for the context
@@ -606,7 +606,7 @@
                    TIME! */
 		current->policy |= SCHED_YIELD;
 	        schedule();
-	        current->state = TASK_RUNNING;
+	        set_current_state(TASK_RUNNING);
 	        remove_wait_queue(&dev->context_wait, &entry);
 	        if (signal_pending(current)) {
 	                ret = -EINTR;
Signature · 2 lines
Paul P 'Stingray' Komkoff 'Greatest' Jr // (icq)23200764 // (irc)Spacebar
  PPKJ1-RIPE // (smtp)[email protected] // (http)stingr.net // (pgp)0xA4B4ECA4
#1 lore raw
Quoted 2 lines · Paul P Komkoff Jr

This is the pilot of task->state cleanup in 2.4.x. Feel free to blame me for incorrect use of set_task_state vs. __set_task_state

Nice cleanup. Awful lot of [items] in the subject though :)

You don't have to worry about your choices wrt set_current_state vs __set_current_state - by using only set_current_state you erred on the side of caution. set_current_state enforces a memory barrier around the write on SMP (on UP it is the same code) while __set_current_state does not.

If anyone can verify where it is safe in this code to use __set_current_state instead, speak up so Paul can make the micro optimization accordingly.

Robert Love

#2 lore raw
In reply to Paul P Komkoff Jr
Quoted 3 lines · Robert Love

If anyone can verify where it is safe in this code to use __set_current_state instead, speak up so Paul can make the micro optimization accordingly.

Ugh, please don't. There is enough mystery as to which one is safe to use when already.

Is there really a circumstance where avoiding the mb makes a noticable difference (in driver code, core code is something else ...) ?

john

Signature · 3 lines
"I never understood what's so hard about picking a unique
 first and last name - and not going beyond the 6 character limit."
 	- Toon Moene