[RFC][PATCH][CLEANUP] task->state cleanup: pilot

[RFC][PATCH][CLEANUP] task->state cleanup: pilot

Post by Paul P Komkoff J » Mon, 08 Apr 2002 07:30:22



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      sting...@stingr.net    1.311
# task->state cleanup part 1
# --------------------------------------------
#
diff -Nru a/drivers/char/drm/drm_dma.h b/drivers/char/drm/drm_dma.h
--- a/drivers/char/drm/drm_dma.h        Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/drm_dma.h        Sun Apr  7 02:02:35 2002
@@ -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);
        }

diff -Nru a/drivers/char/drm/drm_drv.h b/drivers/char/drm/drm_drv.h
--- a/drivers/char/drm/drm_drv.h        Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/drm_drv.h        Sun Apr  7 02:02:35 2002
@@ -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 );
         }

diff -Nru a/drivers/char/drm/drm_lists.h b/drivers/char/drm/drm_lists.h
--- a/drivers/char/drm/drm_lists.h      Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/drm_lists.h      Sun Apr  7 02:02:35 2002
@@ -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;
diff -Nru a/drivers/char/drm/drm_lock.h b/drivers/char/drm/drm_lock.h
--- a/drivers/char/drm/drm_lock.h       Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/drm_lock.h       Sun Apr  7 02:02:35 2002
@@ -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);
diff -Nru a/drivers/char/drm/gamma_dma.c b/drivers/char/drm/gamma_dma.c
--- a/drivers/char/drm/gamma_dma.c      Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/gamma_dma.c      Sun Apr  7 02:02:35 2002
@@ -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
diff -Nru a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
--- a/drivers/char/drm/i810_dma.c       Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm/i810_dma.c       Sun Apr  7 02:02:35 2002
@@ -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);

diff -Nru a/drivers/char/drm-4.0/dma.c b/drivers/char/drm-4.0/dma.c
--- a/drivers/char/drm-4.0/dma.c        Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm-4.0/dma.c        Sun Apr  7 02:02:35 2002
@@ -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);
        }

diff -Nru a/drivers/char/drm-4.0/ffb_drv.c b/drivers/char/drm-4.0/ffb_drv.c
--- a/drivers/char/drm-4.0/ffb_drv.c    Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm-4.0/ffb_drv.c    Sun Apr  7 02:02:35 2002
@@ -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) {
diff -Nru a/drivers/char/drm-4.0/gamma_dma.c b/drivers/char/drm-4.0/gamma_dma.c
--- a/drivers/char/drm-4.0/gamma_dma.c  Sun Apr  7 02:02:35 2002
+++ b/drivers/char/drm-4.0/gamma_dma.c  Sun Apr  7 02:02:35 2002
@@ -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);
...

read more »

 
 
 

[RFC][PATCH][CLEANUP] task->state cleanup: pilot

Post by Robert Lov » Mon, 08 Apr 2002 08:50:07



Quote:> 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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

[RFC][PATCH][CLEANUP] task->state cleanup: pilot

Post by John Levo » Mon, 08 Apr 2002 20:10:08



> 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

--
"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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/