From nobody Wed Dec 31 08:46:43 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 492CFC4167D for ; Mon, 6 Nov 2023 21:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233159AbjKFVHu (ORCPT ); Mon, 6 Nov 2023 16:07:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbjKFVHk (ORCPT ); Mon, 6 Nov 2023 16:07:40 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A425AA3 for ; Mon, 6 Nov 2023 13:07:37 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1699304854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kBti+euuqh1/uRUq/4/BqmS276Luuh3FRgstJhjJXpI=; b=rO+IZ5z60LDnK6bOmPFT51j9NOkdxNHT9YTE9QZdCaYLYBFDqIUeiq+GgPdCUHqyT21iCg MNKL4XsVsrcxD4gaI2D9beZ0cyOFmcGNp4wtfyRR2Xn1oVw01OcTZYOgDA4jB7RYWi0YST 2iBEb5G9AT0tWn/Ko6goqu+SFXk1aUSusJZt0Rem+6xg6irc7xJTUqpnbLJOznuFV2sfpr H3MVdibz2/l0My1YTcu1+cBVZPrWBXP/YsVkhCMq029iDuS8LdgABtTtc97m/5VegKpz7C xBjYR+UEjT2UIyg2LBvh1lAB2CQWOQnOHWvTd+wwjUDmnPWGf0ifEPYnQWbv+Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1699304854; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kBti+euuqh1/uRUq/4/BqmS276Luuh3FRgstJhjJXpI=; b=Si1gJVCx5MZqrcjxIsCfq5cD8gX/FtEBGyffHlxR4+OyKVjZ4IMcEJIxH6J4bM8k2BVAei bWXpXrJUvIyjc7CA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v2 5/9] printk: ringbuffer: Cleanup reader terminology Date: Mon, 6 Nov 2023 22:13:26 +0106 Message-Id: <20231106210730.115192-6-john.ogness@linutronix.de> In-Reply-To: <20231106210730.115192-1-john.ogness@linutronix.de> References: <20231106210730.115192-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" With the lockless ringbuffer, it is allowed that multiple CPUs/contexts write simultaneously into the buffer. This creates an ambiguity as some writers will finalize sooner. The documentation for the prb_read functions is not clear as it refers to "not yet written" and "no data available". Clarify the return values and language to be in terms of the reader: records available for reading. Signed-off-by: John Ogness --- kernel/printk/printk_ringbuffer.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringb= uffer.c index 43d77db435c5..7c121fd68330 100644 --- a/kernel/printk/printk_ringbuffer.c +++ b/kernel/printk/printk_ringbuffer.c @@ -2013,11 +2013,13 @@ static u64 prb_first_seq(struct printk_ringbuffer *= rb) } =20 /* - * Non-blocking read of a record. Updates @seq to the last finalized record - * (which may have no data available). + * Non-blocking read of a record. * - * See the description of prb_read_valid() and prb_read_valid_info() - * for details. + * On success @seq is updated to the record that was read and (if provided) + * @r and @line_count will contain the read/calculated data. + * + * On failure @seq is updated to a record that is not yet available to the + * reader, but it will be the next record available to the reader. */ static bool _prb_read_valid(struct printk_ringbuffer *rb, u64 *seq, struct printk_record *r, unsigned int *line_count) @@ -2036,7 +2038,7 @@ static bool _prb_read_valid(struct printk_ringbuffer = *rb, u64 *seq, *seq =3D tail_seq; =20 } else if (err =3D=3D -ENOENT) { - /* Record exists, but no data available. Skip. */ + /* Record exists, but the data was lost. Skip. */ (*seq)++; =20 } else { @@ -2069,7 +2071,7 @@ static bool _prb_read_valid(struct printk_ringbuffer = *rb, u64 *seq, * On success, the reader must check r->info.seq to see which record was * actually read. This allows the reader to detect dropped records. * - * Failure means @seq refers to a not yet written record. + * Failure means @seq refers to a record not yet available to the reader. */ bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq, struct printk_record *r) @@ -2099,7 +2101,7 @@ bool prb_read_valid(struct printk_ringbuffer *rb, u64= seq, * On success, the reader must check info->seq to see which record meta da= ta * was actually read. This allows the reader to detect dropped records. * - * Failure means @seq refers to a not yet written record. + * Failure means @seq refers to a record not yet available to the reader. */ bool prb_read_valid_info(struct printk_ringbuffer *rb, u64 seq, struct printk_info *info, unsigned int *line_count) --=20 2.39.2