Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp453878ybd; Wed, 26 Jun 2019 00:48:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2ScVtdavCkg6PtAIRz0XulphjHt1LCrRjjqVWCgpJbblQLv2/YIjfNV39iU3IiVM0HmyW X-Received: by 2002:a63:fc52:: with SMTP id r18mr984582pgk.378.1561535297538; Wed, 26 Jun 2019 00:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561535297; cv=none; d=google.com; s=arc-20160816; b=LMhAR/kwdILi8SlsRaakeKphn97tXZMg1bdwD4YrYpA+1UySlcfUdtLWxWGT14V7M/ 2zJ94Ova5VymK0xzKIaRh5n66BKyYY3LWMvK2Eh0OMnTV4/FvIZgNM1bs8dWHzfbjXXG q46q/ZdJbaoZ+QxN0VKEewurdDHHNimbsPN8W1fESN/+Lyb/wL0w3BGMkWptIrB1TfVG D3hgn1V9LvluixsZchrBXqXlhOEl9Ik5SCSAlmr1/6Qom/yJ2VAfH+N8wJzDKX6f6Okq BLOIgiOKGSeEjqzuuwlGDFdUdAEcVmFNEhr5IOYQZqk4WF7d1lBqqcF1QldZK8LKX80g oM0w== 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:dkim-signature; bh=dM7vYsgBxvjACyk/KNCx14abdUKYm6wDW0lC29USMFM=; b=pa6iC6ElYG9bTTIuEZDAQBI9nf2UJIGP+pO1POfelWRPnkxvTt2Zt/jcyDVbWs1Jw3 2m7C9LtzcJAnBwRqElY1VLOzet/8D5JqlnGgfXSaFyy5Uy5TH/rrOBo6+LA2wU1nz082 h+X0SDRNHJNuXY40UGozvxhqwS2ArCJLtXtX589AL0C17beuQTQnduZGN8B0V8eEzMLC vj5sWkok3ryYFU/I6Exr0MIS5EhDF6Hy9SDhyJYg7xc6l70zsz7CkzjY+KCXqiZr60Op My7NV2dfXAvuQp6BOI2I5XZ9VIkdMh+Raro6lDM10j1NqGTcUFBQciwCj421fe28AWv4 pQ6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KrdhRaNh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si2557116pla.259.2019.06.26.00.48.00; Wed, 26 Jun 2019 00:48:17 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KrdhRaNh; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726902AbfFZHpw (ORCPT + 99 others); Wed, 26 Jun 2019 03:45:52 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:46519 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfFZHpv (ORCPT ); Wed, 26 Jun 2019 03:45:51 -0400 Received: by mail-pl1-f194.google.com with SMTP id e5so946497pls.13 for ; Wed, 26 Jun 2019 00:45:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dM7vYsgBxvjACyk/KNCx14abdUKYm6wDW0lC29USMFM=; b=KrdhRaNhf8ZuMC8OlOHOMqqWLX82y7oRuCkfl46uD0d3n3q5ihh/SuvxMSUSmOfvQr yT2SFctPttYAjOmKSAcfQP4kEVCzX5EZuhVBG0NF34bTjd9I7YIGEJda8eZWu9Dd+cO3 wtuAdXKTE1ZuIx/p5Jubqs/Kaz6p1YzPAvY9EQ76yjyD6KFZ0vHMFNwEEbq9O9r9Fy6N 7uJMSZRfp4uasBgvNoVnZixRPa+8gVaAtAmaTFoGJiMiuC/hcA1c6fsx5/ueg07jDrb3 QjSqhT5dDfLFA5S3U0WJ1vPneLjFcUBwgkbLZF24/cMBnCOdc01WfU5ZTtVxMV9+pCi0 h9qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dM7vYsgBxvjACyk/KNCx14abdUKYm6wDW0lC29USMFM=; b=kf50j0uPQAI22RDLAEy5ut6V8FZrMwzhIoJxYLxa04EOdaQIDlUJ4eWXL/Lai1Eioc zHNHtzHp7C7LdDtLV1P4tIydvevxKIrLgyAs693skeQukaEd8wkfx8zUYiwkaMeLkQ71 hFnX2Tox4SeRzBZuaTx4QBll0RRzkMxD1LeJpU6XWKWiCCHtAaagv5RC+9y+wqHxlOT9 4YNibNw1LpfXi7smCip4lZ9JCqDwdU1wOK+0hK0an6851j9yLSPfdIucdlSkRGfqdjqp p9HtOj4o5UtnFm/Zllarw3pIrMrJEuq59xznAJIqzIzQ+tvUZR78E6kXoeHcDRx6EbpN 7isg== X-Gm-Message-State: APjAAAX3RF+2vf5BgWtOZYqv0Kr6hTl+DZmomXOc1XeFZEj/XncF/nQU 6iTSVt0bttJ/1tshIjJsGHHn+xuM X-Received: by 2002:a17:902:6b44:: with SMTP id g4mr3790429plt.152.1561535151300; Wed, 26 Jun 2019 00:45:51 -0700 (PDT) Received: from localhost ([175.223.45.10]) by smtp.gmail.com with ESMTPSA id b11sm15686581pfd.18.2019.06.26.00.45.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 26 Jun 2019 00:45:49 -0700 (PDT) Date: Wed, 26 Jun 2019 16:45:46 +0900 From: Sergey Senozhatsky To: John Ogness Cc: Sergey Senozhatsky , Petr Mladek , linux-kernel@vger.kernel.org, Peter Zijlstra , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky Subject: Re: [RFC PATCH v2 1/2] printk-rb: add a new printk ringbuffer implementation Message-ID: <20190626074546.GA31547@jagdpanzerIV> References: <20190618045117.GA7419@jagdpanzerIV> <87imt2bl0k.fsf@linutronix.de> <20190625064543.GA19050@jagdpanzerIV> <20190625071500.GB19050@jagdpanzerIV> <875zoujbq4.fsf@linutronix.de> <20190625090620.wufhvdxxiryumdra@pathway.suse.cz> <20190625100322.GD532@jagdpanzerIV> <87woh9hnxg.fsf@linutronix.de> <20190626020837.GA25178@jagdpanzerIV> <87mui43jgk.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mui43jgk.fsf@linutronix.de> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (06/26/19 09:16), John Ogness wrote: > On 2019-06-26, Sergey Senozhatsky wrote: > > [..] > >> In my v1 rfc series, I avoided this issue by having a separate dedicated > >> ringbuffer (rb_sprintf) that was used to allocate a temporary max-size > >> (2KB) buffer for sprinting to. Then _that_ was used for the real > >> ringbuffer input (strlen, prb_reserve, memcpy, prb_commit). That would > >> still be the approach of my choice. > > > > In other words per-CPU buffering, AKA printk_safe ;) > > Actually, no. I made use of a printk_ringbuffer (which is global). It > was used for temporary memory allocation for sprintf, but the result was > immediately written into the printk buffer from the same context. In > contrast, printk_safe triggers a different context to handle the > insertion. I agree that's not relevant to your patch. But let me explain what I meant. printk_safe has many faces. The NMI part of printk_safe has the PRINTK_NMI_DIRECT_CONTEXT_MASK bufferring bypass - when we know that we are in NMI and printk logbuf is unlocked then we can do the normal logbuf_store() from NMI, avoiding irq flush because the data is already in the main log buffer. We also can do the same buffering bypass for non-NMI part of printk_safe, but just sometimes. PRINTK_SAFE_CONTEXT_MASK most of the times indicates that logbuf is locked, but not always - e.g. we call console_drivers under PRINTK_SAFE_CONTEXT_MASK. But like I said, not relevant to your patch. The relevant part is the possibility of race conditions. > It is still my intention to eliminate the buffering component of > printk_safe. That's understandable. > After we get a lockless ringbuffer that we are happy with, my next > series to integrate the buffer into printk will again use the sprint_rb > solution to avoid the issue discussed in this thread. Yes, I agree that either sprint_rb or just 2 LOG_LINE_MAX per-CPU buffers looks safer. This basically means that printk cannot use printk_ringbuffer as is and needs some sort of extra layer next to (or atop of) printk_ringbuffer, but we have the same thing in printk right now, basically. static char textbuf[LOG_LINE_MAX] -> logbuf. -ss