• P
    sched/core: Create preempt_count invariant · 609ca066
    Peter Zijlstra 提交于
    Assuming units of PREEMPT_DISABLE_OFFSET for preempt_count() numbers.
    
    Now that TASK_DEAD no longer results in preempt_count() == 3 during
    scheduling, we will always call context_switch() with preempt_count()
    == 2.
    
    However, we don't always end up with preempt_count() == 2 in
    finish_task_switch() because new tasks get created with
    preempt_count() == 1.
    
    Create FORK_PREEMPT_COUNT and set it to 2 and use that in the right
    places. Note that we cannot use INIT_PREEMPT_COUNT as that serves
    another purpose (boot).
    
    After this, preempt_count() is invariant across the context switch,
    with exception of PREEMPT_ACTIVE.
    Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: NIngo Molnar <mingo@kernel.org>
    609ca066
sched.h 90.9 KB