From patchwork Mon Nov 6 21:07:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 162191 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2928051vqu; Mon, 6 Nov 2023 13:08:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiwRbg6QMaUfs7AoULpV9MlpLk5eh6Ivfys1yp19Nysmt0DMeJ/Oo8/2uJ0cPRsXMjAgbF X-Received: by 2002:a17:902:ce83:b0:1cc:6ec2:d24e with SMTP id f3-20020a170902ce8300b001cc6ec2d24emr22402366plg.53.1699304882226; Mon, 06 Nov 2023 13:08:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699304882; cv=none; d=google.com; s=arc-20160816; b=UflyT6jnZJsA4vJd2CRGifLZ212B/q4COZX7aZfeBTzU03jhtDZDywlsnB3t5+4OKo MqxzYaatDst7kLHpTQnFF19c6A9NT07Z6aQxXTtdi5oqX2q7o8D1/AvOW66s/6Q+N1VG gTmPrq0ujG28GqIED+6OQlnl5cfZtQbKYb/JbcfJUV8SJNtzZaA3EOuiddsm2ROTxnH1 XPRyLSYWkTyB1KussnRg073gl4YGXybk5y5XU0cyv8319TDKP8EW5Vx2laKCTX111JLW TUV/FxzkdVBZ7oCyGCUZvmicrdM043/E+BwM/Yt2h28uJ5KBwjNCZJasmNQDJfYZwhZm isiw== 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 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id jc15-20020a17090325cf00b001ca110d482csi8438650plb.573.2023.11.06.13.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 13:08:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; 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 2620:137:e000::3:7 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 5FF82801B3EE; Mon, 6 Nov 2023 13:08:01 -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 S233157AbjKFVHt (ORCPT + 34 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 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:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781850316220197431 X-GMAIL-MSGID: 1781850316220197431 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)