Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4661100imc; Mon, 25 Feb 2019 08:43:28 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib7PtBN7yGg+cyZFV2Nx4Oyr1fC8GyFCSMAqVmDQAUhYwLmCzE9BK7zT0X6ifKkOOWI9Z+N X-Received: by 2002:a17:902:e60e:: with SMTP id cm14mr21254060plb.192.1551113008670; Mon, 25 Feb 2019 08:43:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551113008; cv=none; d=google.com; s=arc-20160816; b=fM+2DGUlvWg/nVLw2EMXoBM25l+BQm+MuKWNxHGkcW+a2kX2aZt6dEiP6WnfRg0EbC BpqjwEcG81d0GAxSWdfqgYtSrfKP4F33aW1GtGJFQST/Vog3DjiC76o93OwcL6VNMpXx 6D6bKVzGX+inQwXfcBizQb4oz2m6vdkT8ZjKf7mUuvQosBlfc7Qkh98Obl3mDmf9Fr3M P7Af06QL9WeNnt226FMj4I4Hemm6k/pfQl0JE+EHbCxMxKVfiDko46NR8HzVwbVK8AlU XBBVwu0vE5LrED8sH5iN90mQvK5yrfO7AU+0/O+iaIKGVIHNASx5v7YbPU8wPZwyu7Cp PNPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=LmJjjs+fVKJB+ImUH3rJFTpWqXzYxrHMxyof23/kNnk=; b=SjpOhMvCm9Fwy0ZBaoG/RHWcRfTYlQ3eJXdopKgVbXKTVa9MUKC9HqiWY8k3E+w5RG hF2MCFgPUQl/x66l3tSuEjlgA6liJmKG6t7AGvVw5LkB4stD5vi0UrM4eOyfVabaRH6D M+p/L7lXvvTvrOfmTorQYNqxwDs0gKiPDlHXFKkrXxyBTMmqWnSlj5ldYVLeEL8jA96t XcR+HNl+YItUkA/ETzgVgLLZ9RX6WArRHifPZ9hjygIYT85QHdRdIe0wzEswFEEF+SPB gwK0pHtQLeZ4m3s1d+ItsK+9uBJcCxicB2zleVerIJrVHPIAPrU0STSTmpHiZeT7vCQQ DfBA== 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 h127si10826572pfb.213.2019.02.25.08.43.13; Mon, 25 Feb 2019 08:43:28 -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 S1728339AbfBYQmB (ORCPT + 99 others); Mon, 25 Feb 2019 11:42:01 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:41066 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728316AbfBYQmA (ORCPT ); Mon, 25 Feb 2019 11:42:00 -0500 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gyJKD-0002V2-33; Mon, 25 Feb 2019 17:41:53 +0100 From: John Ogness To: Petr Mladek 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 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> Date: Mon, 25 Feb 2019 17:41:50 +0100 In-Reply-To: <20190225121106.oig7s6odqikcn4xw@pathway.suse.cz> (Petr Mladek's message of "Mon, 25 Feb 2019 13:11:07 +0100") Message-ID: <875zt7bz1t.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. John Ogness