Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp624419pxh; Tue, 9 Nov 2021 16:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxj06MoW2Di1uZfdMfkEBH9JwpOlcX8I1/A33NFQyLFJIC61KAQYO8zcqwPZYCCarWEnBjg X-Received: by 2002:a05:6638:22d6:: with SMTP id j22mr9109382jat.97.1636503759855; Tue, 09 Nov 2021 16:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636503759; cv=none; d=google.com; s=arc-20160816; b=ckntUyx/jyJMovmC572HYqgNszwMyS4v2XTrdc7xJk55xLfjYi8puEjr8M3/LrZ3yj Cy5nw+PwnU8DEtSB/85gH8OzuRTJXfyYOTo7HoEMxJcFXumBaR+5Rm58aIyZ5Gxmakrd 4xFtOebD3rPC8hJPBnc+8ggYy+XV5WXR0VTpak+UMXQ5+uL/vZRp4jAMZKBhp1fGgket HHLcs2LHHHuqn6TAs4+piyefgiyJj60Ej5xdG/wnKwcqCzY2EiK//SDyidhpXMb8VpLZ 8hJ3pnlNe9UWzgL9n849vw/LkIQaUJ77nd0MsHoeD9a69djaK+DehoaRYDNuXDNuo6hK dpmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=hfoJ3mdhOp2wVVmk0izPdp4ZzIGt68u9ejlAidoV8lo=; b=k1oWFGYrd8BIUBhjfMYJoaGIRVKKOMXlX36A4bHAuSutui5dyr8bcTVFDKQTxEv7rO vtILwfld+QxvBSUlK5u/HgK+n40Zt3EoAlxDypCyXZLoXCKFvCJVdfKT1JGbwnY5xBYZ elUmS7l5cLRQ4oCTOurw5BZzeAAzjZI0klZLSy6A4243s29hC6tYnKycAD0RJEJHqnXi DzNYIklYV5tJigx9iI1dmaYjpnKeSRNbtgaMxKkyHx2LjaZzE5lCYisIjBDg5d2EZYYm w8VLHi1JiqnAhLlZ9HwFx1NAsbOB9IJP3991Pm8ZuuMz4L+hDnhtc8QSUVcj3aJM37LO LUXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="db9/rIn0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si39953587jav.10.2021.11.09.16.22.28; Tue, 09 Nov 2021 16:22:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="db9/rIn0"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243396AbhKIVmL (ORCPT + 97 others); Tue, 9 Nov 2021 16:42:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbhKIVmK (ORCPT ); Tue, 9 Nov 2021 16:42:10 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79C64C061764 for ; Tue, 9 Nov 2021 13:39:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=hfoJ3mdhOp2wVVmk0izPdp4ZzIGt68u9ejlAidoV8lo=; b=db9/rIn0TZoh+TBuGUP9/OW5of PycxW9RB/VkwZeSGcorbwmwTqYGld7zd3DS/IPxU16pe9s9iyIHJr/k1URpNf9gxLrKkr29kSbdrK BEs6GVFVPRpx6n6Zyg1Kq0gKncfBo0putXZJKcGzKwlxUJIhxefx9QUJi2LrgrBcTBQcLQ5fJWaET U1ilvDKABydsQFPJ63NP1hJE2tfaK+X+LRz9UaROBzo1e1zCPPpYzx7sXtWYX86hcEe6nT6mzEwIG piMU7RNEwMe5tDPoEdh0F360CFIQLSl16Eg40x4UKOe4yOJgypGi+uJOb5NR0KOmXEay5AdgNuFVe X9sx/Sdw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkYpL-00F8sM-M5; Tue, 09 Nov 2021 21:38:48 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 3A03F9862D2; Tue, 9 Nov 2021 22:38:47 +0100 (CET) Date: Tue, 9 Nov 2021 22:38:47 +0100 From: Peter Zijlstra To: Sultan Alsawaf Cc: Anton Vorontsov , Ben Segall , Colin Cross , Daniel Bristot de Oliveira , Daniel Vetter , David Airlie , Dietmar Eggemann , dri-devel@lists.freedesktop.org, Ingo Molnar , John Ogness , Juri Lelli , Kees Cook , linux-kernel@vger.kernel.org, Maarten Lankhorst , Maxime Ripard , Mel Gorman , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Zimmermann , Tony Luck , Vincent Guittot , mkoutny@suse.com Subject: Re: printk deadlock due to double lock attempt on current CPU's runqueue Message-ID: <20211109213847.GY174703@worktop.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 09, 2021 at 12:06:48PM -0800, Sultan Alsawaf wrote: > Hi, > > I encountered a printk deadlock on 5.13 which appears to still affect the latest > kernel. The deadlock occurs due to printk being used while having the current > CPU's runqueue locked, and the underlying framebuffer console attempting to lock > the same runqueue when printk tries to flush the log buffer. Yes, that's a known 'feature' of some consoles. printk() is in the process of being reworked to not call con->write() from the printk() calling context, which would go a long way towards fixing this. > #27 [ffffc900005b8e28] enqueue_task_fair at ffffffff8129774a <-- SCHED_WARN_ON(rq->tmp_alone_branch != &rq->leaf_cfs_rq_list); > #28 [ffffc900005b8ec0] activate_task at ffffffff8125625d > #29 [ffffc900005b8ef0] ttwu_do_activate at ffffffff81257943 > #30 [ffffc900005b8f28] sched_ttwu_pending at ffffffff8125c71f <-- locks this CPU's runqueue > #31 [ffffc900005b8fa0] flush_smp_call_function_queue at ffffffff813c6833 > #32 [ffffc900005b8fd8] generic_smp_call_function_single_interrupt at ffffffff813c7f58 > #33 [ffffc900005b8fe0] __sysvec_call_function_single at ffffffff810f1456 > #34 [ffffc900005b8ff0] sysvec_call_function_single at ffffffff831ec1bc > --- --- > #35 [ffffc9000019fda8] sysvec_call_function_single at ffffffff831ec1bc > RIP: ffffffff831ed06e RSP: ffffed10438a6a49 RFLAGS: 00000001 > RAX: ffff888100d832c0 RBX: 0000000000000000 RCX: 1ffff92000033fd7 > RDX: 0000000000000000 RSI: ffff888100d832c0 RDI: ffffed10438a6a49 > RBP: ffffffff831ec166 R8: dffffc0000000000 R9: 0000000000000000 > R10: ffffffff83400e22 R11: 0000000000000000 R12: ffffffff831ed83e > R13: 0000000000000000 R14: ffffc9000019fde8 R15: ffffffff814d4d9d > ORIG_RAX: ffff88821c53524b CS: 0001 SS: ef073a2 > WARNING: possibly bogus exception frame > ----------------------->8----------------------- > > The catalyst is that CONFIG_SCHED_DEBUG is enabled and the tmp_alone_branch > assertion fails (Peter, is this bad?). Yes, that's not good. IIRC Vincent and Michal were looking at that code recently. > I'm not sure what the *correct* solution is here (don't use printk while having > a runqueue locked? don't use schedule_work() from the fbcon path? tell printk > to use one of its lock-less backends?), so I've cc'd all the relevant folks. I'm a firm believer in early_printk serial consoles.