Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3895235ybl; Mon, 9 Dec 2019 01:50:32 -0800 (PST) X-Google-Smtp-Source: APXvYqzRkSUstrztLWlE8IcKh/+ApX6DqQsAots33bChqyoi2FSUNmc/VF1NUrq0De6112G3ByHI X-Received: by 2002:aca:b808:: with SMTP id i8mr12192653oif.66.1575885032454; Mon, 09 Dec 2019 01:50:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575885032; cv=none; d=google.com; s=arc-20160816; b=PsFyFJROiNK85lhJxJUBSpp82Q3UpuJXBP6gMIB+1UzOX0LBHECTXFR2+6YpohYKzn 8sh3LXbxDRiAhqJT+B+unIRK8cSRE5VaafuNB4sQde4ol/Q1nhSFY92Oa7osoAUUTviT ZmsW8heShdHnBBuAdl1KfQvslRc11zuy+eluRoGyVamv1jvAub9VcOY+XL9tX/q5nWDh Suh2+N7bFt4lAJHrHIWv1k4xiz6GKUyYoLJx+7rU0LzOOqQqRjEI6UqxbcToJKwj7klm vFWrGQUdUv+rQZolNoffzN0kqq1k6xs9tShBthBw+UvNkeIMXqB5XQjx2cNlq57b8Nwl xC4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=ucD+C6MxxnLU03Mq+LEDYXrRXywIRueQe/4WAGpY538=; b=aYJNcjdOX6uR4QqMZwzfRTaOcX1x1Ab+T0jCf0XEMAwTlok6N04b/wIUF48zb3Toro H5tDLPj2pZgegjKup4EdV4UUeMS45zGUeAGZke76axoOUtX4kOaydn7xF33Psi2QsBd3 5KNxhSkg0/Ovgy2WoxUShWOYVtku3t3FPLirAF4nRpPd7mBjfZrLDFoJ0UT6hqEpDptI +71/N76AhuCpLnaseIYamwCV52BOjx1o4BTwc5SE15b5rUJTc/SGpnhFazs2I2y21KVm 6BnHxO/8dofNQqdaf//BL6nMSc55rqPUoyeUYE2WrtukOJbAP50CnrumNxsOPQ8vo1dl CChA== 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 y8si11831864oih.141.2019.12.09.01.50.21; Mon, 09 Dec 2019 01:50:32 -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 S1727490AbfLIJfT (ORCPT + 99 others); Mon, 9 Dec 2019 04:35:19 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:38054 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727160AbfLIJfT (ORCPT ); Mon, 9 Dec 2019 04:35:19 -0500 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1ieFRV-0005eV-BF; Mon, 09 Dec 2019 10:35:01 +0100 From: John Ogness To: Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Petr Mladek , Steven Rostedt , Linus Torvalds , Greg Kroah-Hartman , Andrea Parri , Thomas Gleixner , Sergey Senozhatsky , Brendan Higgins , kexec@lists.infradead.org Subject: Re: [RFC PATCH v5 1/3] printk-rb: new printk ringbuffer implementation (writer) References: <20191128015235.12940-1-john.ogness@linutronix.de> <20191128015235.12940-2-john.ogness@linutronix.de> <20191209092756.GH88619@google.com> Date: Mon, 09 Dec 2019 10:34:59 +0100 In-Reply-To: <20191209092756.GH88619@google.com> (Sergey Senozhatsky's message of "Mon, 9 Dec 2019 18:27:56 +0900") Message-ID: <87muc1zvss.fsf@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-12-09, Sergey Senozhatsky wrote: >> + * Sample reader code:: >> + * >> + * struct printk_info info; >> + * char text_buf[32]; >> + * char dict_buf[32]; >> + * u64 next_seq = 0; >> + * struct printk_record r = { >> + * .info = &info, >> + * .text_buf = &text_buf[0], >> + * .dict_buf = &dict_buf[0], >> + * .text_buf_size = sizeof(text_buf), >> + * .dict_buf_size = sizeof(dict_buf), >> + * }; >> + * >> + * while (prb_read_valid(&rb, next_seq, &r)) { >> + * if (info.seq != next_seq) >> + * pr_warn("lost %llu records\n", info.seq - next_seq); >> + * >> + * if (info.text_len > r.text_buf_size) { >> + * pr_warn("record %llu text truncated\n", info.seq); >> + * text_buf[sizeof(text_buf) - 1] = 0; >> + * } >> + * >> + * if (info.dict_len > r.dict_buf_size) { >> + * pr_warn("record %llu dict truncated\n", info.seq); >> + * dict_buf[sizeof(dict_buf) - 1] = 0; >> + * } >> + * >> + * pr_info("%llu: %llu: %s;%s\n", info.seq, info.ts_nsec, >> + * &text_buf[0], info.dict_len ? &dict_buf[0] : ""); >> + * >> + * next_seq = info.seq + 1; >> + * } >> + */ > > Will this loop ever end? :) > > pr_info() adds data to ringbuffer, which prb_read_valid() reads, so > pr_info() can add more data, which prb_read_valid() will read, so > pr_info()... The sample code is assuming that @rb is not the same ringbuffer used by kernel/printk/printk.c. (For example, the test module is doing that to stress test the ringbuffer code without actually affecting printk.) I can add a sentence to clarify that. John Ogness