Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6284379rdb; Thu, 14 Dec 2023 13:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IG5y3EOmfzdCIaxm3o/hJYUeaoZrlK4WB93c8fpadNf42C2sDIbtTv+2eSKYsoMiLXKZF6m X-Received: by 2002:a05:6a00:6082:b0:6d0:8556:1a75 with SMTP id fp2-20020a056a00608200b006d085561a75mr7395545pfb.16.1702590150877; Thu, 14 Dec 2023 13:42:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590150; cv=none; d=google.com; s=arc-20160816; b=oec7np/Z/DaAV2Kq6W3I5EQH5z5IsuJGI9zWYQo1wA+NKljmhIIyntSdRZgXLKbtAS cYxFVV+wPEcV9Goo2FuJ9oPfWXxf9envArWkBwIJJnMl5eHUxVzmEB5+JTzwMItEfo/4 itW+kVLp9PD+jdK7MTkZhRnWlL5M8FsCj9TUOjBeyw8lUNpqDDmtk+i1/WsdLDe3ONzk 3IVg0Afoxh69rNM5WTy+OULoXRY5vWrVx1j6DUhcqllm1mNsQxcssFDky3dMOK21aPGe Zq/lkQNn9fto+i/VUIASfRvX1XMB/5f/ClbMVc2550Bucha/FdI1FEc8ixJufWWFGlhh pjkw== 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=muVNDGHsflpPS75QT30/xhAWDErFJBhvBumoamznaLA=; fh=pKnPKUsir0uEGSsor+4Zc2vgbu+g+ayvUgsdzkuXaoA=; b=jAydgz0qJ7r3sDuhZJq58OSagZGDKUR1rjWCezwl2T8fj1K8M2MVHLke9o3h/IVTTV 5cIJNk+BcEj89VfVPiLJLUeBOrd95iuIyaigghZoMSrDjTZ7p6S1Ezv+4qjvC8qKNlA8 EK6WIOSwrGhbkE+XqzdSDXPfpT1SvgXPIqfGs/ZLK3SlqfE+W09TXWs6HNFFeilRN+Rv jrZpjRdC/hyW9eHa/sR1wMiha8AZglO3v5leZTEJoqiif9n6d630X1N07t8czt7jTdj5 FVnEdws34ROG7wANrjof820gMQ/ZC54hXCi4J2W2TKNP4y6ALmc3GXQ3C7TbATJFuZ9b 84Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=b+oQS7ov; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b20-20020a056a000a9400b006ce9e6cbdf5si11734885pfl.351.2023.12.14.13.42.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:42:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=b+oQS7ov; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 30718B219FB for ; Thu, 14 Dec 2023 21:42:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F9C06D1A7; Thu, 14 Dec 2023 21:42:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="b+oQS7ov"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="phT90Otf" 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 37E496ABB5 for ; Thu, 14 Dec 2023 21:42:07 +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=1702590125; 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=muVNDGHsflpPS75QT30/xhAWDErFJBhvBumoamznaLA=; b=b+oQS7ovxSclsqr8szoXFqH5thsF+V/j7hxOLnR6shH6GCgYLVavhZbEycUD0bPh8KIsd3 /HQ8unq761Xz6A/zlKW0c1tqBwiK+RPYSw8z9b3h5Fag97ckFU1lZUqITRUv/S8r46v69P BCQGaJacgenSB1odluZ4hrYsY04KsCHBS8BmWKl/jka072/PNjXPSNQSd+5MzTOBt7Sr6C 6aD0jtwk9E1j9N8Z7odbKB2nM7msQTNTwU86Opx5sL9z3eT6Elac/AcyaHBTJHTLOTf2qA jUzNItuhD/asRLVfhBa/aDlLPiko1FuNfZqi2A01jZUn8r3708PYNY4WE1C9Lg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702590125; 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=muVNDGHsflpPS75QT30/xhAWDErFJBhvBumoamznaLA=; b=phT90OtfDCug3ZR3eWCa6Yqoc+ndgc1bUViER55GRkZespCIz0VYuEMEEGNPQB0TvYN5gX 9z3IEeo8V9KuY7BA== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v3 03/14] printk: Use prb_first_seq() as base for 32bit seq macros Date: Thu, 14 Dec 2023 22:47:50 +0106 Message-Id: <20231214214201.499426-4-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 Note: This change only applies to 32bit architectures. On 64bit architectures the macros are NOPs. Currently prb_next_seq() is used as the base for the 32bit seq macros __u64seq_to_ulseq() and __ulseq_to_u64seq(). However, in a follow-up commit, prb_next_seq() will need to make use of the 32bit seq macros. Use prb_first_seq() as the base for the 32bit seq macros instead because it is guaranteed to return 64bit sequence numbers without relying on any 32bit seq macros. Signed-off-by: John Ogness --- kernel/printk/printk_ringbuffer.c | 2 +- kernel/printk/printk_ringbuffer.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c index fde338606ce8..49a82ccce8e9 100644 --- a/kernel/printk/printk_ringbuffer.c +++ b/kernel/printk/printk_ringbuffer.c @@ -1832,7 +1832,7 @@ static int prb_read(struct printk_ringbuffer *rb, u64 seq, } /* Get the sequence number of the tail descriptor. */ -static u64 prb_first_seq(struct printk_ringbuffer *rb) +u64 prb_first_seq(struct printk_ringbuffer *rb) { struct prb_desc_ring *desc_ring = &rb->desc_ring; enum desc_state d_state; diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h index 12f60c782e46..ee294aaf4aeb 100644 --- a/kernel/printk/printk_ringbuffer.h +++ b/kernel/printk/printk_ringbuffer.h @@ -378,6 +378,7 @@ bool prb_read_valid(struct printk_ringbuffer *rb, u64 seq, bool prb_read_valid_info(struct printk_ringbuffer *rb, u64 seq, struct printk_info *info, unsigned int *line_count); +u64 prb_first_seq(struct printk_ringbuffer *rb); u64 prb_first_valid_seq(struct printk_ringbuffer *rb); u64 prb_next_seq(struct printk_ringbuffer *rb); @@ -392,12 +393,12 @@ u64 prb_next_seq(struct printk_ringbuffer *rb); static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq) { + u64 rb_first_seq = prb_first_seq(rb); u64 seq; - u64 rb_next_seq; /* * The provided sequence is only the lower 32 bits of the ringbuffer - * sequence. It needs to be expanded to 64bit. Get the next sequence + * sequence. It needs to be expanded to 64bit. Get the first sequence * number from the ringbuffer and fold it. * * Having a 32bit representation in the console is sufficient. @@ -406,8 +407,7 @@ static inline u64 __ulseq_to_u64seq(struct printk_ringbuffer *rb, u32 ulseq) * * Also the access to the ring buffer is always safe. */ - rb_next_seq = prb_next_seq(rb); - seq = rb_next_seq - (s32)((u32)rb_next_seq - ulseq); + seq = rb_first_seq - (s32)((u32)rb_first_seq - ulseq); return seq; } -- 2.39.2