Skip to content

Commit

Permalink
sched/rt: Add schedule_preempt_disabled()
Browse files Browse the repository at this point in the history
Add helper to get rid of the ever repeating:

    preempt_enable_no_resched();
    schedule();
    preempt_disable();

patterns.

Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
KAGA-KOKO authored and Ingo Molnar committed Mar 1, 2012

Verified

This commit was signed with the committer’s verified signature.
jorenham Joren Hammudoglu
1 parent 7abc63b commit c5491ea
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/sched.h
Original file line number Diff line number Diff line change
@@ -361,6 +361,7 @@ extern signed long schedule_timeout_interruptible(signed long timeout);
extern signed long schedule_timeout_killable(signed long timeout);
extern signed long schedule_timeout_uninterruptible(signed long timeout);
asmlinkage void schedule(void);
extern void schedule_preempt_disabled(void);
extern int mutex_spin_on_owner(struct mutex *lock, struct task_struct *owner);

struct nsproxy;
12 changes: 12 additions & 0 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
@@ -3246,6 +3246,18 @@ asmlinkage void __sched schedule(void)
}
EXPORT_SYMBOL(schedule);

/**
* schedule_preempt_disabled - called with preemption disabled
*
* Returns with preemption disabled. Note: preempt_count must be 1
*/
void __sched schedule_preempt_disabled(void)
{
preempt_enable_no_resched();
schedule();
preempt_disable();
}

#ifdef CONFIG_MUTEX_SPIN_ON_OWNER

static inline bool owner_running(struct mutex *lock, struct task_struct *owner)

0 comments on commit c5491ea

Please sign in to comment.