From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S969936AbdD3QMK (ORCPT ); Sun, 30 Apr 2017 12:12:10 -0400 Received: from smtprelay0238.hostedemail.com ([216.40.44.238]:46891 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S967182AbdD3QME (ORCPT ); Sun, 30 Apr 2017 12:12:04 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:355:379:421:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:5007:7903:9108:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12533:12740:12760:12895:13069:13161:13229:13311:13357:13439:14659:14721:21080:21433:21451:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: lead82_68a4862aea228 X-Filterd-Recvd-Size: 2096 Message-ID: <1493568716.1874.7.camel@perches.com> Subject: Re: [PATCH] printk: Add best-effort printk() buffering. From: Joe Perches To: Tetsuo Handa , linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt Date: Sun, 30 Apr 2017 09:11:56 -0700 In-Reply-To: <1493560477-3016-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> References: <1493560477-3016-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2017-04-30 at 22:54 +0900, Tetsuo Handa wrote: > Sometimes we want to printk() multiple lines in a group without being > disturbed by concurrent printk() from interrupts and/or other threads. > For example, mixed printk() output of multiple thread's dump makes it > hard to interpret. > > This patch introduces fixed-sized statically allocated buffers for > buffering printk() output for each thread/context in best effort > (i.e. up to PAGE_SIZE bytes, up to 16 concurrent printk() users). [] > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c [] > +#define MAX_PRINTK_BUFFERS 16 > +static struct printk_buffer { > + unsigned long context; /* printk_context() */ > + unsigned int nested; > + unsigned int used; /* Valid bytes in buf[]. */ > + char buf[PAGE_SIZE]; > +} printk_buffers[MAX_PRINTK_BUFFERS]; Perhaps these buffers could be acquired by alloc_page rather than be static structures and the sizeof buf[PAGE_SIZE] should be reduced by sizeof(unsigned long) + sizeof(unsigned int) + sizeof(unsigned int) so that struct printk_buffers is exactly PAGE_SIZE.