linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guanghui Feng <guanghuifeng@linux.alibaba.com>
To: pmladek@suse.com, senozhatsky@chromium.org, rostedt@goodmis.org,
	john.ogness@linutronix.de, keescook@chromium.org,
	anton@enomsg.org, ccross@android.com, tony.luck@intel.com,
	linux-kernel@vger.kernel.org
Cc: baolin.wang@linux.alibaba.com, yaohongbo@linux.alibaba.com,
	zhangliguang@linux.alibaba.com, zhuo.song@linux.alibaba.com
Subject: [PATCH] printk: fix softlockup/rcu stall warning without setting CONFIG_PREEMPTION
Date: Sat, 12 Feb 2022 21:27:42 +0800	[thread overview]
Message-ID: <1644672462-20793-1-git-send-email-guanghuifeng@linux.alibaba.com> (raw)

If without setting CONFIG_PREEMPTION, and there are too many messages
only in one cpu which will set console_may_schedule to 0 without cond_resched,
we will find softlockup/rcu stall warning. Although the timer interrupt
can be raised in the routine of console_unlock, the irq interrupt return
to user/kernel will't schedule other tasks(without setting CONFIG_PREEMPTION).
So I add need_resched() for cond_schedule to avoid it.

Call trace:
    console_unlock+0x220/0x420
    vprintk_emit+0x17c/0x1ac
    vprintk_default+0x3c/0x44
    vprintk+0x38/0x70
    printk+0x64/0x88
    dump_task.part.0+0xc4/0xe0
    dump_task+0x70/0x74
    dump_tasks+0x78/0x90
    dump_global_header+0xcc/0xe8
    oom_kill_process+0x258/0x274
    out_of_memory.part.0+0xb0/0x33c
    out_of_memory+0x4c/0xa0
    __alloc_pages_may_oom+0x11c/0x1a0
    __alloc_pages_slowpath.constprop.0+0x4c0/0x75c
    __alloc_pages_nodemask+0x2b4/0x310
    alloc_pages_current+0x8c/0x140
    get_zeroed_page+0x20/0x50
    __pud_alloc+0x40/0x190
    copy_pud_range+0x264/0x280
    copy_page_range+0xe8/0x204
    dup_mmap+0x334/0x434
    dup_mm+0x64/0x11c
    copy_process+0x5e0/0x11a0
    kernel_clone+0x94/0x364
    __do_sys_clone+0x54/0x80
    __arm64_sys_clone+0x24/0x30
    el0_svc_common.constprop.0+0x7c/0x210
    do_el0_svc+0x74/0x90
    el0_svc+0x24/0x60
    el0_sync_handler+0xa8/0xb0
    el0_sync+0x140/0x180

Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
---
 kernel/printk/printk.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 82abfaf..54b6cf2 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2716,7 +2716,11 @@ void console_unlock(void)
 		if (handover)
 			return;
 
+#ifndef CONFIG_PREEMPTION
+		if (do_cond_resched || need_resched())
+#else
 		if (do_cond_resched)
+#endif
 			cond_resched();
 	}
 
-- 
1.8.3.1


             reply	other threads:[~2022-02-12 13:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-12 13:27 Guanghui Feng [this message]
2022-02-14  3:06 ` [PATCH] printk: fix softlockup/rcu stall warning without setting CONFIG_PREEMPTION Sergey Senozhatsky
2022-02-15 16:23   ` Petr Mladek
2022-02-14  8:26 ` [printk] 94fb1f214c: BUG:sleeping_function_called_from_invalid_context_at_kernel/printk/printk.c kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1644672462-20793-1-git-send-email-guanghuifeng@linux.alibaba.com \
    --to=guanghuifeng@linux.alibaba.com \
    --cc=anton@enomsg.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=ccross@android.com \
    --cc=john.ogness@linutronix.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=tony.luck@intel.com \
    --cc=yaohongbo@linux.alibaba.com \
    --cc=zhangliguang@linux.alibaba.com \
    --cc=zhuo.song@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).