Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp549352pxk; Wed, 23 Sep 2020 09:38:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxs1S21G3SEKR8/T4UxL6lzMFdFDIV+0Hrvei3MucH8NkcyruhxVlH2pLuwZLAX9+cAA9lW X-Received: by 2002:a17:906:2786:: with SMTP id j6mr491877ejc.73.1600879103208; Wed, 23 Sep 2020 09:38:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600879103; cv=none; d=google.com; s=arc-20160816; b=jVch8Hv2m7uYKPGsNCtT+a6TuWdpEVT+oNay8pEP21a4XxkpM3CPuhurHEYhfOmPNS AAAhE9bkAJQzdDwR9XGMISBALb6kjeUkQmHuCpXdtd23x/0Mn++Hz8l15hvugRZVykwx QhZAS3taHGbaCBO3Lbur59du4UX3ufYbITR1m/BmXS1vZTy+FqjS4Smloa/xUtQHwsrZ 4rphw+ehVw50L+ZhT2CvNXwLFeo04CyiKZxGmXFO+VLpiQ+vwLNKy0DK3Rr3XvJOkDFd 49oqUfPpnuPt2w96VPJcOYhOxmTUvqGFlsB1vNuXL86UMiuiQ7xMfvEHJ0rTMOLBq8UX BFFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XfK4qkocWkT369sQkGo1FXbrIPTkvdIkrivHJ0OU0U4=; b=GKcvAPBFrOtlnpfdSiMos0lV8PHAhpLvmK7WDzwpWLGOgxNCwL0t6/DK6aF1Qy0JxN hhCEgV9W2Wwo3IaKs/v0CU8XB1L/mCU7CfYhQwm8bCycbwA4OsI76ZY2o2dWOLYPDuMJ g2/8Os7fgOfjRI4u5mWreAMApUlBlAQ4gmqsTH6OvHQFXA1a7RV3cbdk20vi8fnYgkFW PzuKaq38sVsxR/7upyPq+gcTPX5y2MmdO/z/px8+IfIfTbIjSfTlw3EUgtN9sb9kAUOz 52e140EqtEi7mwA3I7ifgAFna7SW9JgnsfuALLs2QX20VhRheqtBILUwI1RS2MWmzJBe 0Rog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=SqkYsATK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si292509eji.298.2020.09.23.09.37.50; Wed, 23 Sep 2020 09:38: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; dkim=pass header.i=@suse.com header.s=susede1 header.b=SqkYsATK; 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=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726762AbgIWQgj (ORCPT + 99 others); Wed, 23 Sep 2020 12:36:39 -0400 Received: from mx2.suse.de ([195.135.220.15]:57348 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726743AbgIWQgi (ORCPT ); Wed, 23 Sep 2020 12:36:38 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600878996; 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=XfK4qkocWkT369sQkGo1FXbrIPTkvdIkrivHJ0OU0U4=; b=SqkYsATK3djIR4O+BKElvHh4MDMChDShXUAf3e1vma0yd4i9Z8jVuRqpDrtO8tDTw0XXyE u5Uajv95I/l7V2zQiyIrFfjqoaDbe/g6bmI5clGQ4M72ET2bMS/SGR2no975hEU0CkL1Wx RTsPTE2yV08EObUWA2wABhkB6jsHZVs= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 6F6F4AAC7; Wed, 23 Sep 2020 16:37:13 +0000 (UTC) Date: Wed, 23 Sep 2020 18:36:35 +0200 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk 5/5] printk: remove nmi safe buffers Message-ID: <20200923163635.GE6442@alley> References: <20200922153816.5883-1-john.ogness@linutronix.de> <20200922153816.5883-6-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200922153816.5883-6-john.ogness@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2020-09-22 17:44:16, John Ogness wrote: > Since the ringbuffer is now lockless, new records can be inserted > directly from NMI context. There is no need for the NMI safe > buffers. Handle all NMI printk() calls using defer_console_output() > to avoid calling console drivers that might have their own locks. > > Signed-off-by: John Ogness > --- > kernel/printk/printk_safe.c | 47 ++++--------------------------------- > 1 file changed, 4 insertions(+), 43 deletions(-) > > diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c > index 7c186cefdb50..720935d19a3e 100644 > --- a/kernel/printk/printk_safe.c > +++ b/kernel/printk/printk_safe.c > @@ -355,10 +324,11 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args) > #endif > > /* > - * Try to use the main logbuf even in NMI. But avoid calling console > + * Use the main ringbuffer in NMI. But avoid calling console > * drivers that might have their own locks. > */ > - if ((this_cpu_read(printk_context) & PRINTK_NMI_DIRECT_CONTEXT_MASK)) { > + if ((this_cpu_read(printk_context) & > + (PRINTK_NMI_CONTEXT_MASK | PRINTK_NMI_DIRECT_CONTEXT_MASK))) { > int len; > > len = vprintk_store(0, LOGLEVEL_DEFAULT, NULL, fmt, args); > @@ -366,10 +336,6 @@ __printf(1, 0) int vprintk_func(const char *fmt, va_list args) > return len; > } > > - /* Use extra buffer in NMI. */ > - if (this_cpu_read(printk_context) & PRINTK_NMI_CONTEXT_MASK) > - return vprintk_nmi(fmt, args); > - > /* Use extra buffer to prevent a recursion deadlock in safe mode. */ > if (this_cpu_read(printk_context) & PRINTK_SAFE_CONTEXT_MASK) > return vprintk_safe(fmt, args); I still hope that we will be able to get rid of printk_safe completely. I would expect that only two situations would need special handling with the lockless ringbuffer: + call vkdb_printf() in kdb context + defer console in NMI context Eventually we should prevent too big level of recursion. Best Regards, Petr