Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp390126img; Tue, 26 Feb 2019 01:47:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ9M0n8Iw8Mm6ULdwwL7k4XunFmt5ja/wpReh5bnABp7H7H+PTWqq0m1R9wmbob5kK+1fjm X-Received: by 2002:a62:1346:: with SMTP id b67mr25904640pfj.195.1551174452339; Tue, 26 Feb 2019 01:47:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551174452; cv=none; d=google.com; s=arc-20160816; b=U5BVFDXpXI6ZFH0TbWNzk1CJa5tuuHqWnAjQBGgzor1SoakWpPCX52Z1gtiGr+hgA/ VI0Ah0UrpAcYKKnor5PkYz3CDygp2mlpHUPzRI/lqGqh2lZ6RouTeXA7E4JqnwsEChM8 4qDFbw83lNr//+P0Up2Rmf7oTYDbl2tAcw/03PySZeNskTgaGAXiishsWTwCJUlmEPLy BxDKPogd4KBeC/NBKA/tAS1m40GTugTLfMCUHHFtWBArFgey4djQvJliricuRGrIcMFV IaZgsNOGGR71O5H021lCi3T5+jAgsbXIEtJNB+5JkKMDApV9ZrB3iIhQbmt7p1W3hDYm iCNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=8czFzWdI4TG+2I4mBgJWHoA5LDONIMX7lkx/QrMOOWE=; b=VqOBxHkTBkBfz3KTFT6j99VSVD6sEk+xTJ6b5nvwnlaLY8dzs6cH337+icjjmWPmq7 NyQQ46oAmR7V5K/MkrXPfKu/hPSkF3czAPeUvsa3rt/yWyzVp3nsqJRQhcwH3O7c9tIN Q+T6ljNRRmErG62EBB56/1Zfu/jlNvjxC41O1RrVDtMOefsfojgDGTm0gloTERv5a7kD CGKF6gtq3Al55FDINqNXGy6MXlIE6NgEQAzfOKZcsaO5sElaITvDXyIJrLr+AZXn4Kv4 QudaAZcPnhdQVf9GeJGG1bc39v0KR1aAyxXd148KD+dIQ4Km6Z4qs43GUvf/26egF8is Ohow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q19si11629145pff.177.2019.02.26.01.47.17; Tue, 26 Feb 2019 01:47:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727762AbfBZJpk (ORCPT + 99 others); Tue, 26 Feb 2019 04:45:40 -0500 Received: from mx2.suse.de ([195.135.220.15]:34298 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725941AbfBZJpj (ORCPT ); Tue, 26 Feb 2019 04:45:39 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2AE6EAFF9; Tue, 26 Feb 2019 09:45:38 +0000 (UTC) Date: Tue, 26 Feb 2019 10:45:37 +0100 From: Petr Mladek To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 10/25] printk: redirect emit/store to new ringbuffer Message-ID: <20190226094537.46xfhv5rr5m4c33s@pathway.suse.cz> References: <20190212143003.48446-1-john.ogness@linutronix.de> <20190212143003.48446-11-john.ogness@linutronix.de> <20190220090112.xbnauwt2w7gwtebo@pathway.suse.cz> <8736oijgpf.fsf@linutronix.de> <20190225121106.oig7s6odqikcn4xw@pathway.suse.cz> <875zt7bz1t.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875zt7bz1t.fsf@linutronix.de> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2019-02-25 17:41:50, John Ogness wrote: > On 2019-02-25, Petr Mladek wrote: > >> >> vprintk_emit and vprintk_store are the main functions that all printk > >> >> variants eventually go through. Change these to store the message in > >> >> the new printk ring buffer that the printk kthread is reading. > >> > > >> > Please, are there any candidates or plans to reuse the new ring > >> > buffer implementation? > >> > >> As you pointed out below, this patch already uses the ring buffer > >> implementation for a totally different purpose: NMI safe dynamic memory > >> allocation. > > > > I have found an alternative solution. We could calculate the length > > of the formatted string without any buffer: > > > > va_list args_copy; > > > > va_copy(args_copy, args); > > len = vscprintf(NULL, fmt, args_copy); > > va_end(args_copy); > > > > This vsprintf() mode was implemented for exactly this purpose. > > For vprintk_emit() that would work. As you will see in later (patch 23), > the sprint_rb ringbuffer is used for dynamic memory allocation for > kmsg_dump functions as well. It looks dangerous to share a limited buffer between core kernel functionality and user-space triggered one. I mean that an unlimited number of devkmsg operations must not cause loosing printk() messages. > The current printk implementation allows readers to read directly from > the ringbuffer. The proposed ringbuffer requires the reader (printk) to > have its own buffers. > > We may be able to find an alternate solution here as well if that is > desired. I hope that we will be able to find one. The previous implementation needed some buffers as well. We should be able to use the same approach. I guess that one problem is that the new ringbuffer API is not able to copy just the text directly into the user-provided buffer. It might get solved by extending the API. Anyway, I still have to look at the remaining patches. Best Regards, Petr