Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4529866imj; Tue, 12 Feb 2019 18:38:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IYA9ZLaHYHclzrZi3hEmKjDCpagAjzv0muygxHyzLRS5I9MtqixsUNdQ1DszNGb372yjDMw X-Received: by 2002:a62:b2c3:: with SMTP id z64mr7153276pfl.149.1550025519694; Tue, 12 Feb 2019 18:38:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550025519; cv=none; d=google.com; s=arc-20160816; b=E8WrmKvgo6+OdOQ6woyi8u+/KNDKfgYN/Qpw5SBDkVVC+DqV8G/5JggyxkddMATBti 8iHPQ8D+tpBDhqTYH4+ijiphllGXFK9r9jI7sfJk3ZysBfRL+GMQxUMCj4xlfgn3WOTC m8AmH+idIv7jXstJSEOtbrRAykvn/U009DtBjFbGVxT6WzS5oj+4mbS4y3k989o+48m3 +AWNqN+f2d6TAxB0o09oBK1hoIj8/s5bdt/Df0BDdeGDqgVBHfEa1bivd4k5IoWAUM85 bTGVwB+K+qTtDH/PNgLNvwa899WCOK1kxEihT1b+sJreLX9hBGHgPu4nswamHvCm7Xzf BGDg== 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=u8ORMKanCS7msn/j0yfqCuZ7sBg7zyiiY6K/xZBXzfE=; b=EZwmL/fPZnwF6WmNUKA+HZiPQxDXATPlYHx6QgPJzssEFZo5HmL0RKV0IbuQOyKYER KxejpQZcU/qSt4Bjm1K9Fs8ZTvmXK9QnVnBG8OedKbg6zUyXxWnbMGeuzabht5e5jAq3 Jv1xPw0EMuq5mnqIEZT3U+h2bUW5+joT//ARFZBGgmpxVHDSwajQCZk7oxymqsLKixZd C+pf7s+jNMw+VtTS8vqTGECbWEGPnLn6Hq4Q2OEcx43YVa7cClVKbtoa8FxoqPM5Y/AB 8lk5pXxU/PNa9aMIjxZHbWKsSfBkge0mfJ/Xo1qNLSArCfkx4lWUiPd3Jnts+MBlABIi 6r6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UOxNlfEz; 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 d64si13848070pgc.413.2019.02.12.18.38.23; Tue, 12 Feb 2019 18:38:39 -0800 (PST) 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=UOxNlfEz; 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 S1732745AbfBMBbH (ORCPT + 99 others); Tue, 12 Feb 2019 20:31:07 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43579 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728339AbfBMBbH (ORCPT ); Tue, 12 Feb 2019 20:31:07 -0500 Received: by mail-pf1-f194.google.com with SMTP id q17so335451pfh.10; Tue, 12 Feb 2019 17:31:06 -0800 (PST) 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=u8ORMKanCS7msn/j0yfqCuZ7sBg7zyiiY6K/xZBXzfE=; b=UOxNlfEzKZ73BS9nodoz3m03nyqKSaIcikvL56L+IIaBGBXJV7xCq+tkB6iHN3QV3o j+ZZPXlWK59IEwmQQrw2rHo4WiB0Eye2OEPY9S5CHB0jou07C4ov30hMlh8dATiWvZ6p PDhaOmcKYIKeqN2SHlOFnzA201T+1xN9qkq2Q93N+ktJTdXjCe3OqxiHwgDAinXLOfQ4 wxDansatpHODcQL9MFrr9M1q2Zs8Q1T+soDge/jqASvFV9XCb6SbnuiQ+S+hLzh3U+Xq lgjypN2dK53dGP6yn/mHUCCGWfBo1766xnPeNt7iuXIaYTbmuHLMlAWPE/vJ8WvWCEfq Xz9Q== 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=u8ORMKanCS7msn/j0yfqCuZ7sBg7zyiiY6K/xZBXzfE=; b=kQkBnkvPzVqin4iCfkXwwigAkEYRdhXFReS4i9MPUGoggi2iwif04FfvlVXdDogEzG Bv4L70lRl7aTpQLaqjESvnDRTfKW4aY5w8d5qrw7wX/mwNY9PRfSVAdR0uEv01QcSKT9 QJbTlwBy0UDJAJ+Uvq9TO6vlab0Gv2EuZcgX19+XCpYMB+HJ6ILO62Omm8mHUPWTlmZ9 dw+7p4+WAfRywuPN3WokiB1+39cQadaa4ppXNQJQgD2Pkw5QsYIee7G+kClLq5+gz8rI /XPXmohFeGJm8OBt35VsNq16K7XTkbG0UuV3deONAxfJ4HRKc65TMDcl1+Vhnf7+2bgF ETCw== X-Gm-Message-State: AHQUAuZtuE9KvcbCr5T5SexuxuQ960LLjFW1L0sfypGeLz2EdcMsaBmS XlTb6I778+H4gSvfKkwGSQk= X-Received: by 2002:a62:b2c3:: with SMTP id z64mr6886232pfl.149.1550021466360; Tue, 12 Feb 2019 17:31:06 -0800 (PST) Received: from localhost ([39.7.15.189]) by smtp.gmail.com with ESMTPSA id k17sm190245pfj.92.2019.02.12.17.31.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Feb 2019 17:31:05 -0800 (PST) Date: Wed, 13 Feb 2019 10:31:01 +0900 From: Sergey Senozhatsky To: John Ogness Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Daniel Wang , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , Alan Cox , Jiri Slaby , Peter Feiner , linux-serial@vger.kernel.org, Sergey Senozhatsky Subject: Re: [RFC PATCH v1 00/25] printk: new implementation Message-ID: <20190213013101.GA8097@jagdpanzerIV> References: <20190212143003.48446-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190212143003.48446-1-john.ogness@linutronix.de> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (02/12/19 15:29), John Ogness wrote: > > 1. The printk buffer is protected by a global raw spinlock for readers > and writers. This restricts the contexts that are allowed to > access the buffer. [..] > 2. Because of #1, NMI and recursive contexts are handled by deferring > logging/printing to a spinlock-safe context. This means that > messages will not be visible if (for example) the kernel dies in > NMI context and the irq_work mechanism does not survive. panic() calls printk_safe_flush_on_panic(), which iterates all per-CPU buffers and moves data to the main logbuf; so then we can flush pending logbuf message panic() printk_safe_flush_on_panic(); console_flush_on_panic(); We don't really use irq_work mechanism for that. > 3. Because of #1, when *not* using features such as PREEMPT_RT, large > latencies exist when printing to slow consoles. Because of #1? I'm not familiar with PREEMPT_RT; but logbuf spinlock should be unlocked while we print messages to slow consoles (call_consoles_drivers() is protected by console_sem, not logbuf lock). So it's spin_lock_irqsave(logbuf); vsprintf(); memcpy(); spin_unlock_irqrestore(logbuf); console_trylock(); for (;;) call_console_drivers(); // console_owner handover console_unlock(); Do you see large latencies because of logbuf spinlock? > 5. Printing to consoles is the responsibility of the printk caller > and that caller may be required to print many messages that other > printk callers inserted. Because of this there can be enormous > variance in the runtime of a printk call. That's complicated. Steven's console_owner handover patch makes printk() more fair. We can have "winner takes it all" scenarios, but significantly less often, IMO. Do you have any data that suggest otherwise? > 7. Loglevel INFO is handled the same as ERR. There seems to be an > endless effort to get printk to show _all_ messages as quickly as > possible in case of a panic (i.e. printing from any context), but > at the same time try not to have printk be too intrusive for the > callers. These are conflicting requirements that lead to a printk > implementation that does a sub-optimal job of satisfying both > sides. Per my experience, fully preemptible "print it sometime maybe" printk() does not work equally well for everyone. -ss