Skip to content

Commit

Permalink
sched: do not do cond_resched() when CONFIG_PREEMPT
Browse files Browse the repository at this point in the history
Why do we even have cond_resched when real preemption
is on? It seems to be a waste of space and time.

remove cond_resched with CONFIG_PREEMPT on.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Herbert Xu authored and Ingo Molnar committed Jan 25, 2008
1 parent 03319ec commit 02b67cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ struct user;
* supposed to.
*/
#ifdef CONFIG_PREEMPT_VOLUNTARY
extern int cond_resched(void);
# define might_resched() cond_resched()
extern int _cond_resched(void);
# define might_resched() _cond_resched()
#else
# define might_resched() do { } while (0)
#endif
Expand Down
13 changes: 12 additions & 1 deletion include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1885,7 +1885,18 @@ static inline int need_resched(void)
* cond_resched_lock() will drop the spinlock before scheduling,
* cond_resched_softirq() will enable bhs before scheduling.
*/
extern int cond_resched(void);
#ifdef CONFIG_PREEMPT
static inline int cond_resched(void)
{
return 0;
}
#else
extern int _cond_resched(void);
static inline int cond_resched(void)
{
return _cond_resched();
}
#endif
extern int cond_resched_lock(spinlock_t * lock);
extern int cond_resched_softirq(void);

Expand Down
6 changes: 4 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -4678,7 +4678,8 @@ static void __cond_resched(void)
} while (need_resched());
}

int __sched cond_resched(void)
#if !defined(CONFIG_PREEMPT) || defined(CONFIG_PREEMPT_VOLUNTARY)
int __sched _cond_resched(void)
{
if (need_resched() && !(preempt_count() & PREEMPT_ACTIVE) &&
system_state == SYSTEM_RUNNING) {
Expand All @@ -4687,7 +4688,8 @@ int __sched cond_resched(void)
}
return 0;
}
EXPORT_SYMBOL(cond_resched);
EXPORT_SYMBOL(_cond_resched);
#endif

/*
* cond_resched_lock() - if a reschedule is pending, drop the given lock,
Expand Down

0 comments on commit 02b67cc

Please sign in to comment.