Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37092476rwd; Tue, 11 Jul 2023 09:18:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlEFIphu/XxOOr/te2H/Yi+dL1+KgTUjMR80SELybMKsUsm5Ujf4LS2KWfk9RUMrg2SBCFg0 X-Received: by 2002:a05:6358:528f:b0:134:e964:134c with SMTP id g15-20020a056358528f00b00134e964134cmr18183798rwa.11.1689092317766; Tue, 11 Jul 2023 09:18:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689092317; cv=none; d=google.com; s=arc-20160816; b=KEoWgd+T3rr3rgBt8+T+7WHRqb8Zt9SjNsNshJuNXWWNeCgRs/8rFwCjuvXaGSo4XE wdDGjSJXKIt+NvQJVHhVX0/MzXb7htgKoYwuvtvPxfQ4KYnacxoQ5T/A4QJBEQg8twhy vedzew5Rc3/AamoyEpT+QiRYmRYJmlqu2r6VgxSJnj+BsmiQDt+pZAmlTBVqXCih9c9k oXWnLXDmX09Hfl8VIPBGSKtCfvIWrNGHL/hc41fW8hMCo9ySghTW+w7mgMP9fPwFJPKw 1SMyEBLhZntcFf3FXOE/wAl91cXwlvRnjMoIUlBq/gnSVklAjdlITUBAxFmVyRLFOcKQ 7pJA== 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=SKXcA0SybtEcZr7Re110CanuIvW8wybz2wN0UXPhcI8=; fh=nKoYetPUS4gPI2+x3BkQLMLOB3Em8ZuKw3tjPUCbXrc=; b=vEnnwj2mAzDdb/WQlGeEEh95HH+PAFW67i5+fWHH/eo5vashfdPTobiIjKj5p71Zs+ 2NPHTolThBDD+nDk4a0XASrvd372uZ6a5U9M1XB8RQUrcLiyYSwx246+QMQTOK3LHQxu 4KqCu8kBMjzWN7Pr/uIxjBXZRkNVp3Cypuzx0UmDHRzPkhQ+6ufrfuP/zVMn1u7nXl0x vwrN9hNeJ1uD6w22q9ZUrPY4IkK2rzxtesa4LZpnqpqv3tfQYEoVvDaqhbK7Z+1pXvQo L9oS7/U18p8aEDurql3g+EWFaKLGyAJqB6dXSksad2aH6hJdx3uAFjU5P0tXbz+5jD74 2TXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=k7nHBaEI; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r5-20020a63ce45000000b00547a1922957si1609579pgi.407.2023.07.11.09.18.24; Tue, 11 Jul 2023 09:18:37 -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=@chromium.org header.s=google header.b=k7nHBaEI; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231827AbjGKQII (ORCPT + 99 others); Tue, 11 Jul 2023 12:08:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233366AbjGKQIF (ORCPT ); Tue, 11 Jul 2023 12:08:05 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459DA12F for ; Tue, 11 Jul 2023 09:08:04 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1b89d47ffb6so29807415ad.2 for ; Tue, 11 Jul 2023 09:08:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1689091684; x=1691683684; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SKXcA0SybtEcZr7Re110CanuIvW8wybz2wN0UXPhcI8=; b=k7nHBaEIeGw54IxxyXsoyojRuFJNHzvfk6Rp5splYUo1Bvs133pEU5Bgz3/Ky/fVyE uzqf7K1f/Sxr86nRsurg7naQubOcQq2S54OSposfsaUiBk6CyKADKwtwptuwiuo/RWbe gu9Fn7/r2/UwNNURgOy5MZbDE0GgX1+KmiXHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689091684; x=1691683684; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SKXcA0SybtEcZr7Re110CanuIvW8wybz2wN0UXPhcI8=; b=OYMWmlng+9Ei05Q8pLSjhrBBAkRjO3BO4dttEFkrWbP9U9tC38lRaoXt31xGcDbbnt n32FhikNAeaAWoUXNAHGQ+5ldqdveG670qoyAMdwDZ9r2stJ1mS2WdLwvtKUTaqR7xhb GYud5Bcxlu9kAu6lA4feNN6Ehq5QTeoy0l/96IkfcCOUhIpGL+7752N2EfJxXd8xyS5Z dmtdn9szXz8Gz6fSdGwiKtghXF6FvLf2KmGVDnUS85EEzG1343zuW6qrPWKOIwlDfY47 EC9esqb43Qd48vWFODr4uZttDPQkxCZ5iWMSdxAOIrUGoHKZzBSGKD17l+qQ9s2JBaFo vl9A== X-Gm-Message-State: ABy/qLZjp8WSf5R9/6rHDX0I/yq96FmMoebV8PoFj8nR/9C2E87U5kO3 useMs/2m3CB3GCYlcA/ZpX1h+A== X-Received: by 2002:a17:903:18e:b0:1b3:7de7:f83f with SMTP id z14-20020a170903018e00b001b37de7f83fmr14992315plg.26.1689091683711; Tue, 11 Jul 2023 09:08:03 -0700 (PDT) Received: from google.com ([110.11.159.72]) by smtp.gmail.com with ESMTPSA id g14-20020a1709029f8e00b001b9be2e2b3esm2073939plq.277.2023.07.11.09.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jul 2023 09:08:03 -0700 (PDT) Date: Wed, 12 Jul 2023 01:07:58 +0900 From: Sergey Senozhatsky To: Petr Mladek Cc: John Ogness , Sergey Senozhatsky , 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: <20230711160758.GG12154@google.com> References: <20230710134524.25232-1-john.ogness@linutronix.de> <20230710134524.25232-3-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FSL_HELO_FAKE, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, 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 (23/07/11 17:43), Petr Mladek wrote: > On Mon 2023-07-10 15:51:21, John Ogness wrote: > > The printk path is NMI safe because it only adds content to the > > buffer and then triggers the delayed output via irq_work. If the > > console is flushed or unblanked on panic (from NMI context) then it > > can deadlock in down_trylock_console_sem() because the semaphore is > > not NMI safe. > > > > Just to be sure. The semaphore is not NMI safe because even the > trylock takes an internal spin lock. Am I right, please? > > Alternative solution would be to make down_trylock() NMI safe > by using raw_spin_trylock_irqsave() for the internal lock. > > But this actually would not solve the whole problem. If the NMI safe > down_trylock() succeeded then up() would need to be called > in NMI as well. And up() really needs to take the spin lock > which might get blocked in the meantime. I guess another problem with up() is that it also may call try_to_wake_up(), that may attempt to acquire a bunch of other spin_lock-s.