Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2369727lqp; Sun, 24 Mar 2024 16:12:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUC7eupLr3HRjnZk0deXYh2ihmIKiMeVn5t6xlIcldARjgC+CUvZSePy335i4mLBOgO6ouRe2i0pCpkQM8OTHhR4mvoEMSKYkZi4zNh+Q== X-Google-Smtp-Source: AGHT+IG1JWfM8J/1C7Gpnc+r7InZ2EorkvqGifShPflidKWU9+IlX/MBBOomCvWxZE2UtPMLKLFN X-Received: by 2002:a25:a408:0:b0:dcd:26a8:7f84 with SMTP id f8-20020a25a408000000b00dcd26a87f84mr3276778ybi.47.1711321928432; Sun, 24 Mar 2024 16:12:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711321928; cv=pass; d=google.com; s=arc-20160816; b=Ua8IrvUNAwgWHEg3k+/9dfzSSuoicoWI2Tq253W2UfR3mY7qTl7aYneZKBpDufOtR5 AWQz5ush99yJxpeY2OOO7uA2fAN1jP4Di18Z1ZhlyNLGYaWs06pugWPJLQ5xH2W0jfk7 aUM3sTe2h6lTwELRADxiH0iVQxk9lUaTqHYdBQeq8cNs3Ugt1A+4dehoQUyylh7AmyNf Jh2vgAvZI0ua9NM0FDXZHa5WQ+LxVR6Rw7RBXLgeyjVXzBL16foorMznazdo+hNiSqkJ k6r8zz+YoGvFRnG9RM+Q3xP7Pm//COOD7BcKZCdaxMTG4zx/amXagziwzPbHbGL33N13 sg0w== 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:from:dkim-signature; bh=EyX8uxDqvMhWEI0yDP2gOAQTrAvrXOb/tO8G4cmQOJs=; fh=j+aMbK7eLMI2KMaRmGMOCTxfEkIc4TPOnxEcnsSirNc=; b=nMoMjK6qed8K+YtvqwfU8xtf3i4nNBibuHzPAxzS8c/vIZhHgiK1TpbUMRQHLx36Z5 ho3/LtiGbYSggIwMi9NIRHCG3Eim6iAAT2Zr7PIn8i3HzRsC0jI3cZiozJJ6yMcA7Dk0 EQzD53rT/XKnV0Zpy/1Q8+6Jf12y/5XovdUC32W6yddd7j1z/jGRxPBCLVn5RrB5zWWA 9VSvEShCp4n1W9Zdnp1FQmZHNk+RK6Em19m9E0sLqBZkZ5eGsKrNBexo9G7znXOIl6n5 GOKU9DAv9OWwfjVoWE06I6Ep4mhCRC8KBGX3YdFBCcvB0mRK17Tx3uQ5i7wFHQOQNVqG ha7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUBADQqw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id j17-20020ac85f91000000b0043156bab559si1081603qta.1.2024.03.24.16.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUBADQqw; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F109B1C2147A for ; Sun, 24 Mar 2024 23:12:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC4DC142906; Sun, 24 Mar 2024 22:37:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BUBADQqw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CDF0F14291E; Sun, 24 Mar 2024 22:37:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319859; cv=none; b=fYEZr+/BgXux6t9CpGyXNdyQJgGWw2visRYiugLrctVBysHqOn+AlWeg7pa5R0MtwtEWpYLAu/AoKeR1k3qiG7TA33rJ9B8W4Vy4HZo7UxmtbXF7xM4MEdoQWzNlPs/bVB0vmlRP7/oNXG49PiEFtPHI+ZDfEN+T/yI/CJagZDs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319859; c=relaxed/simple; bh=55Nb6Gl3zSs4ji63PyDfoyTChWWBkNx9WldkUmv7yW4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F7xVmEKaaUkP1JVfCBgrGRmC00lvhR0uChXPYbHfhUOpY3piWv+nz04FGuhHJEBsqeIodk5K7OZ1wvFgNbFp4BwBi64PSDea9Z3LmCyQnqP7GDYgqRPmoRA8CJyEeEFA3pdGJR1MvxdOJRscUh0wsNlybyPBdyMzXeI6vssGA54= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BUBADQqw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE80AC433C7; Sun, 24 Mar 2024 22:37:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319859; bh=55Nb6Gl3zSs4ji63PyDfoyTChWWBkNx9WldkUmv7yW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUBADQqwRLKG+vXVYhERb1zum9zrX9TybyH5boR+RRfIq+tLMwBny/bzmjGK6lm3Y V+vfh035uVcG753ETbTySi7zrVyPtzewpTvS7t6ZBK0edzIdG6DQM3RVDNvSo8GZwP i/hY6nvFSQ7PPL7eOOLNEJXWUkim7pCt1Mw6hbgEUMEBO+sq01jHWZ3VPuRJkqKF66 a6eLXrlTWx65c66yz20zHX/xD4WpISkPitw8miLdI3SEuH8iM8JuQWik48TsPIa5PU T99dLola3GB+NymK2FP3N7jMVbDeZ87Vr+9o4bA8xhW1lrfQPnLuJ+WNQO4KEJMlNi S07FV2ypsB8yw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: John Ogness , Petr Mladek , Sasha Levin Subject: [PATCH 6.8 163/715] printk: ringbuffer: Cleanup reader terminology Date: Sun, 24 Mar 2024 18:25:42 -0400 Message-ID: <20240324223455.1342824-164-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: John Ogness [ Upstream commit 584528d621459d1a5c31da7a591218ad3bb96d6c ] 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 Link: https://lore.kernel.org/r/20240207134103.1357162-9-john.ogness@linutronix.de Signed-off-by: Petr Mladek Stable-dep-of: b1c4c67a5e90 ("printk: ringbuffer: Skip non-finalized records in panic") Signed-off-by: Sasha Levin --- 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 d152b6bd35c9a..97ec25d227976 100644 --- a/kernel/printk/printk_ringbuffer.c +++ b/kernel/printk/printk_ringbuffer.c @@ -2080,11 +2080,13 @@ u64 prb_next_reserve_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) @@ -2103,7 +2105,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 { @@ -2136,7 +2138,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) @@ -2166,7 +2168,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.43.0