Skip to content

Commit f0dc887

Browse files
sean-jcPeter Zijlstra
authored andcommitted
sched/core: Move preempt_model_*() helpers from sched.h to preempt.h
Move the declarations and inlined implementations of the preempt_model_*() helpers to preempt.h so that they can be referenced in spinlock.h without creating a potential circular dependency between spinlock.h and sched.h. No functional change intended. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Ankur Arora <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent f90cc91 commit f0dc887

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

include/linux/preempt.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,45 @@ DEFINE_LOCK_GUARD_0(preempt, preempt_disable(), preempt_enable())
481481
DEFINE_LOCK_GUARD_0(preempt_notrace, preempt_disable_notrace(), preempt_enable_notrace())
482482
DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable())
483483

484+
#ifdef CONFIG_PREEMPT_DYNAMIC
485+
486+
extern bool preempt_model_none(void);
487+
extern bool preempt_model_voluntary(void);
488+
extern bool preempt_model_full(void);
489+
490+
#else
491+
492+
static inline bool preempt_model_none(void)
493+
{
494+
return IS_ENABLED(CONFIG_PREEMPT_NONE);
495+
}
496+
static inline bool preempt_model_voluntary(void)
497+
{
498+
return IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY);
499+
}
500+
static inline bool preempt_model_full(void)
501+
{
502+
return IS_ENABLED(CONFIG_PREEMPT);
503+
}
504+
505+
#endif
506+
507+
static inline bool preempt_model_rt(void)
508+
{
509+
return IS_ENABLED(CONFIG_PREEMPT_RT);
510+
}
511+
512+
/*
513+
* Does the preemption model allow non-cooperative preemption?
514+
*
515+
* For !CONFIG_PREEMPT_DYNAMIC kernels this is an exact match with
516+
* CONFIG_PREEMPTION; for CONFIG_PREEMPT_DYNAMIC this doesn't work as the
517+
* kernel is *built* with CONFIG_PREEMPTION=y but may run with e.g. the
518+
* PREEMPT_NONE model.
519+
*/
520+
static inline bool preempt_model_preemptible(void)
521+
{
522+
return preempt_model_full() || preempt_model_rt();
523+
}
524+
484525
#endif /* __LINUX_PREEMPT_H */

include/linux/sched.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,47 +2064,6 @@ extern int __cond_resched_rwlock_write(rwlock_t *lock);
20642064
__cond_resched_rwlock_write(lock); \
20652065
})
20662066

2067-
#ifdef CONFIG_PREEMPT_DYNAMIC
2068-
2069-
extern bool preempt_model_none(void);
2070-
extern bool preempt_model_voluntary(void);
2071-
extern bool preempt_model_full(void);
2072-
2073-
#else
2074-
2075-
static inline bool preempt_model_none(void)
2076-
{
2077-
return IS_ENABLED(CONFIG_PREEMPT_NONE);
2078-
}
2079-
static inline bool preempt_model_voluntary(void)
2080-
{
2081-
return IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY);
2082-
}
2083-
static inline bool preempt_model_full(void)
2084-
{
2085-
return IS_ENABLED(CONFIG_PREEMPT);
2086-
}
2087-
2088-
#endif
2089-
2090-
static inline bool preempt_model_rt(void)
2091-
{
2092-
return IS_ENABLED(CONFIG_PREEMPT_RT);
2093-
}
2094-
2095-
/*
2096-
* Does the preemption model allow non-cooperative preemption?
2097-
*
2098-
* For !CONFIG_PREEMPT_DYNAMIC kernels this is an exact match with
2099-
* CONFIG_PREEMPTION; for CONFIG_PREEMPT_DYNAMIC this doesn't work as the
2100-
* kernel is *built* with CONFIG_PREEMPTION=y but may run with e.g. the
2101-
* PREEMPT_NONE model.
2102-
*/
2103-
static inline bool preempt_model_preemptible(void)
2104-
{
2105-
return preempt_model_full() || preempt_model_rt();
2106-
}
2107-
21082067
static __always_inline bool need_resched(void)
21092068
{
21102069
return unlikely(tif_need_resched());

0 commit comments

Comments
 (0)