Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp786990ybe; Fri, 6 Sep 2019 07:19:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeQ6vm/rYJPGiIslwKR8Mh/lcnydLBW9X6aOA5fpaIUHZi2DO8fzXkyoLB6+U+JfoNwHD4 X-Received: by 2002:a17:90b:948:: with SMTP id dw8mr9997372pjb.48.1567779589724; Fri, 06 Sep 2019 07:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567779589; cv=none; d=google.com; s=arc-20160816; b=eFCCiUbyAsqC8lwJFWkK/rL7Sgk+JYLspe/7kDubUmdF4yad5MdDSe/JxhCWjB7/vV No3ENwt/UXZxFE2Ka1AETIhiJrLV2c9gHhl+E6qbhegTeIJYXagiTqYDOAOI5uXlco40 U4oroSd1XZB6Zi8nnmb10b3/87beTu8Re7ZjrTXlSILVdeAiRhmtbHTODvxDdS6jb3sx 2h2kKcdNquOzRiCuz1BXpLoZLQnjKeYGfjVqAOk0+y+L+Mpob1nugPpODj9NeCl+qXCG mGek1x/KV+DrZJBnXACrHxq/uxavSfHe8nIF0mYh+bGO6mn/60+l//pqYQTIfGbNspTi NE6Q== 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=mPlEyz3pTYtQ2PRdAV0S+EQaWH5tHTmS4heiquzIdK4=; b=Rybv9W4pDPjnot0ZWgGOM9zaR2SK0isBzJrQOmtS9ADp5paRuAuubxtHW28xILcoQj Vh2SAjuGAy//TLsG9WsvQb5U/AiLon9m4kZUr1ZBcUxFj5r/Uk5ZFddN3ZfNfrswOv/P sTxX2GYFAzFWq2/FzMdmQO6bkuVqg5Vu5158MdMB2C2A554y0rW7V3nv02jpQ9xGS5Pf YChXJABGHkxSHoHdI+KAJ8D6X1Xcgi+GvmlmYrtB/OxDdG+i5hHBd86OkxY0FMf0fhch iJXQWK1FlRTRhlsv7bqxwN35XTxM059NC7bLhXiFx7uQVfhSCoczY5k1K6MVjOsOYaKt eL6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GzHu9b16; 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 d7si4687253plr.215.2019.09.06.07.19.33; Fri, 06 Sep 2019 07:19:49 -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=GzHu9b16; 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 S2390835AbfIFKJt (ORCPT + 99 others); Fri, 6 Sep 2019 06:09:49 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45982 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733254AbfIFKJs (ORCPT ); Fri, 6 Sep 2019 06:09:48 -0400 Received: by mail-pg1-f195.google.com with SMTP id 4so3203217pgm.12 for ; Fri, 06 Sep 2019 03:09:48 -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=mPlEyz3pTYtQ2PRdAV0S+EQaWH5tHTmS4heiquzIdK4=; b=GzHu9b16+b83L8RCAs1A/8tSCMuuLX7crTu6pydCxnq9K7f0YxzOEes87MnbbrHGHN 9YCHQ//OiR5bVRa176WJzUkFTxMTU7rypHyQ96JZ1sRS5wq3qxm2nHrrkM3q2012Drcv Nfo8T/hnSvh3L9FRX2u6wqY5XppxdpPAJ0RI51JkpWBUzxaHv8RVDE9oVqDo64sfxdzn uun6VxJQIy0H5gtrmwKNiGsBx7tn62rJSqE3Y+jQ3eThHEYN/RryM2JFPsC2mwp+l+VW HZqj89qkaaX5+uu0z8ktJt3nasDhAda2Q2a6+kHfc4NZAW1w0Niw3BbJHVJeKDQcPQ1f nNXw== 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=mPlEyz3pTYtQ2PRdAV0S+EQaWH5tHTmS4heiquzIdK4=; b=GVczzIrsVJSm1SnPDG52n+V3V8KYsEhDf/rNHwxTCw0WShkP60YifX3iAOIO44qAYX rwjTkYM6JM+T2nDb/7pUyOHi44L0JXhxz05veoIRkUk22jEyuYSHLky3TPjwI7dYwpLN SD4MOmsSjiydaMfock5hYE+KMydr9s8AmZoHuP9me64Nt9zx46TZjrS1/U+yZGxzzDpM 6HN47T/af2j9cwPuwCDC3VQfVHQ2XZaPikkMiF4RL8eQYANDB2AZ3ys13Gdky0t/ctV4 JQb+e92mT66gh2tUCZiwMgPGE8//1yabeqwb5lZpNZBYVKCFFhxt/Q+JNV3LhFxguanC O/FQ== X-Gm-Message-State: APjAAAVY/O4mrtfPPinv+GHAIRc8iPiMlXvfAOytQ6gP+fohoVyMF4RY kEhyJjiWzbA9ln5gEnv0a8Xhy0/Z X-Received: by 2002:a17:90a:1c01:: with SMTP id s1mr8959839pjs.76.1567764588226; Fri, 06 Sep 2019 03:09:48 -0700 (PDT) Received: from localhost ([175.223.27.235]) by smtp.gmail.com with ESMTPSA id d14sm5997414pjx.8.2019.09.06.03.09.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Sep 2019 03:09:47 -0700 (PDT) Date: Fri, 6 Sep 2019 19:09:43 +0900 From: Sergey Senozhatsky To: Peter Zijlstra Cc: Petr Mladek , John Ogness , Andrea Parri , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Brendan Higgins , Thomas Gleixner , Linus Torvalds , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v4 0/9] printk: new ringbuffer implementation Message-ID: <20190906100943.GB10876@jagdpanzerIV> References: <20190807222634.1723-1-john.ogness@linutronix.de> <20190904123531.GA2369@hirez.programming.kicks-ass.net> <20190905130513.4fru6yvjx73pjx7p@pathway.suse.cz> <20190905143118.GP2349@hirez.programming.kicks-ass.net> <20190906090627.GX2386@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190906090627.GX2386@hirez.programming.kicks-ass.net> 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 (09/06/19 11:06), Peter Zijlstra wrote: > Another approach is something like: > > DEFINE_PER_CPU(int, printk_nest); > DEFINE_PER_CPU(char, printk_line[4][256]); > > int vprintk(const char *fmt, va_list args) > { > int c, n, i; > char *buf; > > preempt_disable(); > i = min(3, this_cpu_inc_return(printk_nest) - 1); > buf = this_cpu_ptr(printk_line[i]); > n = vscnprintf(buf, 256, fmt, args); > > c = cpu_lock(); > printk_buffer_store(buf, n); > if (early_console) > early_console->write(early_console, buf, n); > cpu_unlock(c); > > this_cpu_dec(printk_nest); > preempt_enable(); > > return n; > } > > Again, simple and straight forward (and I'm sure it's been mentioned > before too). :) --- diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c index 139c310049b1..9c73eb6259ce 100644 --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -103,7 +103,10 @@ static __printf(2, 0) int printk_safe_log_store(struct printk_safe_seq_buf *s, if (atomic_cmpxchg(&s->len, len, len + add) != len) goto again; - queue_flush_work(s); + if (early_console) + early_console->write(early_console, s->buffer + len, add); + else + queue_flush_work(s); return add; } --- -ss