Use __set_current_state() instead of current->state = (take 1)

Use __set_current_state() instead of current->state = (take 1)

Post by Inaky Perez-Gonzale » Fri, 20 Dec 2002 02:10:08



Hi all

In fs/*.c, many functions manually set the task state directly
accessing current->state, or with a macro, kind of
inconsistently. This patch changes all of them to use
[__]set_current_state().

Changelog:

- Ported forward to 2.5.52

diff -u fs/dquot.c:1.1.1.4 fs/dquot.c:1.1.1.1.6.2
--- fs/dquot.c:1.1.1.4  Wed Dec 11 11:13:35 2002

                goto repeat;
        }
        remove_wait_queue(&dquot->dq_wait_lock, &wait);
-       current->state = TASK_RUNNING;
+       __set_current_state(TASK_RUNNING);
 }


                goto repeat;
        }
        remove_wait_queue(&dquot->dq_wait_free, &wait);
-       current->state = TASK_RUNNING;
+       __set_current_state(TASK_RUNNING);
 }


                goto repeat;
        }
        remove_wait_queue(&dquot->dq_wait_free, &wait);
-       current->state = TASK_RUNNING;
+       __set_current_state(TASK_RUNNING);
 }

 static int read_dqblk(struct dquot *dquot)
diff -u fs/exec.c:1.1.1.8 fs/exec.c:1.1.1.1.6.2
--- fs/exec.c:1.1.1.8   Mon Dec 16 18:44:31 2002

                count = 1;
        while (atomic_read(&oldsig->count) > count) {
                oldsig->group_exit_task = current;
-               current->state = TASK_UNINTERRUPTIBLE;
+               __set_current_state(TASK_UNINTERRUPTIBLE);
                spin_unlock_irq(&oldsig->siglock);
                schedule();
                spin_lock_irq(&oldsig->siglock);
diff -u fs/inode.c:1.1.1.6 fs/inode.c:1.1.1.1.6.2
--- fs/inode.c:1.1.1.6  Mon Dec 16 18:44:31 2002

                goto repeat;
        }
        remove_wait_queue(wq, &wait);
-       current->state = TASK_RUNNING;
+       __set_current_state(TASK_RUNNING);
 }

 void wake_up_inode(struct inode *inode)
diff -u fs/locks.c:1.1.1.6 fs/locks.c:1.1.1.1.6.2
--- fs/locks.c:1.1.1.6  Wed Dec 11 11:13:35 2002

        int result = 0;
        DECLARE_WAITQUEUE(wait, current);

-       current->state = TASK_INTERRUPTIBLE;
+       __set_current_state (TASK_INTERRUPTIBLE);
        add_wait_queue(fl_wait, &wait);
        if (timeout == 0)

        if (signal_pending(current))
                result = -ERESTARTSYS;
        remove_wait_queue(fl_wait, &wait);
-       current->state = TASK_RUNNING;
+       __set_current_state (TASK_RUNNING);
        return result;
 }

diff -u fs/namei.c:1.1.1.6 fs/namei.c:1.1.1.1.6.2
--- fs/namei.c:1.1.1.6  Wed Dec 11 11:13:35 2002

        if (current->total_link_count >= 40)
                goto loop;
        if (need_resched()) {
-               current->state = TASK_RUNNING;
+               __set_current_state(TASK_RUNNING);
                schedule();
        }
        err = security_inode_follow_link(dentry, nd);
diff -u fs/select.c:1.1.1.3 fs/select.c:1.1.1.1.6.2
--- fs/select.c:1.1.1.3 Wed Dec 11 11:10:14 2002

                }
                __timeout = schedule_timeout(__timeout);
        }
-       current->state = TASK_RUNNING;
+       __set_current_state (TASK_RUNNING);

        poll_freewait(&table);

                        break;
                timeout = schedule_timeout(timeout);
        }
-       current->state = TASK_RUNNING;
+       __set_current_state (TASK_RUNNING);
        return count;
 }

--

Inaky Perez-Gonzalez -- Not speaking for Intel - opinions are my own [or my fault]
-
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/

 
 
 

Use __set_current_state() instead of current->state = (take 1)

Post by Robert Lov » Fri, 20 Dec 2002 02:20:09



> In fs/*.c, many functions manually set the task state directly
> accessing current->state, or with a macro, kind of
> inconsistently. This patch changes all of them to use
> [__]set_current_state().

Some of these should probably be set_current_state().  I realize the
current code is equivalent to __set_current_state() but it might as well
be done right.

> diff -u fs/locks.c:1.1.1.6 fs/locks.c:1.1.1.1.6.2
> --- fs/locks.c:1.1.1.6     Wed Dec 11 11:13:35 2002
> +++ fs/locks.c     Wed Dec 18 13:20:24 2002

>    int result = 0;
>    DECLARE_WAITQUEUE(wait, current);

> -  current->state = TASK_INTERRUPTIBLE;
> +  __set_current_state (TASK_INTERRUPTIBLE);
>    add_wait_queue(fl_wait, &wait);
>    if (timeout == 0)

At least this guy should be set_current_state(), on quick glance.

When in doubt just use set_current_state()..

        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/