Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 155174
b: refs/heads/master
c: d86ee48
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Linus Torvalds committed Jul 10, 2009
1 parent 4dfb860 commit 7bd1cd2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c99e6efe1ba04561e7d93a81f0be07e37427e835
refs/heads/master: d86ee4809d0329d4aa0d0f2c76c2295a16862799
5 changes: 4 additions & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,11 @@ struct task_cputime {
/*
* Disable preemption until the scheduler is running.
* Reset by start_kernel()->sched_init()->init_idle().
*
* We include PREEMPT_ACTIVE to avoid cond_resched() from working
* before the scheduler is active -- see should_resched().
*/
#define INIT_PREEMPT_COUNT (1)
#define INIT_PREEMPT_COUNT (1 + PREEMPT_ACTIVE)

/**
* struct thread_group_cputimer - thread group interval timer counts
Expand Down
14 changes: 9 additions & 5 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -6541,6 +6541,11 @@ SYSCALL_DEFINE0(sched_yield)
return 0;
}

static inline int should_resched(void)
{
return need_resched() && !(preempt_count() & PREEMPT_ACTIVE);
}

static void __cond_resched(void)
{
#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
Expand All @@ -6560,8 +6565,7 @@ static void __cond_resched(void)

int __sched _cond_resched(void)
{
if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) &&
system_state == SYSTEM_RUNNING) {
if (should_resched()) {
__cond_resched();
return 1;
}
Expand All @@ -6579,12 +6583,12 @@ EXPORT_SYMBOL(_cond_resched);
*/
int cond_resched_lock(spinlock_t *lock)
{
int resched = need_resched() && system_state == SYSTEM_RUNNING;
int resched = should_resched();
int ret = 0;

if (spin_needbreak(lock) || resched) {
spin_unlock(lock);
if (resched && need_resched())
if (resched)
__cond_resched();
else
cpu_relax();
Expand All @@ -6599,7 +6603,7 @@ int __sched cond_resched_softirq(void)
{
BUG_ON(!in_softirq());

if (need_resched() && system_state == SYSTEM_RUNNING) {
if (should_resched()) {
local_bh_enable();
__cond_resched();
local_bh_disable();
Expand Down

0 comments on commit 7bd1cd2

Please sign in to comment.