Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5371240pxb; Sun, 13 Feb 2022 18:53:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrYtkyR24J4GABiLMHdA+6hPYkhEu5awxc2EyfcSMI9iecHXgL0vrp2PstnBIPhYNl6Dpo X-Received: by 2002:a05:6402:34d3:: with SMTP id w19mr13263545edc.377.1644807236499; Sun, 13 Feb 2022 18:53:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644807236; cv=none; d=google.com; s=arc-20160816; b=TpjIK+/zT4rzY6zviRi2agRo1n0StLSCQqaeeusF1NgmdgaDbrg/nWb6CPV9FG93b9 YKbLttKJczh1lgisESPxKJ+v2LKuQnqRdAnx0LIU8B7pisGlcXO26wZ/TETxkd5/RPup jT+lutB1nUuND9KmU5wYW095SIbMwiKMU8Y1lluC8UbMTeXMsLcWhqGjddnlKQWrhVvQ IM5x/H0vofV6F/DuefRBdY/CGNhlKoBKt4nIYQgjgy1xRKRE6OyJYU8Day+qpcLGP5UT SpkJ9Kj6e2KPy3mz11PDvgNSIvY5h68TAm8ZfJOjkUraT8q/Ftogx+eo/Utzm1/24i5t GR1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=n2pvPY3kWKFtwPS/ckIff39cpJvcUd7pkrRXEdSq2W4=; b=tbJY21zNqx+e1Od3ZobnRwm09p+N8qxIgHohIyeaCHjOn+e8iQOcJhmlB2rh7RfKn6 XS4T5NzTmJqbUre88B8xWPCH8fVcnm1MmxOpj41K7bt03MaiQk2CjwLvCqfY3FBuRxvQ q/RD02f1B9GpOmrS/5tkBluW9xzwCBtxJX8nTLN2DEF77Qpb96bLEeCHDIS9bRJl9WH0 KSScHXsj9wpEOIO0b3Dio/d4xLrZK7qh6ef4n0ETABiSkTqunWE1KE0QBRr+O4A3yFiO HG5KV8RBmIiEhmbyI+ZBrf90FDtyS/cFeQP9ea7jZ9twGGh317HEXyAbmGBkXqflk4uf lVtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ed3si14942225edb.464.2022.02.13.18.53.34; Sun, 13 Feb 2022 18:53:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235726AbiBLN2D (ORCPT + 99 others); Sat, 12 Feb 2022 08:28:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:47390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231276AbiBLN2B (ORCPT ); Sat, 12 Feb 2022 08:28:01 -0500 Received: from out30-57.freemail.mail.aliyun.com (out30-57.freemail.mail.aliyun.com [115.124.30.57]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57034245AF for ; Sat, 12 Feb 2022 05:27:56 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=guanghuifeng@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0V4DccNi_1644672462; Received: from VM20190228-102.tbsite.net(mailfrom:guanghuifeng@linux.alibaba.com fp:SMTPD_---0V4DccNi_1644672462) by smtp.aliyun-inc.com(127.0.0.1); Sat, 12 Feb 2022 21:27:52 +0800 From: Guanghui Feng 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 Message-Id: <1644672462-20793-1-git-send-email-guanghuifeng@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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