Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2457729pxy; Tue, 3 Aug 2021 07:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhETrRqWloytRcKeRDSVZrM7AIPqmjv49GUWKhI6fqsOfkL3KI72YLJFWIrTyPupP7RT+1 X-Received: by 2002:a92:dc06:: with SMTP id t6mr226508iln.231.1627999413145; Tue, 03 Aug 2021 07:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627999413; cv=none; d=google.com; s=arc-20160816; b=T+DfMIVzqQHGcjcWJ0GoyuZQKiqGNpHDMko2AqBT02IPFi2y09JKKhiY5aRUDwfoM3 OB8wlgxut9dKw//dPlu2qar8QOjrfOSLGBZOyBwxKWpdpZX65U/cnac4ldoIw3KQXAph IQwLKl0RxdJw/gueBnN056YzNRy2v9A4qxa2guQ+pNdb8qIVFsMA9lmpVHsu0YzyLOHQ OagBAwu4RBIxklz3UQMXrCgVBWnDSOtVoSD2rX2R7Ifira6DdKi2qzpfJ/bmGdcQ/3VD aCKYcOldq/4WxysVH57grYiXf4ONTxPBuMXRnmAmywsJHLNwxUEMcVEqf3+BtyIjOdY6 UmEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=VUNzQH7wfzxpjiyiYobCjakTmaCYKzYfL9cv2a4Ykcg=; b=pu2IN/KmLt1S4hr1MXNlLhGYRsQNrtEb8SmAZ7V6NDFynLJs8HKZ4Q/thhJ9eI0Qye QDK2EjpIrd5uUtHw3d+UUc712pkn/wyuWD3+CtZmoCspJKYeJQm1SMz/qRemilCWyT7y G+G/u0YRaKiUrJ4gD61MS1A2RKjP2peR0YIUBWv5k0kQjZPHHoQ6ICjuqzrVoFClYqv7 bjiP1Gy81O8E44j/0byNegjHA7xOy2ndBNNaECG56v8kDlv+/GXnB47HTvRB2B0w6Igy UIZIv0TmeofbEbQp3iMj9Ad4S4ObmMNFt1rN5SJtGBWB5jPAaLCWQj4FWPqGpnYz9Qg9 mtWA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x9si14924020jaf.48.2021.08.03.07.03.21; Tue, 03 Aug 2021 07:03:33 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236363AbhHCOCi (ORCPT + 99 others); Tue, 3 Aug 2021 10:02:38 -0400 Received: from mga14.intel.com ([192.55.52.115]:61807 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236370AbhHCOCg (ORCPT ); Tue, 3 Aug 2021 10:02:36 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10064"; a="213423076" X-IronPort-AV: E=Sophos;i="5.84,291,1620716400"; d="scan'208";a="213423076" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 07:02:24 -0700 X-IronPort-AV: E=Sophos;i="5.84,291,1620716400"; d="scan'208";a="502403161" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Aug 2021 07:02:20 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1mAuzl-004kRl-2r; Tue, 03 Aug 2021 17:02:13 +0300 Date: Tue, 3 Aug 2021 17:02:13 +0300 From: Andy Shevchenko To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Andrew Morton , Masahiro Yamada , Peter Zijlstra , Nick Desaulniers , "Paul E. McKenney" , Tetsuo Handa , Vitor Massaru Iha , Sedat Dilek , Changbin Du Subject: Re: [PATCH printk v1 07/10] console: add write_atomic interface Message-ID: References: <20210803131301.5588-1-john.ogness@linutronix.de> <20210803131301.5588-8-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210803131301.5588-8-john.ogness@linutronix.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 03, 2021 at 03:18:58PM +0206, John Ogness wrote: > Add a write_atomic() callback to the console. This is an optional > function for console drivers. The function must be atomic (including > NMI safe) for writing to the console. > > Console drivers implementing write_atomic() must select the new > HAVE_ATOMIC_CONSOLE Kconfig option. > > Console drivers must still implement the write() callback. The > write_atomic() callback will only be used in special situations, > such as when the kernel panics. > > Creating an NMI safe write_atomic() that must synchronize with > write() requires a careful implementation of the console driver. To > aid with the implementation, a set of console_atomic_*() functions > are provided: > > void console_atomic_lock(unsigned long flags); > void console_atomic_unlock(unsigned long flags); > > These functions synchronize using the printk cpulock and disable > hardware interrupts. > > In order to increase effectiveness, the printk cpulock functions are > also made more aggressive and now keep interrupts disabled while > spinning. > > CPUs holding the printk cpulock must not spin on any other lock. > Therefore can_use_console() will now return false if the printk > cpulock is held in order to avoid calling into console driver code, > while typically contain spinlocks. > > Likewise, console_trylock_spinning() will fail rather than attempt > to acquire the console_sem (which includes a spinlock in its ... > #include > #include > +#include Ordered? ... > + if (!(con->flags & CON_ENABLED)) \ > + continue; \ What about #define console_is_enabled(con) (!!(con->flags & CON_ENABLED)) or inliner equivalent static inline bool console_is_enabled(struct console *con) { return !!(con->flags & CON_ENABLED); } ? -- With Best Regards, Andy Shevchenko