Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4718135ybv; Wed, 26 Feb 2020 01:56:19 -0800 (PST) X-Google-Smtp-Source: APXvYqwXZ1L0ZTobokzEBsS8064T0jNAs2fmrJHRlW2NJ5YPHvTTswZPMSeBG3h1rlewSv1W6fmT X-Received: by 2002:a9d:65cb:: with SMTP id z11mr2127250oth.348.1582710979641; Wed, 26 Feb 2020 01:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582710979; cv=none; d=google.com; s=arc-20160816; b=GZ3nNKqawNGFk2azbaEqgSqMWxOuEAKQM0+71cyE2omZRTSPlRGwmIgcdmH9TN65+c Z7578pp9XeNrwHrRIY+7QWw87d4ncDVzaNbbyXcevj56ozfvsDmJKj8wAL+MTYFdqY7q 150U/707fcBYewgcvWYIifeBAxY/DceMk5DlQi7ph2nRoNNG5vquPpTiFuVHNG288Uh+ zwQrXS/SD0W+Zxz4PovO9RDyLI2RHnhpdsWJRHJEUDARsn0RNszmmRqUefJ4iTmUpMd4 1wSgjoEW+kXn04NvZkL2cDizHmVjUeLwnFNXCWuI3aYEfGnFSGl88BQa/84hOri4RHWG 75Mw== 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; bh=bpMFqytXtOx6Wf5dzx0HmocijKOzWc3hBdbvINqRfvI=; b=Yx5vvrl79JUg5tWPNKqL9/inP9lZgt/EjZtt7Aete0ALbLG7Odt1EV0JnkoWwZmdzG cQ1FQCcdCzsaDxMy29SPaTB7IkBv6S0V60mmoH/X1mp9L+3eAfWv6wudeFIAfCyRYoL0 xNuZoxSw3Jx1tewjqgW89kaE0zdoWl4VWs1cw2RxV50DfNr/iKgvs0j/C59aSbZG5+Gm GfVmhhWkQrF/0ym7U3zHFuJr/3N54mujR4yU2jPQaEuFXZtuyJI5DyAe6KH6VEF6QAR2 xvdS0l1nWPMsFr0TxRDbnOjRsAiMtxT9qiFn+aNinNeck8X3vaovAqAuMjcFwl99pcvA vmog== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3si973528otq.203.2020.02.26.01.56.07; Wed, 26 Feb 2020 01:56:19 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727815AbgBZJy7 (ORCPT + 99 others); Wed, 26 Feb 2020 04:54:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:42714 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgBZJy7 (ORCPT ); Wed, 26 Feb 2020 04:54:59 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4AD63AAB8; Wed, 26 Feb 2020 09:54:57 +0000 (UTC) Date: Wed, 26 Feb 2020 10:54:56 +0100 From: Petr Mladek To: John Ogness Cc: Peter Zijlstra , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: misc details: Re: [PATCH 2/2] printk: use the lockless ringbuffer Message-ID: <20200226095456.zrp256asr5ozvlf3@pathway.suse.cz> References: <20200128161948.8524-1-john.ogness@linutronix.de> <20200128161948.8524-3-john.ogness@linutronix.de> <20200217144110.xiqlzhs6ynoqdpun@pathway.suse.cz> <87h7zeqvf0.fsf@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87h7zeqvf0.fsf@linutronix.de> User-Agent: NeoMutt/20170912 (1.9.0) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 2020-02-25 21:11:31, John Ogness wrote: > >> --- a/kernel/printk/printk.c > >> +++ b/kernel/printk/printk.c > >> - * Every record carries the monotonic timestamp in microseconds, as well as > >> - * the standard userspace syslog level and syslog facility. The usual > >> + * Every record meta-data carries the monotonic timestamp in microseconds, as > > > > I am afraid that we could not guarantee monotonic timestamp because > > the writers are not synchronized. I hope that it will not create > > real problems and we could just remove the word "monotonic" ;-) > > I removed "monotonic". I hope userspace doesn't require the ringbuffer > to be chronologically sorted. That would explain why the safe buffers > use bogus timestamps. :-/ The timestamp was not stored into the safe buffers to keep the code simple. And people request to add the proper timestamps from time to time. IMHO, the precise timestamps are more important than ordering. So people should love the lockless ringbuffer from this POV ;-) > >> @@ -1974,9 +1966,9 @@ asmlinkage int vprintk_emit(int facility, int level, > >> > >> /* This stops the holder of console_sem just where we want him */ > >> logbuf_lock_irqsave(flags); > >> - curr_log_seq = log_next_seq; > >> + pending_output = !prb_read_valid(prb, console_seq, NULL); > >> printed_len = vprintk_store(facility, level, dict, dictlen, fmt, args); > >> - pending_output = (curr_log_seq != log_next_seq); > >> + pending_output &= prb_read_valid(prb, console_seq, NULL); > > > > The original code checked whether vprintk_store() stored the text > > into the main log buffer or only into the cont buffer. > > > > The new code checks whether console is behind which is something > > different. > > I would argue that they are the same thing in this context. Keep in mind > that we are under the logbuf_lock. If there was previously nothing > pending and now there is, this context is the only one that could have > added it. Right. > This logic will change significantly when we remove the locks (and it > will disappear once we go to kthreads). But we aren't that far at this > stage and I'd like to keep the general logic somewhat close to the > current mainline implementation for now. OK, it is not a big deal from my POV. It is just an optimization. It can be removed or improved later. It caught my eyes primary because prb_read_valid() was relatively complex function. I was not sure if it was worth the effort. But I am fine with keeping your code for now. It will help to reduce unrelated behavior changes. Best Regards, Petr