Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp116029lqs; Thu, 13 Jun 2024 05:45:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXGyD9OvIvq+Svw/F2/Soq42Kp2dpowWk4JquJ/2pq0UsDGr5zJfIoT3x73LTZb9zCvm/apooQhBFloOq6MG4kiLTejTpVhaqNZbAdDjQ== X-Google-Smtp-Source: AGHT+IHmy/2zyWnIRlvoNVNh1c8F2K0OtdSnMXYqCRoXwEPK0ZPr9+pLPc9i8LfDBr1PprHNX0S1 X-Received: by 2002:a17:903:1c2:b0:1f7:b24:c271 with SMTP id d9443c01a7336-1f83b56be32mr56977275ad.21.1718282711523; Thu, 13 Jun 2024 05:45:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718282711; cv=pass; d=google.com; s=arc-20160816; b=vEuMfrFYSrVQ/SvQRoZwMs02yPH5uvNypcIn4peQrcAF6OAyYtQTKyFB30Wxwz03N1 ES+qA4U4FEbgnXQDYUAn5oHzR2n5VVwlJHcx9kGDFzGBJzvTN3IiUOkcD1LRggPJPjxx xE48iMLamMnrh2DIISEeZxmITEXHuJzg88ZTkVEvnl/Ataf71480RNG8orCj86CQYa6+ kMFRZBCNruL5mzyXrbCaRKhMWN5AlpMNaqUNlCiREwdu1OGHCSnKifvcrz9VggnELSVP crKIzh3lkjKtxrnsrKJDQX7nAHXuAavq0zvpKHdtVVAYrTqhkCnO8mMf6lR2uGxZ7ZWZ ouvg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=lvOE+xx/r3Ze7HhTtH9a9kVEqKKwBRndNOB7sOnUFic=; fh=R1IQSmE7Oh7EdRwbKpYxYDVuStjAV4s81QgobDwGjus=; b=Ux9ooMo3cE+PboHABsGXvs0fYh9QHcOh+3e8PWOCDmnZgGnTuEY8vHszwL8TR/aC0z 3c/rbxHYCdYpm2xwiPYx2Y8m6LhJtEwteyRqbGVjvEnLcep3tCEid+bCYGe2kr+rZM8U ve3W7gW5NB8n9Q7TRiVEwE1gBwyvwXO0d8B/kDZiNS09RbsCUv86Zg5r4NCTm5Ys0GQj cxmJmxHhbUbcN5F2JNju6aJX64Np/y6f2tytM6P9wkZivc7fTXyh5rU7u7Gvekwals/g hAG2cgm042tH6Vr135PXxVIjx+B1EL3kQKYE/ldGwrIzy0qdlanmwP/qEJwZpwIO0L7n iwCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=LNf+c3Oe; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-213228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f855e36521si12520265ad.29.2024.06.13.05.45.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 05:45:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=LNf+c3Oe; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-213228-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213228-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C77E5281741 for ; Thu, 13 Jun 2024 12:45:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 51DB21F937; Thu, 13 Jun 2024 12:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="LNf+c3Oe" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FED24A07 for ; Thu, 13 Jun 2024 12:44:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282699; cv=none; b=Kg+F0LaSSOR2K7hITSIVvRXgbsQT14mqvvPZdIyE/KQZ2ZRzktBNOgXRGT0w2z32OzH/fjfcCeVOvawOJG83yW6sOLBoPZqGDh33ymwZER72MtXaysDcsWIdBVl+zY6ggzAu3oOoBdIIOP2agZF/gx6VawRcy+QdnTnYYKznNEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282699; c=relaxed/simple; bh=Oc/aNnSJanTDNPeyaIgkcgxBXSkytTnrCARPAp5zkbs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Vpouf7QXsZq9KqbDFHqutnRnmqguzYDU5QnqlHIsZTPXL32GguCapflu5HBkr55eeKWLSTju8HR64HHXCG4vCg3AnQamhe6RpSp7Lvac7BofJN3WEVWJI00B6hAeymou9IIqDFqtdZceqhKv0AzFj/Zjq8r358u0fIcaSAhv1Jk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=LNf+c3Oe; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57a44c2ce80so1030926a12.0 for ; Thu, 13 Jun 2024 05:44:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1718282695; x=1718887495; darn=vger.kernel.org; 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=lvOE+xx/r3Ze7HhTtH9a9kVEqKKwBRndNOB7sOnUFic=; b=LNf+c3Oe82hN9WrzMqF5cJk5oC4xCGEZgexK4aRQqbccgxHDnXswb0EazwSLCSbARP KxHomZ5E4MO3wP24sI72ZIL+RgEm8fGq4/hVPF518jhWviIPwG3B355EaVRZwXttN5nJ ppg9izQrkzOSv9DpvtQjLD6ex3qGWf+JCK4Hc3PFO1yvf/0/s9HAmlA+cbK8sBkhZ9Vi iX5nlzIeghIKXLwfuM6N3pg4mHYj0YOVCu2s438vAUAA71yDlLXCJd7o3frKBBzgC8Jw bWY6oTI4DdyWU2q9PgKMMjim6ZSaLD/4XL8dfhEO3BRr3yTn9qyNdgOLYUe5Wpr5AB6X h1Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718282695; x=1718887495; 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=lvOE+xx/r3Ze7HhTtH9a9kVEqKKwBRndNOB7sOnUFic=; b=mIkxsktoPd427emjGCu+OSpvHYWV2KCm4UcpgZL23pI6VJg2DsYS9+S8v+lg0LkycY rnk34DbyvrkfGgDqePG5mT43jIFQmks6D46AxGiPYRp7P4qfp9wgQV18VdqTb0Oeb4TI jY++vT3ZG0Rd0p9hL33dk2oum3f3+SwUurMNc/1alaPgSXAhzjaqUXV+lFXU4yeDeSZC Frq7s6KmgDxGkX86O/nu+aNtjg4PIqRymcX4ADR4E3d8NRv9BvnkyqlWprNXwDf/Mlas zGLFCSOzL9hW775U3lHnpGGwvs2ACgeLYGazYMprR8RuKdlnMiTNSGys97eoyJI6Prj5 29MQ== X-Forwarded-Encrypted: i=1; AJvYcCUorvQ67iAsARwIgyIofCewivUZXR1bth3rsj/z6Acy9SDYyia5FumZq1SD4btkK/RO2/oXMMDgaoZTuzjt15l8QZPTBzKdtA2JvEPP X-Gm-Message-State: AOJu0YwzVJnL3BMQN2A6+oMqqZEek5QDM2aJRVjuYQMK3Mh0hUEYoN1P /+Otkpa468noJudBNSRZo+cW+3tsyg629QzIb1ywpufA6sslM6jLT5fHjZ2wfiQ= X-Received: by 2002:a17:906:6bc1:b0:a6f:3155:bb89 with SMTP id a640c23a62f3a-a6f47d5f3c8mr266082466b.70.1718282695398; Thu, 13 Jun 2024 05:44:55 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a6f56f9978esm67672866b.200.2024.06.13.05.44.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 05:44:55 -0700 (PDT) Date: Thu, 13 Jun 2024 14:44:53 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: atomic_flush vs boot consoles - was: Re: [PATCH printk v2 05/18] printk: Atomic print in printk context on shutdown Message-ID: References: <20240603232453.33992-1-john.ogness@linutronix.de> <20240603232453.33992-6-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240603232453.33992-6-john.ogness@linutronix.de> On Tue 2024-06-04 01:30:40, John Ogness wrote: > For nbcon consoles, normally the printing is handled by the > dedicated console printing threads. However, on shutdown the > printing threads may not get a chance to print the final > messages. > > When shutting down or rebooting (system_state > SYSTEM_RUNNING), > perform atomic printing from the printk() caller context. > > Signed-off-by: John Ogness > --- > kernel/printk/nbcon.c | 5 +++-- > kernel/printk/printk.c | 7 ++++++- > 2 files changed, 9 insertions(+), 3 deletions(-) > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2389,12 +2389,17 @@ asmlinkage int vprintk_emit(int facility, int level, > * > * - When this CPU is in panic. > * > + * - During shutdown, since the printing threads may not get > + * a chance to print the final messages. > + * > * Note that if boot consoles are registered, the console > * lock/unlock dance must be relied upon instead because nbcon > * consoles cannot print simultaneously with boot consoles. > */ > - if (is_panic_context) > + if (is_panic_context || > + (system_state > SYSTEM_RUNNING)) { > nbcon_atomic_flush_pending(); > + } > } I was curious why we do not need to add this check also to console_flush_all() which checks con->kthread as well. I realized that we call it only when #define printing_via_unlock (have_legacy_console || have_boot_console) => it handles nbcon consoles only when there is still a boot console. It actually have to handle them in this case because the boot consoles can be serialized only via console_lock(). In fact, nbcon_atomic_flush_pending() is not safe when there are boot consoles. This is handled in vprintk_emit(). But it is not enforced on several other locations. I played with a possible solutions. The conditions around the console calls are getting more and more complicated. I am going to send a solution which looks acceptable to me. Best Regards, Petr