From patchwork Wed Feb 7 13:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 197947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2250453dyb; Wed, 7 Feb 2024 06:06:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnkpYEwmBCEOofXzffrW1VKzzR6UdiOW0zZs2w8sBLbxHezxcgo2sUQOkwSFgYNFNa3ecq X-Received: by 2002:a05:6830:603:b0:6e2:afd2:cd62 with SMTP id w3-20020a056830060300b006e2afd2cd62mr5223480oti.22.1707314790345; Wed, 07 Feb 2024 06:06:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707314790; cv=pass; d=google.com; s=arc-20160816; b=ecPapHmDTj8MM82om0+3K267jxsSBokxTgglP+0eVEPfmW1sH15nH52FOkjONCGYja cOE2hJlbXjIS2VFS58yyxdNfelHg1eH7XMze68XVnanP/igzEfE/4eLJL/Xz/2Dj5D9D 3tpIeUAE8+Gpetb82xs5oZLv1+coU2R3dcKwOvM4/euQ8bSQyRWwjeeHSm+an1BD0yEU n0AaK+FuIGru8qDCWnWOBzb1souc1ByhwR4R17/OREF8tGZF78YjhcLe0YWU2Nz21gNN 5uH+49lhsazjL/kNYWRkfPtwuzmB9T1pYSxoCYd5a0NPsSp+DKWcg5hQ1kkWKNMY9im5 D8Ag== ARC-Message-Signature: i=2; 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=zhO6JKJB/J3Qv7bq/QRbOX1jB95B7+7hKvBX2b3MyxY=; fh=V6bDs6uvAyve/ow/cqMVdu5I1HYrAZcqk9d2jistKOc=; b=iGnLZM8NaFZUlZC5tUa3CmhFKvLL7rXUkG/0JuKsstkLR1l8V+YSPJOFgrb+sSk4v0 HN06/kh6C5n010t4U2gZRoTLv+iyDqxPX+Y/kuhNkbsrXxSaSD3yHfykpuDQEj4j2khF n5MuTj7YBsdpxj/YqHMZHjyMcn6HOZIxv9+XdNx40WsyK6SSo3fkJ4MIbcKYBamH7qEt k4zGyqbwE6P7sqoqcotzY0SExMy+Vuwh2GeVjQ4bx/efxQJrRXCFGB5B7gBxjDQ51nXV UMau2EGFzUVtwsQAbuUn2eErLKLdRIPzCGr515ONgL4ZBJF//SxUOOexW2HnbgDuQPk6 0NIQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sk6Ms0ah; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-56569-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56569-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCXFXXM8P9BkncU1hFHD8+71oEAtOKXVpTjMKWboBIbmYLh8O2Lh950Ypvn/ZumHXqAMJjjIjzbjiGIlaD4Ar6eiLJsURw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a18-20020a9d3e12000000b006e2bac7c0c2si391493otd.136.2024.02.07.06.06.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 06:06:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56569-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=sk6Ms0ah; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-56569-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56569-ouuuleilei=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 EEC7E28D72E for ; Wed, 7 Feb 2024 13:44:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E391D80045; Wed, 7 Feb 2024 13:41:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="sk6Ms0ah"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EzNArgF2" 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 416A87A727 for ; Wed, 7 Feb 2024 13:41:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707313283; cv=none; b=n4uqSMga4yBK/KMAhqqWvcYsHiBAUGDoCNgXXwKhsHAmygtY7KPKb6rmMDRzeo0ekJvOXCyJ5OTFjThH337BEISEufOwaE1mk91COsrPc0KnNik8S8Oc41hlsmu6YUiCnYxmGoZ9hRwJN+VaSUt65sn461YAQmSW/b/ltOUvDNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707313283; c=relaxed/simple; bh=9pKhdcb4U6Kn6n57q/bMFfBnJsOtwwB+U+IocoT8FII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JW1UnS9RCf/A8Ho+BuJnRzdBgut+Xn98rkc3kIjQQn2oZUaRtASwfSJC2dG9zbXevEpoMH+9Gwv0GSVvzeFW7iP8zcI9/vP+bDPyE4SVbeuSOnJJaJzBTXwXRWbzwIL31vOYBok6y0T5TW1dlqb1ODt0lBmToR5ITmd1VWBHcYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=sk6Ms0ah; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EzNArgF2; arc=none smtp.client-ip=193.142.43.55 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=1707313276; 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=zhO6JKJB/J3Qv7bq/QRbOX1jB95B7+7hKvBX2b3MyxY=; b=sk6Ms0ahQUVB/nEPquFAjN6fJ+FmlGtBFidV6ykTNk8cDu9P+zUJdrmD29YSeyOoCKwWNN i2j/AiEGYeJhZZCfKmXy4m3x1PDJGWQi1audu+RIQ26QS2plgyd6uz6nKO1XqxCuLCvdpf HMBvCOZVltSgZo7mEAeDtUsiiTHkBRIvweHT2DS9j0t9x5VreEdBLdubnFDPseaL+k9Alv XF2bT+TBqb2d3GnTLzQMwoBBvJye4leOaMZfDS8P5VVIMa8AEp4VWQzjvvfEBYRl5WPTpc Uq4RNrFOsfuLS5NyVPuZJNybblwXqClF/a/n1aOKNnzFgpZwQg3oz392lhBItw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707313276; 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=zhO6JKJB/J3Qv7bq/QRbOX1jB95B7+7hKvBX2b3MyxY=; b=EzNArgF2dx+iI6Bd/8fC6sLYUZBQZEAag54Ig93WG0ie99hdhNAAK/aCcjMGrk0y37TuR5 bSGXdlnCd/hAZyBQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 08/14] printk: ringbuffer: Cleanup reader terminology Date: Wed, 7 Feb 2024 14:46:57 +0106 Message-Id: <20240207134103.1357162-9-john.ogness@linutronix.de> In-Reply-To: <20240207134103.1357162-1-john.ogness@linutronix.de> References: <20240207134103.1357162-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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790249313384413269 X-GMAIL-MSGID: 1790249313384413269 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 Reviewed-by: Petr Mladek --- 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)