Skip to content

Commit 35a773a

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/core: Avoid _cond_resched() for PREEMPT=y
On fully preemptible kernels _cond_resched() is pointless, so avoid emitting any code for it. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mikulas Patocka <[email protected]> Cc: Oleg Nesterov <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 9af6528 commit 35a773a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/linux/sched.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,11 @@ static inline int signal_pending_state(long state, struct task_struct *p)
32093209
* cond_resched_lock() will drop the spinlock before scheduling,
32103210
* cond_resched_softirq() will enable bhs before scheduling.
32113211
*/
3212+
#ifndef CONFIG_PREEMPT
32123213
extern int _cond_resched(void);
3214+
#else
3215+
static inline int _cond_resched(void) { return 0; }
3216+
#endif
32133217

32143218
#define cond_resched() ({ \
32153219
___might_sleep(__FILE__, __LINE__, 0); \

kernel/sched/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,6 +4883,7 @@ SYSCALL_DEFINE0(sched_yield)
48834883
return 0;
48844884
}
48854885

4886+
#ifndef CONFIG_PREEMPT
48864887
int __sched _cond_resched(void)
48874888
{
48884889
if (should_resched(0)) {
@@ -4892,6 +4893,7 @@ int __sched _cond_resched(void)
48924893
return 0;
48934894
}
48944895
EXPORT_SYMBOL(_cond_resched);
4896+
#endif
48954897

48964898
/*
48974899
* __cond_resched_lock() - if a reschedule is pending, drop the given lock,

0 commit comments

Comments
 (0)