Skip to contentSkip to conversation

sched: Use SCHED_WARN_ON() instead of WARN_ON_ONCE() with CONFIG_SCHED_DEBUG

PATCH In review Yue Hu 2 participants 2 messages Feb 3, 2021 – Feb 9, 2021 Scheduler

lore
Share & tools
lore

Yue Hu

author
#0 lore raw

PATCH 1/1 sched: Use SCHED_WARN_ON() instead of WARN_ON_ONCE() with CONFIG_SCHED_DEBUG

From: Yue Hu <[email protected]>

Since SCHED_WARN_ON() is provided as a wrapper for WARN_ON_ONCE().

---
 kernel/sched/core.c | 2 +-
 kernel/sched/rt.c   | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
kernel/sched/core.c +1 -1
index 8c54810..8f1f345 100644
@@ -5347,7 +5347,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void)
 int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags,
 			  void *key)
 {
-	WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~WF_SYNC);
+	SCHED_WARN_ON(wake_flags & ~WF_SYNC);
 	return try_to_wake_up(curr->private, mode, wake_flags);
 }
 EXPORT_SYMBOL(default_wake_function);
kernel/sched/rt.c +1 -3
index 8f720b7..a90eab3 100644
@@ -114,9 +114,7 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)
 
 static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se)
 {
-#ifdef CONFIG_SCHED_DEBUG
-	WARN_ON_ONCE(!rt_entity_is_task(rt_se));
-#endif
+	SCHED_WARN_ON(!rt_entity_is_task(rt_se));
 	return container_of(rt_se, struct task_struct, rt);
 }
 
Signature · 1 line
1.9.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Wed, 3 Feb 2021 17:50:12 +0800 Yue Hu <[email protected]> wrote:

From: Yue Hu <[email protected]>

Since SCHED_WARN_ON() is provided as a wrapper for WARN_ON_ONCE().

Peter, care to take this?

Also, looks like we can get rid of the #ifdef CONFIG_SCHED_DEBUG in set_task_cpu() by replacing all the WARN_ON_ONCE() with SCHED_WARN_ON().

-- Steve

Quoted 35 lines
---
 kernel/sched/core.c | 2 +-
 kernel/sched/rt.c   | 4 +---
 2 files changed, 2 insertions(+), 4 deletions(-)
kernel/sched/core.c +1 -1
index 8c54810..8f1f345 100644
@@ -5347,7 +5347,7 @@ asmlinkage __visible void __sched preempt_schedule_irq(void)
 int default_wake_function(wait_queue_entry_t *curr, unsigned mode, int wake_flags,
 			  void *key)
 {
-	WARN_ON_ONCE(IS_ENABLED(CONFIG_SCHED_DEBUG) && wake_flags & ~WF_SYNC);
+	SCHED_WARN_ON(wake_flags & ~WF_SYNC);
 	return try_to_wake_up(curr->private, mode, wake_flags);
 }
 EXPORT_SYMBOL(default_wake_function);
kernel/sched/rt.c +1 -3
index 8f720b7..a90eab3 100644
@@ -114,9 +114,7 @@ static void destroy_rt_bandwidth(struct rt_bandwidth *rt_b)
 
 static inline struct task_struct *rt_task_of(struct sched_rt_entity *rt_se)
 {
-#ifdef CONFIG_SCHED_DEBUG
-	WARN_ON_ONCE(!rt_entity_is_task(rt_se));
-#endif
+	SCHED_WARN_ON(!rt_entity_is_task(rt_se));
 	return container_of(rt_se, struct task_struct, rt);
 }