Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sched/headers: Move idle polling methods to <linux/sched/idle.h>

Further reduce the size of <linux/sched.h> by moving these APIs:

tsk_is_polling()
__current_set_polling()
current_set_polling_and_test()
__current_clr_polling()
current_clr_polling_and_test()
current_clr_polling()

Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

+76 -76
-76
include/linux/sched.h
··· 3176 3176 #endif 3177 3177 } 3178 3178 3179 - /* 3180 - * Idle thread specific functions to determine the need_resched 3181 - * polling state. 3182 - */ 3183 - #ifdef TIF_POLLING_NRFLAG 3184 - static inline int tsk_is_polling(struct task_struct *p) 3185 - { 3186 - return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); 3187 - } 3188 - 3189 - static inline void __current_set_polling(void) 3190 - { 3191 - set_thread_flag(TIF_POLLING_NRFLAG); 3192 - } 3193 - 3194 - static inline bool __must_check current_set_polling_and_test(void) 3195 - { 3196 - __current_set_polling(); 3197 - 3198 - /* 3199 - * Polling state must be visible before we test NEED_RESCHED, 3200 - * paired by resched_curr() 3201 - */ 3202 - smp_mb__after_atomic(); 3203 - 3204 - return unlikely(tif_need_resched()); 3205 - } 3206 - 3207 - static inline void __current_clr_polling(void) 3208 - { 3209 - clear_thread_flag(TIF_POLLING_NRFLAG); 3210 - } 3211 - 3212 - static inline bool __must_check current_clr_polling_and_test(void) 3213 - { 3214 - __current_clr_polling(); 3215 - 3216 - /* 3217 - * Polling state must be visible before we test NEED_RESCHED, 3218 - * paired by resched_curr() 3219 - */ 3220 - smp_mb__after_atomic(); 3221 - 3222 - return unlikely(tif_need_resched()); 3223 - } 3224 - 3225 - #else 3226 - static inline int tsk_is_polling(struct task_struct *p) { return 0; } 3227 - static inline void __current_set_polling(void) { } 3228 - static inline void __current_clr_polling(void) { } 3229 - 3230 - static inline bool __must_check current_set_polling_and_test(void) 3231 - { 3232 - return unlikely(tif_need_resched()); 3233 - } 3234 - static inline bool __must_check current_clr_polling_and_test(void) 3235 - { 3236 - return unlikely(tif_need_resched()); 3237 - } 3238 - #endif 3239 - 3240 - static inline void current_clr_polling(void) 3241 - { 3242 - __current_clr_polling(); 3243 - 3244 - /* 3245 - * Ensure we check TIF_NEED_RESCHED after we clear the polling bit. 3246 - * Once the bit is cleared, we'll get IPIs with every new 3247 - * TIF_NEED_RESCHED and the IPI handler, scheduler_ipi(), will also 3248 - * fold. 3249 - */ 3250 - smp_mb(); /* paired with resched_curr() */ 3251 - 3252 - preempt_fold_need_resched(); 3253 - } 3254 - 3255 3179 static __always_inline bool need_resched(void) 3256 3180 { 3257 3181 return unlikely(tif_need_resched());
+76
include/linux/sched/idle.h
··· 12 12 13 13 extern void wake_up_if_idle(int cpu); 14 14 15 + /* 16 + * Idle thread specific functions to determine the need_resched 17 + * polling state. 18 + */ 19 + #ifdef TIF_POLLING_NRFLAG 20 + static inline int tsk_is_polling(struct task_struct *p) 21 + { 22 + return test_tsk_thread_flag(p, TIF_POLLING_NRFLAG); 23 + } 24 + 25 + static inline void __current_set_polling(void) 26 + { 27 + set_thread_flag(TIF_POLLING_NRFLAG); 28 + } 29 + 30 + static inline bool __must_check current_set_polling_and_test(void) 31 + { 32 + __current_set_polling(); 33 + 34 + /* 35 + * Polling state must be visible before we test NEED_RESCHED, 36 + * paired by resched_curr() 37 + */ 38 + smp_mb__after_atomic(); 39 + 40 + return unlikely(tif_need_resched()); 41 + } 42 + 43 + static inline void __current_clr_polling(void) 44 + { 45 + clear_thread_flag(TIF_POLLING_NRFLAG); 46 + } 47 + 48 + static inline bool __must_check current_clr_polling_and_test(void) 49 + { 50 + __current_clr_polling(); 51 + 52 + /* 53 + * Polling state must be visible before we test NEED_RESCHED, 54 + * paired by resched_curr() 55 + */ 56 + smp_mb__after_atomic(); 57 + 58 + return unlikely(tif_need_resched()); 59 + } 60 + 61 + #else 62 + static inline int tsk_is_polling(struct task_struct *p) { return 0; } 63 + static inline void __current_set_polling(void) { } 64 + static inline void __current_clr_polling(void) { } 65 + 66 + static inline bool __must_check current_set_polling_and_test(void) 67 + { 68 + return unlikely(tif_need_resched()); 69 + } 70 + static inline bool __must_check current_clr_polling_and_test(void) 71 + { 72 + return unlikely(tif_need_resched()); 73 + } 74 + #endif 75 + 76 + static inline void current_clr_polling(void) 77 + { 78 + __current_clr_polling(); 79 + 80 + /* 81 + * Ensure we check TIF_NEED_RESCHED after we clear the polling bit. 82 + * Once the bit is cleared, we'll get IPIs with every new 83 + * TIF_NEED_RESCHED and the IPI handler, scheduler_ipi(), will also 84 + * fold. 85 + */ 86 + smp_mb(); /* paired with resched_curr() */ 87 + 88 + preempt_fold_need_resched(); 89 + } 90 + 15 91 #endif /* _LINUX_SCHED_IDLE_H */