Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2461949rwl; Thu, 13 Apr 2023 06:52:08 -0700 (PDT) X-Google-Smtp-Source: AKy350bM3zPFFYP0KtVE3ASaf4I13N9Q5fKXJKBJGuJ7EpvNBZ0o57R84+b9BUqDTls8fVi/weVF X-Received: by 2002:a05:6a20:bb30:b0:eb:69c3:38b5 with SMTP id fc48-20020a056a20bb3000b000eb69c338b5mr1949000pzb.7.1681393927922; Thu, 13 Apr 2023 06:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681393927; cv=none; d=google.com; s=arc-20160816; b=JaDYNrkRqXwakni+j9UeCwvzGkNp+2KR6QAi2sYZtw/PBfjxhs1JQ3XTz9qJxmgBp6 kPZsmnkYwtasTIYWoim8SvB7BeG6BusqbO4pVOL8xw21ciTTrRgiMs7t22JxskPFq+HY 1lQMJjET6OELWGNn3TEfQQpt8JrQrQL5CyiMk57o1XAMaMFpewACr5zSNOdkRitSkScn d/cCjDwKZxkM0/Mutb+VpJYTJzD1BvsMgy8HYj6XJhJpFKmxOUD12Gmt0qJptRR13/yR sY4m3rwTl3Qj75MzloA0wrvEvDB2v1xj6tsZ739RQndr78YgiCPcLtARCUvUGPfWXo35 upGw== 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=laiMbeK7JM+yqQBuZgOEovH0qN4DzeU6w/zO8nnlU6g=; b=b/MHwabLLrjcDPtY7/mtmZkWsHu9uRHN2986UOl80ki88vpwOwAmn1r2YLOKgBizVp mYjLGi3lVAN91107ySqOXHLXjiY31jM78SHGVqOfzPxWfuBZI7ZMhE8c9TRWl7eB8bm3 2LmIQuzGuX/QEWkXeKka7RwejHKeen/q43iAFzdqeQ+z/OwOULREz25qjDkTTemaZK1s +tFqHEa0u3+pjTwIvkwfyWq+3uPx9QvdQOsqj7EInsIWW1+okSBBT3kHeOfmZG3IztNU CmJcaZ6tVGEh5Aqn5Y4zu4pT+/L6cs1Zhwa8VYUwRhm36DhVFmD5/CmTFIp0FBTGnkgh D/bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=FsVF1dUB; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c133-20020a621c8b000000b0063b5e220eedsi299884pfc.213.2023.04.13.06.51.55; Thu, 13 Apr 2023 06:52:07 -0700 (PDT) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b=FsVF1dUB; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbjDMNnx (ORCPT + 99 others); Thu, 13 Apr 2023 09:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231310AbjDMNng (ORCPT ); Thu, 13 Apr 2023 09:43:36 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F9ADBB92 for ; Thu, 13 Apr 2023 06:42:10 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 890AD218B1; Thu, 13 Apr 2023 13:42:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681393328; 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=laiMbeK7JM+yqQBuZgOEovH0qN4DzeU6w/zO8nnlU6g=; b=FsVF1dUBTNAgHOaQEIvxa2MQ39g2evXXxk0lBR+tiBwjv5PNDbsJfmUIFLtRxyFsb62UgW VDuHHVugz+w/3ATqOKy2tDPM1irizPPQ7ommpzATV0bB6IRGWmmHVpZ/PWBZgTN0EzNjCv KI07YXiplfFjjoVrfQiGf6JsH0dhr/k= Received: from suse.cz (unknown [10.100.201.202]) (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 58D5C2C143; Thu, 13 Apr 2023 13:42:08 +0000 (UTC) Date: Thu, 13 Apr 2023 15:42:08 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v1 02/18] printk: Add NMI check to down_trylock_console_sem() Message-ID: References: <20230302195618.156940-1-john.ogness@linutronix.de> <20230302195618.156940-3-john.ogness@linutronix.de> <874jqj7gmj.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <874jqj7gmj.fsf@jogness.linutronix.de> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 On Fri 2023-03-17 12:43:56, John Ogness wrote: > On 2023-03-07, Petr Mladek wrote: > > So that this change would cause a non-paired console_unlock(). > > And console_unlock might still deadlock on the console_sem->lock. > > Yes, but at least it would have flushed beforehand. > > > One solution would be to call console_flush_all() directly in > > console_flush_on_panic() without taking console_lock(). > > > > It should not be worse than the current code which ignores > > the console_trylock() return value. > > I think your suggestion is acceptable. > > > Note that it mostly works because console_flush_on_panic() is called > > when other CPUs are supposed to be stopped. > > > > We only would need to prevent other CPUs from flushing messages > > as well if they were still running by chance. But we actually already > > do this, see abandon_console_lock_in_panic(). Well, we should > > make sure that the abandon_console_lock_in_panic() check is > > done before flushing the first message. > > > > All these changes together would prevent deadlock on > > console_sem->lock. But the synchronization "guarantees" should stay > > the same. > > We could also update console_trylock() and console_lock() to fail and > infinitely sleep, respectively, when abandon_console_lock_in_panic() is > true. That would prevent CPUs from newly acquiring the console lock and > interfering with the panic CPU. Interesting idea. It should be safe after panic() tries to stop the CPUs. But I am slightly worried to do this earlier. I wonder if it might block, for example, trigger_all_cpu_backtrace() that is called when (panic_print & PANIC_PRINT_ALL_CPU_BT) bit is set. Best Regards. Petr