Skip to content
Commit 45fb4e58 authored by Ingo Molnar's avatar Ingo Molnar Committed by Zhao Wenhui
Browse files

sched/all: Change all BUG_ON() instances in the scheduler to WARN_ON_ONCE()

mainline inclusion
from mainline-v6.1-rc1
commit 09348d75
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9QW75

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=09348d75a6ce60eec85c86dd0ab7babc4db3caf6



--------------------------------

There's no good reason to crash a user's system with a BUG_ON(),
chances are high that they'll never even see the crash message on
Xorg, and it won't make it into the syslog either.

By using a WARN_ON_ONCE() we at least give the user a chance to report
any bugs triggered here - instead of getting silent hangs.

None of these WARN_ON_ONCE()s are supposed to trigger, ever - so we ignore
cases where a NULL check is done via a BUG_ON() and we let a NULL
pointer through after a WARN_ON_ONCE().

There's one exception: WARN_ON_ONCE() arguments with side-effects,
such as locking - in this case we use the return value of the
WARN_ON_ONCE(), such as in:

 -       BUG_ON(!lock_task_sighand(p, &flags));
 +       if (WARN_ON_ONCE(!lock_task_sighand(p, &flags)))
 +               return;

Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/YvSsKcAXISmshtHo@gmail.com



 Conflicts:
	kernel/sched/deadline.c
	kernel/sched/fair.c
	kernel/sched/core.c
	kernel/sched/sched.h
[Some contexts around BUG_ON are different. No functional impact.]
Signed-off-by: default avatarZhao Wenhui <zhaowenhui8@huawei.com>
parent 37e0a494
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment