Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6285026rdb; Thu, 14 Dec 2023 13:44:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbfcDJrrBI7cUYERGn9RHkXC4qd0C6HCX/+iJGtyDhQYYpMI1chxhDHN+vLX2p1QzUZfol X-Received: by 2002:a05:6a00:cc1:b0:6ce:49a7:1695 with SMTP id b1-20020a056a000cc100b006ce49a71695mr12470067pfv.32.1702590245020; Thu, 14 Dec 2023 13:44:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590245; cv=none; d=google.com; s=arc-20160816; b=uaZsJX9WOkk/J6ookwv3stSgZO3+ci3y5hWJXdRw9+FGGr+nVm8U2IawNE5hCoflyO RAlIWvXc1+pLDDfVxsTw4cIL2NJzWei7Uegm8XTMlcVmo7poWTps+GgnaNW3DfXE4Axy 8Ib9H0EUnqA6EfpGwCg48rTFRKQM8vJOGzzIzt54GqQoRn+c2Qiy3UWxtnHQvZ6foZ23 6KYv6IYI3uoKPu11pV8cxpaxnP9c6MDU4XVGmClT8DNMwsLyoIUgMSujCemZUEIMBb+Y 09TnP3fpuRvMYHJ4LqzuaSpu57C5wCzSQfa8ClvFr5y/Zpm4d9RQfhJPQFG7i5ivib6P c03g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=dulH4uTFGHjZfiwmh5wTwYSUbBhMPUk3D6gHo+246W0=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=uR+dqgcKPKFGndMWLN6TI8WqoZGVZIBeE5bPwcAmbZyHu4YCEzbUemDs76OLddTBXZ IFlN7imDL3cTqWUlZ003Kd3jTwroO/zCJ5OV2Hro3AbQUwYVO7OjVDEXJtdhfWoyl3ON OmDqvtwc3Kswxe3pQXnI1CAf60BmJGh/K8RYAlO2C/rMAF4Ty8pDdRRpYmC9zJTu9Zpl xUHUzKUwCtqZYaEjyIhOLGqVvXUx4Ufxa3ULVd2vHThExRsa1FzbUEaphbLAY71pPxGu bpivl0rMKh8QpVTggJBVI4zeB7VqRrCLO6ZprEtr7hoZ6/v4/A0LETvFKe3gGAy5HaQ9 o74g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Um+KStAI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f21-20020a056a00239500b006ce05b64d14si12024836pfc.93.2023.12.14.13.44.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:44:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Um+KStAI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-150-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-150-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D068A28155C for ; Thu, 14 Dec 2023 21:44:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18DAC77B29; Thu, 14 Dec 2023 21:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Um+KStAI"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="QiXbx7oE" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9F086E2C0 for ; Thu, 14 Dec 2023 21:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702590127; 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=dulH4uTFGHjZfiwmh5wTwYSUbBhMPUk3D6gHo+246W0=; b=Um+KStAIeVeli6ubkyXVvhUMFOAS+CGHsj0pasba2RsNvgIJw6sMPi6+2Vl8+YxYNV55aQ Da1wq69Q1xiAHokJ9oILGdhGR5TZQxwJTSBizELnIG3HKzRamrshLvpLNA/+M1JmcR5q53 VxjgXE2dr8QYemoKKg7U5rxSrUgive0oXyomTR7Wf1vn0Z7Y75VR20+NmhymkVi7zOcevk lzUtmXaEyZCRhIPQPcU7V1y9BadI4EN8LaeawoE7tktDmktre7YG9MaCEu9TicCDFSeR/N iYmWkn0KTiQIgHKzgWKs7UzoUNtO13GD28o2yRJLQ7j0G8Ev4WFJlTN8NWIMOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702590127; 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=dulH4uTFGHjZfiwmh5wTwYSUbBhMPUk3D6gHo+246W0=; b=QiXbx7oE4vDke9/uZ44k7k21fMsLQKRToJN9tPxb+hM7GI2qYu0A5+vThpVToe1d2Ki58B 5EpLq38dMFioq3DQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v3 08/14] printk: ringbuffer: Cleanup reader terminology Date: Thu, 14 Dec 2023 22:47:55 +0106 Message-Id: <20231214214201.499426-9-john.ogness@linutronix.de> In-Reply-To: <20231214214201.499426-1-john.ogness@linutronix.de> References: <20231214214201.499426-1-john.ogness@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 244d991ffd73..67ee1c62fcd6 100644 --- a/kernel/printk/printk_ringbuffer.c +++ b/kernel/printk/printk_ringbuffer.c @@ -1987,11 +1987,13 @@ 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) @@ -2010,7 +2012,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 { @@ -2043,7 +2045,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) @@ -2073,7 +2075,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