Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1541410ybt; Thu, 25 Jun 2020 08:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgDtxNz2mZN4VhD0oIxChLKQjdy4Ph9tuthXiZLrT2FLp7j+isr3Cve/4rKBYBen1yr7Nc X-Received: by 2002:a17:906:148b:: with SMTP id x11mr31467161ejc.282.1593098528094; Thu, 25 Jun 2020 08:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593098528; cv=none; d=google.com; s=arc-20160816; b=v4O8fcWt1URBXdsL/VQVCt2sGUXQsKXrcAqPLOzLO1JKBIXuzNycIE5hGzQDwA3lnb ExqanOi2UIsDDRmRDBlvqzTSxyA0e1ktBQPWzA9ThuYU0SzHhqB1OpVIV34/d+ROvoIv 2jOc/GVUuB8SGhYr1LJqYB1gJ/x8o7M6bYcJgxcOxw1rSIeOWt+o8JoqmuUVoMWTlHgZ C1ryVBfGHxQt7jQpKJ1tMa0xxIM6XrVWFjLiHn5d6khp1hFr96xR9R/MrsD+EYokiE66 HYqrWh+xwgG0EglZ2d/unaKKl5x7Y8ZihTKgV4I5iqn2VeFZF+wZTjAfUcvk5rPQcQz0 eMOQ== 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=Thde6fO3HscVJscdhQKNeuD2MdIKnhJ9A6H0QAqmXfE=; b=SlOtYA6gfxgLzgta1+kropQGPohIcRffqZxTCp3j2K79eOisX2ViA0aTf9gBjOKjr4 pTfzu9eXIGQU9GOobTKIh5WiXdI5cGPMTPbGDLMn9DpKi0BO9CygXwABI4YWxdXH8kzT 3n3wuDS/2hNTY/yLrPVjEzDi4mqXm0CmUhFw56L/zSlk2HUFrB6wHhR20xoXeY+0JFVN wH7yo7jothaLTzZ0RXiJtrkdtzUFyWCOi0Z7qGUaCQ2MNxqn4LzdkGZsx1vmd4KnlfPq MEVLoldDw7yBGI4/BJowzPnxSZbYQ7TgioBasrv56cwovA9r3dP6tgs5crrZhqJVUoZ5 10zQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si14302387edu.513.2020.06.25.08.21.44; Thu, 25 Jun 2020 08:22:08 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405693AbgFYPUo (ORCPT + 99 others); Thu, 25 Jun 2020 11:20:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:40332 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404580AbgFYPUo (ORCPT ); Thu, 25 Jun 2020 11:20:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 099E5AFFC; Thu, 25 Jun 2020 15:20:43 +0000 (UTC) Date: Thu, 25 Jun 2020 17:20:42 +0200 From: Petr Mladek To: John Ogness Cc: Peter Zijlstra , Sergey Senozhatsky , Sergey Senozhatsky , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Paul McKenney , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: syslog size unread: was: [PATCH v3 3/3] printk: use the lockless ringbuffer Message-ID: <20200625152042.GI8444@alley> References: <20200618144919.9806-1-john.ogness@linutronix.de> <20200618144919.9806-4-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618144919.9806-4-john.ogness@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2020-06-18 16:55:19, John Ogness wrote: > Replace the existing ringbuffer usage and implementation with > lockless ringbuffer usage. Even though the new ringbuffer does not > require locking, all existing locking is left in place. Therefore, > this change is purely replacing the underlining ringbuffer. > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -1609,11 +1633,15 @@ int do_syslog(int type, char __user *buf, int len, int source) > break; > /* Number of chars in the log buffer */ > case SYSLOG_ACTION_SIZE_UNREAD: > + if (source != SYSLOG_FROM_PROC) { > + text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL); > + if (!text) > + return -ENOMEM; The buffer is needed only to count lines to count the size of added prefixes. Could we use the new prb_read_valid_info() that allows to get the number of lines without actually reading the buffer? > + > + } > logbuf_lock_irq(); > - if (syslog_seq < log_first_seq) { > + if (syslog_seq < prb_first_seq(prb)) { > /* messages are gone, move to first one */ > - syslog_seq = log_first_seq; > - syslog_idx = log_first_idx; > + syslog_seq = prb_first_seq(prb); > syslog_partial = 0; > } > if (source == SYSLOG_FROM_PROC) { Best Regards, Petr