Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp553346pxk; Wed, 23 Sep 2020 09:45:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgDS9QEiuZzQIki2Mx9LOf7Ki0N5dGfb9C0oeE+gCqnKxtSRuzUOly899RqkJ13ASoJWy7 X-Received: by 2002:a50:a6c2:: with SMTP id f2mr176019edc.227.1600879500055; Wed, 23 Sep 2020 09:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600879500; cv=none; d=google.com; s=arc-20160816; b=tPVERhmGdYXhosHf4cxk3ix4mDfKLQzu4Mxg38BpQCq83BgXfP3IZ0/e4g1J7jsUlv cEwcW/dW9OedG/XLsr+yzdUVpp8KdJLmVLXCcdtoj6FwMJ9tMr12LS+i1VmLisSragIM UwPIkgTbQhdeu2Q447H5nQ7VZu5CP4f2OqP78XBvEr51rVr34mfQhAE2XiwIXREhXKA3 QQ0e670qgnRV93SZnCaHmpODWUuur6zAn2KZMEn2nRQnXGLWrcn38aCBr6L9R5ERyA1J 9aBX3vPTv5ZrXrGm8ifvkCrAej7JxjlglbH3p+BmhspEw1G1vpkOJFzFfNXtJikllMp1 iIZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=IM69qc/OE8PO5fk7UQqc5zqiXF1MhlwGn7B85mXjcM4=; b=znZD95sVfw+mvDeyd5hZIunsjUVM0RkESFcZ50UmlRr0q+kNfNEIsR6lWsBIkbQvwX f568bXfAiU4/m3/uNyFS1FsVstJT28bensI1/j3p6p3tNo2BQCbWl+E51uoxwaiFWN8N dO0NTwb2pwzgFawJ245AA1MgMzzFqXt0T9Jt9FKTXk3tp85Kpl93b2F8XDRyqPVky58H tYc9vCtZK2HL0nXcaOgwbnXUaHDo4VP8pqxgMGuc5k/p+jjlFgK4DqmokV8nI+5huCff BtgY23tPDyaWq12XO3iYtvfYhT8zYq3cRvbIj0PnR92eFtaqPQYvZJaPtYlotRjJzzy6 pDag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=WCfbu7ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u7si214749edo.567.2020.09.23.09.44.37; Wed, 23 Sep 2020 09:45:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=WCfbu7ch; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726634AbgIWQlr (ORCPT + 99 others); Wed, 23 Sep 2020 12:41:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:33222 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726130AbgIWQlq (ORCPT ); Wed, 23 Sep 2020 12:41:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1600879305; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IM69qc/OE8PO5fk7UQqc5zqiXF1MhlwGn7B85mXjcM4=; b=WCfbu7chftYh7/i4FIfm86OVHIr0goskgXU8g4XjmJmwiX2TbjAS61GML1iY0Sva90Z9Gj Y3bzIftyJnjZZElskfJ/8sIiqmjy42r757tPWDxt3CqaNiGNpoAUtbG059blQvQ8ixoxB8 fiVLcqk4+AtoJ8MEmfvNV2kJyyd1g50= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4D178AAC7; Wed, 23 Sep 2020 16:42:22 +0000 (UTC) Date: Wed, 23 Sep 2020 18:41:44 +0200 From: Petr Mladek To: David Laight Cc: John Ogness , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Thomas Gleixner , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH printk 3/5] printk: use buffer pool for sprint buffers Message-ID: <20200923164144.GF6442@alley> References: <20200922153816.5883-1-john.ogness@linutronix.de> <20200922153816.5883-4-john.ogness@linutronix.de> <20200923151129.GC6442@alley> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2020-09-23 15:21:41, David Laight wrote: > From: Petr Mladek > > Sent: 23 September 2020 16:11 > > > > On Tue 2020-09-22 17:44:14, John Ogness wrote: > > > vprintk_store() is using a single static buffer as a temporary > > > sprint buffer for the message text. This will not work once > > > @logbuf_lock is removed. Replace the single static buffer with a > > > pool of buffers. > > > > The buffer is used because we do not know the length of the > > formatted message to reserve the right space in the ring buffer > > in advance. > > > > There was the idea to call vsprintf(NULL, fmt, args) to count > > the length in advance. > > > > AFAIK, there is one catch. We need to use va_copy() around > > the 1st call because va_format can be proceed only once. > > See, va_format() in lib/vsprintf.c as an example. > > > > Is there any other problem, please? > > Potentially the data can change after the vsprintf(NULL, ...) > call so that the buffer isn't guaranteed to be the right length. Yup. Well, in the worst case, we would shrink the text when the length increased in the meantime. The content of such a message is racy anyway. > Never mind the extra cost of doing all the work twice. IMHO, neither of this is worth the extra complexity with a pool of buffers. I would prefer to increase the complexity only when there are real life problems. Best Regards, Petr