Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2401989rdf; Mon, 6 Nov 2023 13:08:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IGC9erW7Xce8rLLk/4Jhsoj5/+wzUkIRzvVUr69PfMQw/8e3tx9nGBsrVr1gqQB2QpyqmfC X-Received: by 2002:a05:6358:e4a0:b0:169:6251:c4a5 with SMTP id by32-20020a056358e4a000b001696251c4a5mr20715863rwb.8.1699304883621; Mon, 06 Nov 2023 13:08:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699304883; cv=none; d=google.com; s=arc-20160816; b=YL27XwcqBFAYelxgy9ifRgYrp7h4Z1BYyLIxw8yLvOyfGAqpL4XfrBsYO6Z0HUdMbf yAQSZwmG0VZ+chDpTFVq6vl123oYuxk7oPwyTkiXf9mo+QJfR5Y4tL/S5KxI0xD4rEDF gpVazE48VCknD51x6jFWblQcaJcrDND/PBqEYabUmFZAvH8afNVviOVb+Z/5nEjfiiMA OsfDis7VIqNzfG7TuMh0gleQfiFuJMoSrVMWTMhBVmyuukzqT0vcexFNrWGxVLKbPJjz p5G8YbnV0aBPeiUmRmdkNT4tqIYi9C8n+557iqzOyI4P7S6zzEnSpaABAQry3EZ6Yl/W yHSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=kBti+euuqh1/uRUq/4/BqmS276Luuh3FRgstJhjJXpI=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=stR6rxBeGR/hJGRZT2d1O6wz6AXPCOmj4pI3FCL0I0VQt7T1JVUospWANQtBzXgua9 KcuZrm5VxeN72jsyxkr6uFHZJcRKD8EIY7fkrWPqw6g/20FdA2QO902h8Ls5R5EptybP yyeyn9xZZxOXO++j3xDkCXnV46B/yoYaw3egzPSWgtQKRRbFzb4pZu//98vVaLmc4YKY TXb64mneinhafuO7jhMUtaCpoB3ACqpdyFbDEfpZQGh7Dtt2lOHoM4AzzZX9uZrt5gL5 DtCzzC5SdGw1XaIj0y4dw8NsgIf84EtE9S9LLn1AOmUW0/FgFRnq3zuDi6prx15qieIV ivDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rO+IZ5z6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k69-20020a638448000000b00578889362a2si440311pgd.663.2023.11.06.13.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 13:08:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rO+IZ5z6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id A481F801B3FB; Mon, 6 Nov 2023 13:08:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233156AbjKFVHt (ORCPT + 99 others); Mon, 6 Nov 2023 16:07:49 -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: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 13:08:02 -0800 (PST) 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_ringbuffer.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) } /* - * 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 = tail_seq; } else if (err == -ENOENT) { - /* Record exists, but no data available. Skip. */ + /* Record exists, but the data was lost. Skip. */ (*seq)++; } 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 data * 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) -- 2.39.2