Re: [PATCH] kernel <linux-2.6.11.10> kernel/sched.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



much better.
If so, another place, activate_task(), need to make adjustment as well.

-chen

/* ============================ */
 /*
@@ -704,7 +704,7 @@
 	}
 #endif
 
-	recalc_task_prio(p, now);
+	p->prio = recalc_task_prio(p, now);

/* ============================ */

On 5/23/05, Ingo Molnar <[email protected]> wrote:
> 
> the real problem comes from recalc_task_prio() having a side-effect,
> which makes requeueing of tasks harder. The solution is to return the
> prio from recalc_task_prio() - see the tested patch below. Agreed?
> 
>         Ingo
> 
> --
> 
> micro-optimize task requeueing in schedule() & clean up
> recalc_task_prio().
> 
> --- linux/kernel/sched.c.orig
> +++ linux/kernel/sched.c
> @@ -675,7 +675,7 @@ static inline void __activate_idle_task(
>         rq->nr_running++;
>  }
> 
> -static void recalc_task_prio(task_t *p, unsigned long long now)
> +static int recalc_task_prio(task_t *p, unsigned long long now)
>  {
>         /* Caller must always ensure 'now >= p->timestamp' */
>         unsigned long long __sleep_time = now - p->timestamp;
> @@ -734,7 +734,7 @@ static void recalc_task_prio(task_t *p,
>                 }
>         }
> 
> -       p->prio = effective_prio(p);
> +       return effective_prio(p);
>  }
> 
>  /*
> @@ -757,7 +757,7 @@ static void activate_task(task_t *p, run
>         }
>  #endif
> 
> -       recalc_task_prio(p, now);
> +       p->prio = recalc_task_prio(p, now);
> 
>         /*
>          * This checks to make sure it's not an uninterruptible task
> @@ -2751,7 +2751,7 @@ asmlinkage void __sched schedule(void)
>         struct list_head *queue;
>         unsigned long long now;
>         unsigned long run_time;
> -       int cpu, idx;
> +       int cpu, idx, new_prio;
> 
>         /*
>          * Test if we are atomic.  Since do_exit() needs to call into
> @@ -2873,9 +2873,14 @@ go_idle:
>                         delta = delta * (ON_RUNQUEUE_WEIGHT * 128 / 100) / 128;
> 
>                 array = next->array;
> -               dequeue_task(next, array);
> -               recalc_task_prio(next, next->timestamp + delta);
> -               enqueue_task(next, array);
> +               new_prio = recalc_task_prio(next, next->timestamp + delta);
> +
> +               if (unlikely(next->prio != new_prio)) {
> +                       dequeue_task(next, array);
> +                       next->prio = new_prio;
> +                       enqueue_task(next, array);
> +               } else
> +                       requeue_task(next, array);
>         }
>         next->activated = 0;
>  switch_tasks:
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux