Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp1610603imp; Fri, 22 Feb 2019 07:08:31 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibxw6BHoCgZG/bZMWDRNzXt4xuFH8+fKi1rD3S6pdnIpeyKhB+pEwvUams73qxUBAmqxSaR X-Received: by 2002:a65:6553:: with SMTP id a19mr4408307pgw.267.1550848111553; Fri, 22 Feb 2019 07:08:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550848111; cv=none; d=google.com; s=arc-20160816; b=f1kAykL8JG+pmxydg5iCOt2lOMLIhHJCHmL1BZbfzgcApJFaWBVzDLkaxD9+wNCLg3 C8nzz/HFiZCrHfGJJ8NaGpBq5kwMuoumH63kvoFUjJ5ZT6JJdSc1KboREg9xu9nHnK78 w+rhcwxPB4oN80TwvYhbQn5eUSiXTSIaDO1O848FefU/RKm8aqoFmEmrxKWxxveKKBl5 Tb2ir4h+BjPcvcboeUL5FwVeVoP3qtlcwwbJneuQB7ZC9Zjun6WYoS8CYyp5yBkGSHv3 1jQKscq8TpH0UreaXmOHRvgIEdiwJeMpCYSoy0DIeXXiq2ehPMRrK9LrihClPkt6yJMo rszQ== 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=Yuktq3yrmg4dZz+x2gq89BJlQmL5zwU1xlcWniP8hxo=; b=QLhGh5zh7fwql1nl4kQPbggY2jAM0khdQ/IsrfpdZ9tFAu3Wu3Sy5/ptqcHOaImbuD /xPcxuPf6WbkWlj5Ah39Gj91lEtN/mbRwHHUp/6ZegiGGAYz+4Ce7gWN/T5OGLsfKehb Fav74+1p1TQivn2fcpmAXMYLwOgb9SdDX7ocuVmHu6aFFOFnox3/czmQgCtZWWq9mXxE spnOf4nDtynq3OGjSfIrABXVPZZ774WLOxNwNQyRxK003Bu02SM8E9uGeUtuKpKOAQ5r UtoV1BxKvFwjSidwytaqCNtY2vBYxOwbNdb+R0jZXDFtne3+0WH0Hk+cBF8Lweji5Na7 vn/A== 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 u2si1478414pls.34.2019.02.22.07.08.16; Fri, 22 Feb 2019 07:08:31 -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 S1727015AbfBVPGg (ORCPT + 99 others); Fri, 22 Feb 2019 10:06:36 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:55623 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726278AbfBVPGg (ORCPT ); Fri, 22 Feb 2019 10:06:36 -0500 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gxCPD-0005bA-LI; Fri, 22 Feb 2019 16:06:27 +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> <20190222144302.44zl37p75qgaixf3@pathway.suse.cz> Date: Fri, 22 Feb 2019 16:06:26 +0100 In-Reply-To: <20190222144302.44zl37p75qgaixf3@pathway.suse.cz> (Petr Mladek's message of "Fri, 22 Feb 2019 15:43:02 +0100") Message-ID: <87va1byia5.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-22, Petr Mladek wrote: >>>> + rbuf = prb_reserve(&h, &sprint_rb, PRINTK_SPRINT_MAX); >>> >>> The second ring buffer for temporary buffers is really interesting >>> idea. >>> >>> Well, it brings some questions. For example, how many users might >>> need a reservation in parallel. Or if the nested use might cause >>> some problems when we decide to use printk-specific ring buffer >>> implementation. I still have to think about it. >> >> Keep in mind that it is only used by the writers, which have the >> prb_cpulock. Typically there would only be 2 max users: a non-NMI >> writer that was interrupted during the reserve/commit window and the >> interrupting NMI that does printk. The only exception would be if the >> printk-code code itself triggers a BUG_ON or WARN_ON within the >> reserve/commit window. Then you will have an additional user per >> recursion level. > > I am not sure it is worth to call the ring buffer machinery just > to handle 2-3 buffers. It may be slightly overkill, but: 1. We have the prb_cpulock at this point anyway, so it will be fast. (Both ring buffers share the same prb_cpulock.) 2. Getting a safe buffer is just 1 line of code: prb_reserve() 3. Why should we waste _any_ lines of code implementing the handling of these special 3-4 buffers? > Well, it might be just my mental block. We need to be really careful > to avoid infinite recursion when storing messages into the log > buffer. The recursion works well. I inserted a triggerable BUG_ON() in vprintk_emit() _within_ the reserve/commit window and I see a clean backtrace on the emergency console. John Ogness