Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp151736pxk; Thu, 24 Sep 2020 01:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7uev6V4dhqIlzTyTE4WMKqxFRr8L4GOoLXzcOL2rBCG+Jn2NoWJz837hAQ9Y06iVeWzg4 X-Received: by 2002:a17:907:1116:: with SMTP id qu22mr3338166ejb.231.1600937885785; Thu, 24 Sep 2020 01:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600937885; cv=none; d=google.com; s=arc-20160816; b=btd8MrsITE5k2clFaH9csBx4/r0CNdd50HGsTtCwSKUKqVLUkBS/zVaLAw2ZT7meS3 1C2Pk9xGSTWL1DClg1gtUYye4mL16hUqYgSbLSHmTnOgsHvFR0RfpKpPzBF5pfARHHZG F8FAB8d3CQsxDuR5CwO7RRyCLPky3xNjPPg84bVeN98naFTXpoqXN5x2oSFx2lUfSxcD Jo5sHvwBMF8+sQRH90ZL9FWefMeS7wGBxVAruMR2BhYESejyjap6PwlO2uAPf94bXyK4 pg8GTndN5a5duvfxIOKtuwTqBdjPqxQ03SwqIqVIfXC+I3jdcSRKGDov+xdJPPZcq3FI td2g== 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=Gnupa/FLLl5BSc73ruXnxSmNk2cnUZqVStpXpBHlSG8=; b=YmICaKldWZoPErKVu+2DS36F9NJEswsMfMN9ok7p/ZEFRJJjAYmH7JnqOzliWFMOJj ScTCUknxy1auvUR0xTtSbz4oLhO4P8xXJ8FIAKCdJuLgbxTz0B+59zqI4LwXuC73HxRH qjbIt9FblyMozKgHgKRJWsuIl4zqMmmBrlQtPBVEyCmEfgf+qSMlacTNKUbC6Zpub3l9 PpubV0+LxdGK2PvrcPlSpLqW9YuZ3F3kHi6BIIf/gOZyEBK/Df8sbSaUgmF2rk/UDK7D ta93X/ksaKtN2S9oABemiQuw9J8KynZJIMvvC2nWDNVJkHzrbNG262u8nrY0E8/xb/qd IUHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=NPezC9Qd; 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 yj16si1936936ejb.592.2020.09.24.01.57.42; Thu, 24 Sep 2020 01:58:05 -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=NPezC9Qd; 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 S1727325AbgIXIys (ORCPT + 99 others); Thu, 24 Sep 2020 04:54:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:36166 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727287AbgIXIyr (ORCPT ); Thu, 24 Sep 2020 04:54:47 -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=1600937685; 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=Gnupa/FLLl5BSc73ruXnxSmNk2cnUZqVStpXpBHlSG8=; b=NPezC9QdftkpIrnAMch7/Gy7kMVeJhInMg8bpApfN7KFE0oNMe+k0ReKvOTPO/sW8KPEO8 9pGc7ShExvqmDy6iNhP84GbFjbYzMrnXkBZs7Zjnv7CCTp/X2ly20sNPAtXuAcEZ/KgGB7 w+sBMUijR6BI4MqCAydIP5CK1Ng6nzY= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id AA9B0ABF4; Thu, 24 Sep 2020 08:55:23 +0000 (UTC) Date: Thu, 24 Sep 2020 10:54:45 +0200 From: Petr Mladek To: Sergey Senozhatsky Cc: John Ogness , 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: <20200924085445.GK6442@alley> References: <20200922153816.5883-1-john.ogness@linutronix.de> <20200922153816.5883-4-john.ogness@linutronix.de> <20200924061746.GF577@jagdpanzerIV.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200924061746.GF577@jagdpanzerIV.localdomain> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-09-24 15:17:46, Sergey Senozhatsky wrote: > On (20/09/22 17:44), John Ogness wrote: > > +/* > > + * The sprint buffers are used with interrupts disabled, so each CPU > > + * only requires 2 buffers: for non-NMI and NMI contexts. Recursive > > + * printk() calls are handled by the safe buffers. > > + */ > > +#define SPRINT_CTX_DEPTH 2 > > + > > +/* Static sprint buffers for early boot (only 1 CPU). */ > > +static DECLARE_BITMAP(sprint_static_textbuf_map, SPRINT_CTX_DEPTH); > > +static char sprint_static_textbuf[SPRINT_CTX_DEPTH * LOG_LINE_MAX]; > > + > > +/* Dynamically allocated sprint buffers. */ > > +static unsigned int sprint_dynamic_textbuf_count; > > +static unsigned long *sprint_dynamic_textbuf_map; > > +static char *sprint_dynamic_textbuf; > > Just a question: > > Can dynamic_textbuf be a PER_CPU array of five textbuf[1024] buffers > (for normal printk, nmi, hard irq, soft irq and one extra buffer for > recursive printk calls)? That would be my preferred fallback when the approach with vsprintf(NULL, ) is not acceptable for some reasons. But I still think that calling vsprintf(NULL, ) is the most trivial and good enough solution. IMHO, the solution with per-CPU buffers is not that trivial, for example: What if recursive printk() is interrupted by NMI and it causes yet another recursion? Is one level of recursion enough? Best Regards, Petr