From patchwork Wed Feb 7 13:40:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 197941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2236839dyb; Wed, 7 Feb 2024 05:46:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVc0id+l+tIWvW/xdRRnLRLAVRkntIJlvo7ukANl19oHYdd8BkRd2pEYMAPll+JT3szjLZHDuxkSnLSdfyGh0FHFEHzXA== X-Google-Smtp-Source: AGHT+IHrIjY5PkdFxFZp/gw1pZjEUJ0q+9Rvsr0FUd0gkw4ljPfDV64PETyZjIKJMkCfjREL1mWY X-Received: by 2002:a05:6a20:a11e:b0:19e:aa08:1a0 with SMTP id q30-20020a056a20a11e00b0019eaa0801a0mr819271pzk.8.1707313576612; Wed, 07 Feb 2024 05:46:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707313576; cv=pass; d=google.com; s=arc-20160816; b=uIEmby/uRJLvjklxsYZ8tUMQIalb8DliTdezhb1bepuCk2aZ9SfKNxv/Nr+f9AjEr8 +kk7/P1n/ZhG2NiGyK5LKxF7iwBH3N8hEZtseZxo3Lfqpp0RzW09UiKFq+MGiUaNfFyh klE+w0e8GO5q/BlEW4UVgcNWsjOr4HG30UA4sO9UjkgIDioTkw/FaTlZaDl9XeBW/Ean MpbdQshdRhnjNGCG0yuVrfUs9Bk51IVbRTbqtodCZVxdS6Vn+OdUld0BUPq2FV0ANSwY vRArhVTTW8ynV+QZhnDKmw3g9kKMgYKrSqRJTamFnuyOV5zkA6NHA524a6vmxWZi6Svq EYGg== 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=Ff+TzJ0o/pSPZIn7CSGIS2C7uqhdZISpglDMKsXmGyg=; fh=SUnoNy0/CXgScqCSJvAmuKzrG5xqZ9ScgjUXir0PVoY=; b=QcX1pJdGzSF3tOwWN143YYya6XNykqNPJlj4s3bXpbrbHyBaWDejCRPJyhylYWrAnA WLfnnmeooBy6JgOeJFoSX+Y7Asf7SanmSv5Sk1hrnOUJ2doNjk9BUbU7nHj8SH0Ld0Qt U4xANv2s/4FyhAytQeaRUuLtVVonSFMdRyNU/SHKynlo4PsrrNZdc7m1gQpUH0plNRSO dOE3XT8006Xisic9R8G+PPFRno/EF5AdbegulArUE9k/YJfxHJK48WrdjTrqq8YkaXBb rjMokqUzo2cbyM5TfA8YD9veikzMO9Fztw8JsjCm/DnFF4pZjLIHGmCjhJNffLevy3pR LQFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=I86rzyaT; 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-56564-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56564-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCWrF08fj6vK02x0sqs4yIDIswXJAEyLHVWNi9ArTqQcwQaimICnCQD0xqwLEd9i76QX7clGj+SSl2SkKtIyPthcWCmOtw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id r21-20020a638f55000000b005cfd6ba16f7si1528113pgn.647.2024.02.07.05.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 05:46:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56564-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=I86rzyaT; 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-56564-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56564-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 93F4FB26465 for ; Wed, 7 Feb 2024 13:43:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1F8547F7C8; Wed, 7 Feb 2024 13:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="I86rzyaT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vOA14TGY" 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 91BA476C8A for ; Wed, 7 Feb 2024 13:41:16 +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=1707313280; cv=none; b=NI5JcV2zAxlYCnB355t6M09A+uHqKlCKwNzHQP/WnygDkFmrDcqLHR7HyBvNmSbBNanQb2Wkr5nB5nGJ4sQfK7mANSOz5gZxN2MTHnhNdTXlAbjBaXrMJkxLRot1uw1KMLk+mexKT28X0AgKH3911EtVhUKkynfxxZywDq76oFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707313280; c=relaxed/simple; bh=6HLIesyzd6TYtnLLBRHlzGAgs2b2+AOfna8a9sUGBqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=F/54kh9P+W2+hNVpRd29d6bGjC5yZYChhCeQVYuAUzuqvE8puMXSQSquY3MvRXzo+OA+919aXRgNc8FNgeeldDFWqiiJTUikSYwppdbf4LhzBtLyReRfNL9Ava77HSE2iT1XXyH9M76NA8JFuvJXxny+czNPBep9KnyiChJUMuI= 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=I86rzyaT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vOA14TGY; 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=1707313274; 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=Ff+TzJ0o/pSPZIn7CSGIS2C7uqhdZISpglDMKsXmGyg=; b=I86rzyaTjJH6jmu5xlB4+JhZ5XJagVhAbR0ZFxsZgREJILWfp+2t/b++0SPEcIcomw9Fdv YlvXdx78rB/Ehi0r9DPo/IpbKK88odtOSW7rX4Md+KCxlr8oTR2RrQ06Gj3/M2itjsvQ6d +Q6lWLxKgl+cieTr82M+UXxnhHzRSeDTtqy4HypfCfD0X7KFhYAsjlQE/6IxQwBXncC7WK b8J9YxFi18oDIxKevPsSykFxEokWVYo+Y55L9Ku2xSrlts/in5LHYnR965xkzRvKYuFdUi GW3sPl6N+ZW7bKYkXABxeXVaFZvC/+q+GSZY7Z/d7yfiMUpBdNgFSmjJuSnUiA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1707313274; 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=Ff+TzJ0o/pSPZIn7CSGIS2C7uqhdZISpglDMKsXmGyg=; b=vOA14TGYHeZPooXLLUGflPnRs+1CGMFT0XY+6bUFIurGNrfUMq20Ox8u0ljomgWrcwRuF5 K6dZXpx6IPMfqkAg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH printk v4 03/14] printk: Use prb_first_seq() as base for 32bit seq macros Date: Wed, 7 Feb 2024 14:46:52 +0106 Message-Id: <20240207134103.1357162-4-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: 1790248041147387725 X-GMAIL-MSGID: 1790248041147387725 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 Reviewed-by: Petr Mladek --- 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; }