Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1131496rwb; Tue, 27 Sep 2022 08:49:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ft7oPYg+lS4EmWUMfRvbQUJPbAGxzIR4ygNhNNZOQ3HA2O5S8UqjQ0FNceALMChVdHusJ X-Received: by 2002:a17:902:a50a:b0:178:b06f:ea1f with SMTP id s10-20020a170902a50a00b00178b06fea1fmr28125616plq.13.1664293753051; Tue, 27 Sep 2022 08:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664293753; cv=none; d=google.com; s=arc-20160816; b=YEYsAshMqDwKWCW6qLUOEBhbkoASpvBceUgkgIaYkab64g3GmfAjFZbQcHqHgim3D1 2bAkesx3pE3y10JftV6N8rb9ozIoIS0BMnU3/kFJJrIPc9jR0ee7sEWsWEQd3UIuaawi Q+V6hk9OLRYqhrrXRx5qiPk8bCVRX66sMRlhoJV4ShSjpCRqEKSM/ZQ3N459TLa7Lv+g WyhOTsZZFSZ6FERp+jOs4Dpl2fsA4oGL2ewHD2dcMBRgrC+VhXYAQ4XG2ukAMFSHL64h jAFOHKiSfvom+WtuSWIvFgYDdL9Q9STy6Iwz8EA+YudU0KNJZ3uo9b6tGVw6U4v8+Mzr d9NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=CIBbc7Ixz0yANnUMl+8HLGWXcOy/Ot1heesGkqB0K/E=; b=bEJlOCNcKVmkOCIu62KIxEbqAuDZs92Qgqj+o1WXxVN+z1/31PeaFmybdQTYnDwi8X mRR9IipvPsM1tXGlqzHx7mNDqD+MgRhy0ecaCHwdTGGo7QH9IJ0zsmweQdDc2PaFyd3H dMN/IkXjAoH1ZfIclBmTf4My0ibVknlHqzDimPmxQt+oaKBmk8GRDiEH7MbSnJZdF6cs D8Vax6LtmiB/pJ7yLccAmtbC7pPHLtnCAR0DFIB7szMscNHRvgQGxO+wkv0fz/XO7/jF pcCCY+iTHhe0NXUP78oIMfFzGre6KNljE4jP8gf+g9kGgTDF7vNg/5dGzzG6Q2VYO27Q mT5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=MPLSul4d; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a056a00188800b00536c198ca83si2787502pfh.15.2022.09.27.08.49.00; Tue, 27 Sep 2022 08:49:13 -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=@linutronix.de header.s=2020 header.b=MPLSul4d; dkim=neutral (no key) header.i=@linutronix.de; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231288AbiI0Ov1 (ORCPT + 99 others); Tue, 27 Sep 2022 10:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232911AbiI0Ou4 (ORCPT ); Tue, 27 Sep 2022 10:50:56 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA58E1E717 for ; Tue, 27 Sep 2022 07:49:46 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1664290185; h=from:from:reply-to:subject:subject: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=CIBbc7Ixz0yANnUMl+8HLGWXcOy/Ot1heesGkqB0K/E=; b=MPLSul4d3QU5Mfo3jZO6sobZ61PTC0AjhGsv3l02R2EijqP9J2CXq58CXRoURqKDYhjFF6 U2KSPbzqahC8TT4g5w2ZgeZ0cm0uJFXoWlarodbxSMWYe//5Eo3wT4VfhEsb4hmUIwZMhe t/F2Ueh05p6FZZHCr2tZw/167Qbqqmhw1yr8tX1ZfFVO5lzPXcFIX7yWKjHG2vDkYIiUfA OXLqJl/WWzNs3Ys96HkgKfYHqoW+dsV9oBoLr9hwHJt/6CfQdTqcjEJo0uTgMbWrkgbsho KQm0rcP4ChqVXQ5YOoeNfvQya7pi3W11ZRmcXJy7o+68JVJc/TkGu5vRQsxYzw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1664290185; h=from:from:reply-to:subject:subject: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=CIBbc7Ixz0yANnUMl+8HLGWXcOy/Ot1heesGkqB0K/E=; b=BgOdwAxVWYluZ6fTRlN1UtTV6pLNICTlgjFsnhaur0Yy/mT2Aq/HAoXXzfDZUwjqBJ0jK6 0gKTynPLMLyTnlAA== To: Thomas Gleixner , LKML Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Peter Zijlstra , "Paul E. McKenney" , Daniel Vetter , Greg Kroah-Hartman , Helge Deller , Jason Wessel , Daniel Thompson Subject: Re: [patch RFC 28/29] printk: Provide functions for atomic write enforcement In-Reply-To: <20220910222301.995758602@linutronix.de> References: <20220910221947.171557773@linutronix.de> <20220910222301.995758602@linutronix.de> Date: Tue, 27 Sep 2022 16:55:44 +0206 Message-ID: <87k05olvnb.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 Below is a fix that was used for the LPC2022 demo so that after a warning, the atomic printing context is not responsible for printing any non-emergency backlog that came after the warning. On 2022-09-11, Thomas Gleixner wrote: > --- a/kernel/printk/printk_nobkl.c > +++ b/kernel/printk/printk_nobkl.c > + * cons_atomic_flush_one - Flush one console in atomic mode > + * @con: The console to flush > + * @prio: The priority of the current context > + */ > +static void cons_atomic_flush_one(struct console *con, enum cons_prio prio) > +{ > + struct cons_write_context *wctxt = cons_get_wctxt(con, prio); > + struct cons_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt); > + > + if (!cons_atomic_try_acquire(con, ctxt, prio)) > + return; > + > + do { > + /* > + * cons_emit_record() returns false when the console was > + * handed over or taken over. In both cases the context is > + * not longer valid. > + */ > + if (!cons_emit_record(wctxt)) > + return; If the CPU is no longer in an elevated priority and kthreads are available, abort the atomic printing and let the kthreads take over. Add the following break condition here: /* * If the CPU is no longer in an elevated priority, let the * kthreads take over, if they are available. */ if (prio <= CONS_PRIO_NORMAL && con->kthread) break; > + } while (ctxt->backlog); > + > + cons_release(ctxt); > +} John Ogness