Skip to content

Commit 9148a3a

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
sched/debug: Add SCHED_WARN_ON()
Provide SCHED_WARN_ON as wrapper for WARN_ON_ONCE() to avoid CONFIG_SCHED_DEBUG wrappery. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: 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>
1 parent 49bd21e commit 9148a3a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

kernel/sched/fair.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,7 @@ static inline struct rq *rq_of(struct cfs_rq *cfs_rq)
262262

263263
static inline struct task_struct *task_of(struct sched_entity *se)
264264
{
265-
#ifdef CONFIG_SCHED_DEBUG
266-
WARN_ON_ONCE(!entity_is_task(se));
267-
#endif
265+
SCHED_WARN_ON(!entity_is_task(se));
268266
return container_of(se, struct task_struct, se);
269267
}
270268

@@ -2369,7 +2367,7 @@ void task_numa_work(struct callback_head *work)
23692367
unsigned long nr_pte_updates = 0;
23702368
long pages, virtpages;
23712369

2372-
WARN_ON_ONCE(p != container_of(work, struct task_struct, numa_work));
2370+
SCHED_WARN_ON(p != container_of(work, struct task_struct, numa_work));
23732371

23742372
work->next = work; /* protect against double add */
23752373
/*
@@ -4474,7 +4472,7 @@ static void hrtick_start_fair(struct rq *rq, struct task_struct *p)
44744472
struct sched_entity *se = &p->se;
44754473
struct cfs_rq *cfs_rq = cfs_rq_of(se);
44764474

4477-
WARN_ON(task_rq(p) != rq);
4475+
SCHED_WARN_ON(task_rq(p) != rq);
44784476

44794477
if (rq->cfs.h_nr_running > 1) {
44804478
u64 slice = sched_slice(cfs_rq, se);

kernel/sched/sched.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515
#include "cpudeadline.h"
1616
#include "cpuacct.h"
1717

18+
#ifdef CONFIG_SCHED_DEBUG
19+
#define SCHED_WARN_ON(x) WARN_ONCE(x, #x)
20+
#else
21+
#define SCHED_WARN_ON(x) ((void)(x))
22+
#endif
23+
1824
struct rq;
1925
struct cpuidle_state;
2026

@@ -1309,7 +1315,7 @@ static inline void idle_set_state(struct rq *rq,
13091315

13101316
static inline struct cpuidle_state *idle_get_state(struct rq *rq)
13111317
{
1312-
WARN_ON(!rcu_read_lock_held());
1318+
SCHED_WARN_ON(!rcu_read_lock_held());
13131319
return rq->idle_state;
13141320
}
13151321
#else

0 commit comments

Comments
 (0)