Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp175106ybd; Tue, 25 Jun 2019 19:09:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMRMdyuPGqsF434Szi5tXx9a+pXK+5JaMivwQfEzoeJPrkSo+jmk+0ylflJCB5GwYI36Nw X-Received: by 2002:a63:e250:: with SMTP id y16mr184358pgj.392.1561514944460; Tue, 25 Jun 2019 19:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561514944; cv=none; d=google.com; s=arc-20160816; b=aNqxzIxm4z1O0pPs9DJHS9mgOXNMKL978RydCMbye3LSEf2edq4fM8iHbCfAbnhWuX MZD3H0UH3bSS24HBhVvYyLPTlBkoXH09hmgKI8HMkPM2GEUSakW16Uk5yUnPdTiXkX4Y u86DeiF2vGfoY5x7SuQ74+TGdZCHpkVNXLozV5xkzu5+wUh1SUf199A5qDS1RQJkSVuv BpOoonfXzxfregC9MTZRVfo3Ok3yKR0Y8heXzSk4dJ+3pX8dMrydfmiT/1x2/p8RMXq7 kXZ6CmXCAYABP4kyXeAz2V31GBTyg1K6PWF0PH1TkFFUkTrJayGF91vejUXKJac8tedA 8zTQ== 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=XuWQUH8JO1My/hziqtFzijpXAic/yIwdWsCsK+nonzM=; b=ify2qv4+j59BcrApBLD3s+93kKCAYqEl6RfTTR6sWTxw1u6Hki0lr97pAcTxGt7rLv srxhPjXJAaE8qEuPklyz1idgY20B+WCNmJpHWvgtf7DyGiXhGhjueILaTmQOtsYwaLtx E1ghqjK9Pbgk0cvid3yH2cEhybdYgtDL95oCud9z0UyQgo+2MfPrLFhgkVILNPxt+zZk 5jp4Db7gNJUXqs0hXb0+ySi0CXnFtdEuLnnknyGiK6CVoq69LJlRGxOccPSuqQ74yyvc Cv+08ZR+4YDQ8N+CuuqCDflCtX2IZ72/hqebuQ3GMY+AkgvZ1L4nPll7ndbXbJvkHEGr HvBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KGjJLH7c; 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 m20si572698pjn.40.2019.06.25.19.08.47; Tue, 25 Jun 2019 19:09:04 -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=KGjJLH7c; 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 S1726320AbfFZCIn (ORCPT + 99 others); Tue, 25 Jun 2019 22:08:43 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:39922 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbfFZCIm (ORCPT ); Tue, 25 Jun 2019 22:08:42 -0400 Received: by mail-pl1-f193.google.com with SMTP id b7so481316pls.6 for ; Tue, 25 Jun 2019 19:08:42 -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=XuWQUH8JO1My/hziqtFzijpXAic/yIwdWsCsK+nonzM=; b=KGjJLH7ccDtu3GEy1Y3TQpJmBYzXNW/b1SqbwdKLD1cRf7In+97nZ5tUjlc1RgplMt UfB7Wmhciq5X1fPicY6M9W3OOEXveQSIdUoIGqN06lEM9ThJLDQ/Jmv24GWS0d+CVu6R N+udjXFTG8xrjcoNPK6/bzV5LJYj5+bvQ7NBTx9xVzhIx+cQ8yLojsmdfMrpP9qpvVbH wjowa2hwnLEPm8YJh6xoHgPRls2FubXMOi6uC8R090dkUtslVx9x4/kcdFCrXD2MZvHW ch8YCgRD8nQ+Rad+qSpfmf7QcRG+eGOUI5V7IPPVhVL3JqpU1uBhKHpfVFnCT7vaVfRF vikA== 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=XuWQUH8JO1My/hziqtFzijpXAic/yIwdWsCsK+nonzM=; b=YmmE6b4KGMCcJmy1rctOzoLJG8hLUOrL2mh1HS+36G5Kk0/f8QtM/xOjTEmhqSBR3v JUmfUl2hV5q6KXoe4DFOkP6EkPzzSxyz1nR1TONSmHaLuwBmbtgWvDl/ymNFtzBYIn0o qS2HOGlwqeZ4OCNJRFpNNCKSUivXCHVmIWGdi4ENcl+13J4rMOV/pYU5qpDy5Gkap4iX RhGMRmrN+LvdUMaK+O4OHrKSm7rc2q0/vKYo+D6yU9jtGXR2i85iZqxaIpW0KEW2MAPc WxDFpUQYSZeVhLf2l/zfSsvs3wYpYpnhiZWKBePJv6Y1X4KHURZVj/cPknsUJH0aCmPt ln7A== X-Gm-Message-State: APjAAAW1CNt0o/0p/ZW03LEag6SgYGXLFr0qW2UyvDE/KwAix5NkIqPo PbIOCVRaFTcnPzOwHHUYVxg= X-Received: by 2002:a17:902:b70f:: with SMTP id d15mr1995628pls.318.1561514922145; Tue, 25 Jun 2019 19:08:42 -0700 (PDT) Received: from localhost ([175.223.45.10]) by smtp.gmail.com with ESMTPSA id x3sm319311pja.7.2019.06.25.19.08.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 19:08:41 -0700 (PDT) Date: Wed, 26 Jun 2019 11:08:37 +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: <20190626020837.GA25178@jagdpanzerIV> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87woh9hnxg.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/25/19 14:03), John Ogness 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 ;) -ss