Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp311818rdh; Wed, 7 Feb 2024 05:41:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXkJ8Hn561o5yDgSqm6GusLm2SJ7RxHUw61prr48waWaWuJUvXCzZvF1bxsYUCjtCmnke9S5DXWoT4MB1dHve9XhyB5q5ekXocZ/pJh7A== X-Google-Smtp-Source: AGHT+IFrKujQz/zp4W3dP8+er9CnR6Kr6DRZ9v43+n41wRXky5w4WWpAZtY70+OxThwYj8iD57NX X-Received: by 2002:a17:902:fc45:b0:1d7:1a90:65ba with SMTP id me5-20020a170902fc4500b001d71a9065bamr8402994plb.25.1707313315177; Wed, 07 Feb 2024 05:41:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707313315; cv=pass; d=google.com; s=arc-20160816; b=1LO9G8Rv/PMd9+sYK7/g9HY7avZN8as2UrwKWwzHN6VC7OMZS2/ZfzT+av6WpLQ0RO zzAQHCOaGzhjEneU9ckRifMjbwP/QJ3YDXQ6C+OIc8GIKyzbwmPyhIlH2RdwNfNHbr7t 1eBp5S+XWPJtlZ0JXaNW6Dn5Rl+jbli/TA3SIR/H1zYW+lyh3eTw2b5mbsHzPaNipPXn UL1TILfo7RuQMSeIPm88QyDbWrvTOiSLVRtQV2o1ihrVd6077m9VU9cfCm2zE8Vm94eq nf76tjnXaLAGCQsl+rpM+FMeXXQ1pYFCD3Opsvpf0ky/I6Rs+tcQv33c79jc6MnKO0Z7 wZwg== 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=2Kv9ctMU8zX6WOM2KeSVjRpbbMNrZiLlMcYwzmjmtKU=; b=fTogfaFJca1EsDuHM2LRIYEGlmgVdC/fOkkUErL9ZxVJaxPuWbOL4Vu/ztTeqvhOWh l1QSjIgZY/T7CKUH9KF5hH4c+SdDVFdHlSMtFiIpi8yMwKG/EUaefCLV8WB3FuHmdkfI 9zeEzUBkgtxk1ECNaUDfUvfHCGSS16zwMRYixFZH9i0a0hhXHbm8YIxd7qiW+RK5vQ/X IfEb/h7DIqcs9xOZZ42WZPqKYDfgUBhgd9lIIphYOITkJMbdmmDgW2bq701pvjOjFzbQ IQRDKKHKahEpRuiRQ6cFWbZdpWrmC+YU2YzbBLdmD81rz/PGE7LT5UDW2QsJ8FhxwDKB mV7Q==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56564-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de X-Forwarded-Encrypted: i=2; AJvYcCVkOohYy7/CZ+2A0IoMhNBBfw97xu92PWJdtP/VCqFgBuMkmPgOAAaZJ85oqdDTquhFX+vti9E+BVO8tYZR3Ineqbvlb3ttKSF9NiCVMg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e18-20020a17090301d200b001d78541b723si1764173plh.496.2024.02.07.05.41.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 05:41:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56564-linux.lists.archive=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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56564-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 9FE4A285CFF for ; Wed, 7 Feb 2024 13:41:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 026F17CF00; Wed, 7 Feb 2024 13:41:22 +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 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 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; } -- 2.39.2