Re: [PATCH/RFC] sched: Remove SYSTEM_RUNNING checks fromcond_resched*()

From: Oleg Nesterov
Date: Tue Jul 07 2009 - 20:53:39 EST


On 07/08, Anton Vorontsov wrote:
>
> but I'm curious if removing the checks makes sense
> nowadays.
...
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -6560,8 +6560,7 @@ static void __cond_resched(void)
>
> int __sched _cond_resched(void)
> {
> - if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) &&
> - system_state == SYSTEM_RUNNING) {
> + if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE)) {
> __cond_resched();
> return 1;
> }

and, with CONFIG_PREEMPT preempt_schedule() does not check system_state,
so it looks really strange cond_resched() does check SYSTEM_RUNNING.



debug_smp_processor_id() looks strange too:

/*
* It is valid to assume CPU-locality during early bootup:
*/
if (system_state != SYSTEM_RUNNING)
goto out;

this doesn't look right, smp_init() is called before we set
SYSTEM_RUNNING.

Hmm, and

/*
* Kernel threads bound to a single CPU can safely use
* smp_processor_id():
*/
if (cpumask_equal(&current->cpus_allowed, cpumask_of(this_cpu)))
goto out;

perhaps this should use PF_THREAD_BOUND ?

Oleg.

--
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/