sched: Kill unnecessary check in sched_pre_select().
authorAndre Noll <maan@systemlinux.org>
Thu, 21 Jul 2011 17:39:03 +0000 (19:39 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 30 Jul 2011 18:27:55 +0000 (20:27 +0200)
The only two callers of sched_shutdown() call this function
from post_select context, so we may safely remove the check
whether the pre_select list is empty.

Add a comment to sched_shutdown() which mentions that this
function must be called from post_select.

sched.c

diff --git a/sched.c b/sched.c
index 8648811..7b5ca63 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -52,18 +52,8 @@ static void sched_preselect(struct sched *s)
        list_for_each_entry_safe(t, tmp, &pre_select_list, pre_select_node) {
                if (t->pre_select)
                        t->pre_select(s, t);
-//             PARA_INFO_LOG("%s \n", t->status);
-               if (t->error >= 0)
-                       continue;
-               /*
-                * We have to check whether the list is empty because the call
-                * to ->pre_select() might have called sched_shutdown(). In
-                * this case t has been unregistered already, so we must not
-                * unregister it again.
-                */
-               if (list_empty(&pre_select_list))
-                       return;
-               unregister_task(t);
+               if (t->error < 0)
+                       unregister_task(t);
        }
 }
 
@@ -97,7 +87,12 @@ static void sched_post_select(struct sched *s)
 //             PARA_INFO_LOG("%s: %d\n", t->status, t->ret);
                if (t->error >= 0)
                        continue;
-               /* nec., see sched_preselect() */
+               /*
+                * We have to check whether the list is empty because the call
+                * to ->post_select() might have called sched_shutdown(). In
+                * this case t has been unregistered already, so we must not
+                * unregister it again.
+                */
                if (list_empty(&post_select_list))
                        return;
                unregister_task(t);
@@ -197,7 +192,8 @@ void register_task(struct task *t)
  * Unregister all tasks.
  *
  * This will cause \a schedule() to return immediately because both the
- * \a pre_select_list and the \a post_select_list are empty.
+ * \a pre_select_list and the \a post_select_list are empty. This function
+ * must be called from the post_select (rather than the pre_select) method.
  */
 void sched_shutdown(void)
 {