Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1671767pxj; Fri, 18 Jun 2021 12:15:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwInJj7aOR5T2/2G2i7aZT1gUf+4SLexEmHc56gK1FbCwTBtzlETx8Sls2BswC+MK4opuCV X-Received: by 2002:a17:907:e90:: with SMTP id ho16mr12648933ejc.410.1624043723515; Fri, 18 Jun 2021 12:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624043723; cv=none; d=google.com; s=arc-20160816; b=eWEXb36izlt9hNhGwEkCKIHcTimrMBv7vWWjx9EB1MABPhBd1gkNIYQWmLYy1hmxdD acCpj+AYcGTMjNc2b9ueSXwF1Cm3NvX0dWULyRMQzyiuro9FKI2uKJ4DKN6e0CtMsXuT XZlQ4Xkfxz4eDKci2gztBsDxkq2u7inTCareysmcuZ+7mSONPY4kEaF8jpgpRwBd2VxG Ey+BQp9GVxUiyEA6t9v7GCrPwzX2Nc3xE/WzCUzkZZm764WYAYrFbOSuKQJ8m9xoty/R BZ4ldIxyetbftBIeWo+D8LpjvO4PpNsmNadDM66y18FwH7H5+3XKb1VSHLLn0At4gUTn /J3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=t6vfGNelQsbMaq08IMZFgTUXexC9fF144OU/twZMt1E=; b=KX/z6iN5obgeqAFgEXjZI2HhuGn2v8dnuClE2aQrNTsstKah4UyJsRJ/eoMfJMLTou 37rYGJeukLzBo4UUvMcFys1VJWjsjfEZV0qr7qCZUzLx4E+gLkAhi5nyeYmRCeWDKywK OiEZV2pUyMvWy1gSLF5lodI07w1YwDjAIUNVdWkqVPSHYdR/59IkW7sjnMYOiHwF42ED ITIHU1SWoG4k0M/rhu2Dlj9Vt8WxKKwPJySv7aXYYM5vRYgYxPfn9nofpy42GBlbF1N6 Q7ceikJqmlqfTfp153UIy4R8AV1+xuDiMgiZZZs8mewRgg2v66yJx2Pz5DyHhzfivJnE ttuQ== ARC-Authentication-Results: i=1; mx.google.com; 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 23si3368799ejg.480.2021.06.18.12.14.35; Fri, 18 Jun 2021 12:15:23 -0700 (PDT) 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; 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 S235889AbhFRQeO (ORCPT + 99 others); Fri, 18 Jun 2021 12:34:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:46420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235867AbhFRQeF (ORCPT ); Fri, 18 Jun 2021 12:34:05 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C5ED61260; Fri, 18 Jun 2021 16:31:54 +0000 (UTC) Date: Fri, 18 Jun 2021 12:31:52 -0400 From: Steven Rostedt To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Thomas Gleixner , linux-kernel@vger.kernel.org, Stephen Rothwell , Andrew Morton , Peter Zijlstra , Daniel Bristot de Oliveira , Stephen Boyd , Alexander Potapenko Subject: Re: [PATCH next v4 1/2] lib/dump_stack: move cpu lock to printk.c Message-ID: <20210618123152.35a992ea@oasis.local.home> In-Reply-To: <877dirb4t2.fsf@jogness.linutronix.de> References: <20210617095051.4808-1-john.ogness@linutronix.de> <20210617095051.4808-2-john.ogness@linutronix.de> <20210617093243.795b4853@gandalf.local.home> <877dirb4t2.fsf@jogness.linutronix.de> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 18 Jun 2021 17:01:37 +0206 John Ogness wrote: > Since the cpu lock is also taken in NMI context (for example, via > nmi_cpu_backtrace()/dump_stack()), the main concerns are: > > 1. locks that are taken by a CPU that is holding the cpu lock > > 2. NMI contexts that take any type of lock > > (Actually, #2 is just a special case of #1 where an NMI interrupted a > task that was holding the cpu lock.) > > For early_printk() the early USB devices look to be a > problem. early_xdbc_write() will take a spinlock. Assuming the > early_console was also registered as a normal console (via "keep") we > could end up in the following deadlock between the normal console and > early_printk() writes: My use case of earlyprintk is to avoid all the crud in printk, and just have something to print to the serial console. USB early printk is not my use case, as that adds even more crud. Thus, I don't care about this being an issue with USB early printk ;-) > > CPU0 CPU1 > ---- ---- > early_printk() console->write() > cpu_lock() spinlock() > early_console->write() *NMI* > spinlock() cpu_lock() > > The upcoming atomic console work addresses this by implementing a new > write_atomic() callback that is lockless (and SMP-safe) or aware of the > cpu lock to avoid dead locks such as above. > > AFAICT, the USB devices (CONFIG_EARLY_PRINTK_USB) are the only > early_printk() candidates that use locking. So for all other > early_printk() implementations I think your suggestion would work fine. > > Although, in general, early_printk() is not SMP-safe. So I'm not sure > how much safety we need to include at this point. > Right. I say we ignore the issue with usb earlyprintk. The only time I can see that even useful, is for issues that are happening before printk is initialized, and all you have for a console is the usb for early printk, and the above scenario shouldn't be an issue. But for places that would utilize early printk for later on in the boot process (and normal activity), any console that takes locks would be useless. -- Steve