Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2256935rwp; Fri, 14 Jul 2023 03:28:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlHoEaTB9aZo4ee7Bl3fFIffhDT+Ml7eH1j38N8BMwbwzwhZOL93p59vU/3mt4DZr59rJM3s X-Received: by 2002:a17:90a:d48b:b0:263:fc27:662c with SMTP id s11-20020a17090ad48b00b00263fc27662cmr3330741pju.39.1689330481127; Fri, 14 Jul 2023 03:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689330481; cv=none; d=google.com; s=arc-20160816; b=QLQuiq2awGxPYF2e3blG7S6W/TVkKvSw3ACmsZU5YhDbBk548p6XKsDK9cVwgJiYvR 64r1SODBUjyllRsZ6ysFdkL9qUQ/RfW8krGB0ZNtUMp1aMfdLA8cRWmalhIAovMs0Oay MRGjXj0ouzI9QMKlh2QtOTaLCSDvKylyoqmdM973OckF8gjHS5+ID5AktAAmkI8Wh6CR fOxgIqgfzyOTwcA2rMdsNWraVUBjMFD6NjJUec5H/yeUSY9J4lEgvn/s6K2Rf4FJe4AJ g/0TqRXKbc6cN4OLUlqzXuJtlzY55HLonDIJ3Vy45CM8XgqSXNtJuHBsgkhqIplSgKw8 s6Kg== 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=V58G6k0S7NfSY//HiKoAYgvYkcXeF11/x3e2pQLhXQo=; fh=z2udDhd2xHc3fXHax20fgNiYpiJ5cp15u1fezB7hNOU=; b=G+VmU3pKIrMXHf5wgYQG/vImMburHeqC6yGBoR9f2YCecqtyFk+M6yB/Lb0jHFBTXZ RT1ohNJ2iYhYYUxogZqp+0GRbFtaLsgtmrG59E8RrQbZcS2ZPZszYaSQojbJzmPCBfQS nsmvuxUn2NRrSl+Z4WqB/sSXtc0yoakQaGO30Lfk6+nycvyOfF4TSH1cbPARaksEoIY+ OVPs7pL8yiw+3EBdGzMDEzspgyeX7WxTHNeMZGCHXCqa5r35Kc6tnTCIIQKsC27QpNim zKweCIUBJEuXPIgR+R4T9a+8uyrUjd2Fz1Ak3Uqx12qHCgPszZVjpcnsaeabwzYk5stU xeiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=kHyK4fPd; 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 z4-20020a17090abd8400b00263638bb354si1046820pjr.93.2023.07.14.03.27.49; Fri, 14 Jul 2023 03:28:01 -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=kHyK4fPd; 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 S235363AbjGNJle (ORCPT + 99 others); Fri, 14 Jul 2023 05:41:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234672AbjGNJld (ORCPT ); Fri, 14 Jul 2023 05:41:33 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 054C712D for ; Fri, 14 Jul 2023 02:41:29 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B976E22118; Fri, 14 Jul 2023 09:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1689327687; 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=V58G6k0S7NfSY//HiKoAYgvYkcXeF11/x3e2pQLhXQo=; b=kHyK4fPd7F72876ra7gyB0ErqV52Ctd/8NgZkb+A2kMXzsMK2mP6lWEsqvjITdhQ9ZqNg5 RLztS7mqpab3NscxFdFBuWI/85RgwNMMTKPKIiCI/NnfAviToiaITeumGb82Y1Rp3GqTen X3XjaPVmvaRLQ8esV9ah1dlb01d4FWc= Received: from suse.cz (unknown [10.100.208.146]) (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 92C2F2C142; Fri, 14 Jul 2023 09:41:27 +0000 (UTC) Date: Fri, 14 Jul 2023 11:41:27 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: John Ogness , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v2 2/5] printk: Add NMI safety to console_flush_on_panic() and console_unblank() Message-ID: References: <20230710134524.25232-1-john.ogness@linutronix.de> <20230710134524.25232-3-john.ogness@linutronix.de> <878rbkrg16.fsf@jogness.linutronix.de> <20230714040049.GA81525@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230714040049.GA81525@google.com> 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_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR,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-07-14 13:00:49, Sergey Senozhatsky wrote: > On (23/07/13 16:43), Petr Mladek wrote: > > > > Simple removal of console_trylock() in console_flush_on_panic() would > > cause that other CPUs might still be able to take it and race. > > The problem is avoided by checking panic_in_progress() in console_lock() > > and console_trylock(). They will never succeed on non-panic CPUs. > > > > In theory, we also can have non-panic CPU in console_flush_all(), > which should let panic CPU to take over the next time it checks > abandon_console_lock_in_panic() (other_cpu_in_panic() after 5/5), > but it may not happen immediately. I wonder if we somehow can/want > to "wait" in console_flush_on_panic() for non-panic CPU handover? Good point. It might actually be any console_lock() owner, including printk() on other CPU. I think that we might need to add some wait() as we did in the last attempt, see the commit b87f02307d3cfbda76852 ("printk: Wait for the global console lock when the system is going down"). Anyway, it will be more important after introducing the kthreads. There is a non-trivial chance that they would block the lock. They might be busy when handling a message printed right before the panic() was called. At least, this is what I saw in the last attempt to introduce the kthreads. But maybe, it will be somehow hidden in the new atomic lock. It might be passed to a printk context with a higher priority and it uses some wait internally, see the waiting in the patch https://lore.kernel.org/all/20230302195618.156940-7-john.ogness@linutronix.de/ Anyway, this patch does not make it worse. It just ignores the potential console_lock owner in console_flush_on_panic() another way. Best Regards, Petr