Re: [PATCH 2/2] sched: Pull resched loop to __schedule() callers

From: Linus Torvalds
Date: Sun Dec 14 2014 - 21:46:38 EST


On Sun, Dec 14, 2014 at 6:24 PM, Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:
> -need_resched:
> preempt_disable();
> cpu = smp_processor_id();
> rq = cpu_rq(cpu);
> @@ -2821,8 +2824,6 @@ need_resched:
> post_schedule(rq);
>
> sched_preempt_enable_no_resched();
> - if (need_resched())
> - goto need_resched;


So my suggestion was to move the
"preempt_disable()/enable_no_resched()" into the callers too.

Everybody already does that - except for "schedule()" itself. So that
would involve adding it here too:

> @@ -2842,7 +2843,9 @@ asmlinkage __visible void __sched schedule(void)
> struct task_struct *tsk = current;
>
> sched_submit_work(tsk);
> - __schedule();
> + do {
preempt_disable();
> + __schedule();
sched_preempt_enable_no_resched();
> + } while (need_resched());
> }

Hmm?

That would mean that we have one less preempt update in the
__sched_preempt() cases. If somebody cares about the preempt counter
value, we'd have to increemnt the preempt count add values too, ie do

__preempt_count_add(PREEMPT_ACTIVE+1);

there, but I'm not convicned anybody cares about the exact count.

As it is, you end up doing the preempt count things twice in the
__sched_preempt() case: first the PREEMPT_ACTIVE count, and then the
count inside __schedule().

Hmm?

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/