Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp354249pxh; Wed, 10 Nov 2021 02:55:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy82dMT+W9CfZ+77SrUzXC6p6LrTuP2SyZu4FbE3L+Z6ofGzMraNdc82m6TmXdh8uCvGvUo X-Received: by 2002:a17:907:96aa:: with SMTP id hd42mr20730434ejc.385.1636541733932; Wed, 10 Nov 2021 02:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636541733; cv=none; d=google.com; s=arc-20160816; b=p51wjqqgfme33hOkR9P4NN47x2IHomF72gm8WypD5mruXxIXCTZrG6GV4eoN2Tqbht Rg/0maGkUdXGPzuxKhvOjyHDQrX5Axx02G5vbfluogQ0rLRBFev+xZ2jWz1h5q7Dxb48 JqSQFV+isQ1V9wMHQCHeUW/pkJTn8H6z+F75O06jaqxUGKOOWldj7lLjrPcarAgPZ0z7 0p2wxLKoIxdazsTlp/2HfHEe5dNsAX5nLCh4QtcS/v3ZROSQaApy9roFqp1LZoNqSjsq JPfNGQCtmwSwpUXSP6LrWi+NYfUavu91SIHcR/dKADraGJXZblrm02Kf21Tk4X+sdrwn 2usA== 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=HO47rCdGhejVyJEgjF3SBkyM6/8hcrmcNNntgOspooM=; b=BUgQBMQA9XpHeIBv4HkK7a981/i56emsevDOktxqDikVxc8YUArXNzvrVr9gBNX3CU P2JwALe5e83+ekKzjmBitXbnwyVFCxU3Eq1Maer7HPSMK75/kqSWGOeVmh1/IXAqid5W xM4YeTnNILbLl4/ZW5EnOpEzi0+57cWoLBT+JKvgyQFiDyhYY72h84lU2z3wQhkVH3ct tBn9Fh/Ntk2DsrgxAR0DGkA2RWmlWUGpO2WVnJ7WZW+z5rwpf9Qu88V+SXjGyz5wj+dp 9ucnPh/SOUYGLi3yocO7aCRofFRt+UI1hbmdF5nfhKXR6X0cGZDuQnbCfq2N6P/3LIvp FQdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=qMYeTxwU; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si25337454edc.69.2021.11.10.02.55.09; Wed, 10 Nov 2021 02:55:33 -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=@suse.com header.s=susede1 header.b=qMYeTxwU; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231218AbhKJKxb (ORCPT + 99 others); Wed, 10 Nov 2021 05:53:31 -0500 Received: from smtp-out1.suse.de ([195.135.220.28]:35416 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbhKJKxa (ORCPT ); Wed, 10 Nov 2021 05:53:30 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A2F1221B13; Wed, 10 Nov 2021 10:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1636541442; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HO47rCdGhejVyJEgjF3SBkyM6/8hcrmcNNntgOspooM=; b=qMYeTxwU4cq63Q3OW+UKg5QF2lysxwlTmwJqWixHqqENUO4b7wMGaNPHKAxr4Wj7BAW3fz jJOWsgoGaDc+mFW5E8ZcK4HByJMKjHuGclCKi/pVQQUsYSc6CIvMleBaN9zM7reHFRcL7z 6HvQY8mRhBmazXg5zzWpszlEwRpeD3I= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 2F76DA3B83; Wed, 10 Nov 2021 10:50:42 +0000 (UTC) Date: Wed, 10 Nov 2021 11:50:38 +0100 From: Petr Mladek 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 , Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Thomas Zimmermann , Tony Luck , Vincent Guittot Subject: Re: printk deadlock due to double lock attempt on current CPU's runqueue Message-ID: 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 2021-11-09 12:06:48, 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. > > 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. At the moment, printk_deferred() could be used here. It defers the console handling via irq_work(). There is no deferred variant for WARN() at the moment. The following might work: #define WARN_DEFERRED(condition, format...) ({ \ unsigned long flags; \ \ printk_safe_enter_irqsave(flags); \ WARN(condition, format...) \ printk_safe_exit_irqrestore(flags); \ }) , where printk_safe_enter_irqsave()/printk_safe_exit_irqrestore(flags) are currently used only internally by printk() code and defined in the local kernel/printk/internal.h Be ware that using the deferred variants is a whack a mole approach. There are many printk() callers that might be called indirectly and eventually cause deadlocks. As already said, the plan is to upstream -rt solution and offload the console work into kthreads. But it goes slowly. We want to make it a clean way and prevent regressions as much as possible. Best Regards, Petr