Commit 87dcbc06 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched/core: Simplify INIT_PREEMPT_COUNT

As per the following commit:

  d86ee480 ("sched: optimize cond_resched()")

we need PREEMPT_ACTIVE to avoid cond_resched() from working before
the scheduler is set up.

However, keeping preemption disabled should do the same thing
already, making the PREEMPT_ACTIVE part entirely redundant.

The only complication is !PREEMPT_COUNT kernels, where
PREEMPT_DISABLED ends up being 0. Instead we use an unconditional
PREEMPT_OFFSET to set preempt_count() even on !PREEMPT_COUNT
kernels.
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent fe191592
...@@ -606,19 +606,18 @@ struct task_cputime_atomic { ...@@ -606,19 +606,18 @@ struct task_cputime_atomic {
#endif #endif
/* /*
* Disable preemption until the scheduler is running. * Disable preemption until the scheduler is running -- use an unconditional
* Reset by start_kernel()->sched_init()->init_idle(). * value so that it also works on !PREEMPT_COUNT kernels.
* *
* We include PREEMPT_ACTIVE to avoid cond_resched() from working * Reset by start_kernel()->sched_init()->init_idle()->init_idle_preempt_count().
* before the scheduler is active -- see should_resched().
*/ */
#define INIT_PREEMPT_COUNT (PREEMPT_DISABLED + PREEMPT_ACTIVE) #define INIT_PREEMPT_COUNT PREEMPT_OFFSET
/** /**
* struct thread_group_cputimer - thread group interval timer counts * struct thread_group_cputimer - thread group interval timer counts
* @cputime_atomic: atomic thread group interval timers. * @cputime_atomic: atomic thread group interval timers.
* @running: non-zero when there are timers running and * @running: non-zero when there are timers running and
* @cputime receives updates. * @cputime receives updates.
* *
* This structure contains the version of task_cputime, above, that is * This structure contains the version of task_cputime, above, that is
* used for thread group CPU timer calculations. * used for thread group CPU timer calculations.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment