Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp427664ybd; Wed, 26 Jun 2019 00:17:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9QA9OoBfGjhrGRqjSC2vBl+QT0dnbQgxPzkSMD3YuG+vXZp9iq+phCfOf1C8rMFzOVrEr X-Received: by 2002:a17:90a:32e4:: with SMTP id l91mr2986036pjb.17.1561533479810; Wed, 26 Jun 2019 00:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561533479; cv=none; d=google.com; s=arc-20160816; b=zzeszZENfWhM5YULXyK3TXBlh92tejGPkKCFbMkVtJQ1uhsF53MwU4ra//E1w+LL6/ 9oMP6dj1OBrfV++F726LmRoYQ4+dE87Hin2BNBUGvkqI+l8c/S9CjWhTxPEm2JnBjYhL xpHx0KMTEbYWXFJ1G03OM2uFdph5FiLeIoOoSMBvkkwB/cEyaCt9gBim5I09hxAnXNHX 7HqrSoJUnQd5DbwHpRehC3Sg1EQ6vWmrElxRm2BI741p56XQtyXr9kZKShH/cLBiOS8W Qnr5sxG5Zh0tQ2Zx1a/ejdP4WsB8CIqpQ4N2pFoM3ck1OgzEDDJgjb+328X9nJmtCjfh 6Qew== 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=CEy56TYlpHNcETLcHU3u+QwzeY3kIt90ketAvQlxM8Y=; b=Ho9QnGewEpUo2+qPElx1ZnDlnNComKM6rCKNWVd6dnEHXScnGn2aHbcMYy2ORh/jcE NO8X/2N4AtrtVjrqf8+kd2beHhZ42ZjvcrJhN+4psxowIcksd/MkNZ4s2u2Usv8Vl7QF IVaqeoXza1gjh1mUeUbHb9KcoEBSbMCVjLRMUFlD4tHdFIo9tzF082/53Ui/xNbfKVqb eMEEZdxg29FAHLqJ0HmepFJRAyN4IUvZnl+deggWS/CAgJOnHYKSGzGnVYU+4aEUbs02 LS8p9d6zWb7xEF/MKvsmCGitw30IvPSDFtuNcLwO9pHLCCpn8c/+w17wqtR0MQhaLEf1 dJyg== 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 n11si14373342pgq.498.2019.06.26.00.17.43; Wed, 26 Jun 2019 00:17:59 -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; 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 S1726788AbfFZHQV (ORCPT + 99 others); Wed, 26 Jun 2019 03:16:21 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:45239 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725876AbfFZHQV (ORCPT ); Wed, 26 Jun 2019 03:16:21 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hg2A8-0006V9-Lf; Wed, 26 Jun 2019 09:16:12 +0200 From: John Ogness To: Sergey Senozhatsky Cc: 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 References: <20190607162349.18199-1-john.ogness@linutronix.de> <20190607162349.18199-2-john.ogness@linutronix.de> <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> Date: Wed, 26 Jun 2019 09:16:11 +0200 In-Reply-To: <20190626020837.GA25178@jagdpanzerIV> (Sergey Senozhatsky's message of "Wed, 26 Jun 2019 11:08:37 +0900") Message-ID: <87mui43jgk.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-06-26, Sergey Senozhatsky wrote: > [..] >> > CPU0 CPU1 >> > printk(...) >> > sz = vscprintf(NULL, "Comm %s\n", current->comm); >> > ia64_mca_modify_comm() >> > snprintf(comm, sizeof(comm), "%s %d", current->comm, previous_current->pid); >> > memcpy(current->comm, comm, sizeof(current->comm)); >> > if ((buf = prb_reserve(... sz))) { >> > vscnprintf(buf, "Comm %s\n", current->comm); >> > ^^^^^^^^^^^^^^ ->comm has changed. >> > Nothing critical, we >> > should not corrupt >> > anything, but we will >> > truncate ->comm if its >> > new size is larger than >> > what it used to be when >> > we did vscprintf(NULL). >> > prb_commit(...); >> > } > > [..] >> 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. It is still my intention to eliminate the buffering component of printk_safe. 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. Perhaps it would be best to continue this discussion after I've posted that series. John Ogness