Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6284382rdb; Thu, 14 Dec 2023 13:42:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbEb8QcwBTTtnrY9vnBrlhYYL7iz936DiiAnCIjfFthAzPH7vEJN9x7GgXRPPyrWyCAzEi X-Received: by 2002:a50:d798:0:b0:552:3358:f637 with SMTP id w24-20020a50d798000000b005523358f637mr3074725edi.37.1702590151745; Thu, 14 Dec 2023 13:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702590151; cv=none; d=google.com; s=arc-20160816; b=MUfejWTcaiTGShyPlaaCyG8S6UxBRR0h6DHJ/puygt0g/QwdaEP69bGxmE4IjpnII0 T4Ce2xbkgu02WmVtPCXg0L+uJdoEo8LYFx7HCYSUCm06RitxmZvx+ZdDzZRqfLUjOypG 8lOMrUQiFxo/wVDtR/pLc4GMKW56sAsZW1XfgYi/ROpbjlzJ6C1Nd4kgKGt8TgDBvA6X 1kUsZr2WAeyYY7eIppMbiKID1ZT0xHGLFdc+Gt3E6O3WLLs6QIJwstLgYtao7ssAAlws RacVlJ4ABt8OHU/GBi4eIzLVlmOl+F1snkq9/kAaZpBSo8/rBN6N1SvVLhNHbivNgAHN lzwQ== 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=n7/AQ14CtAPSsdBF4bK1N6nAJCYWmYHbSVQMVRCyl58=; fh=FsZvNuK0qXzIHpKngach73/EWdkC91/zDh9w34lnxX4=; b=qERmMrusINe1IYGiJ4beM2r15O6VTx5ZFhDrK3ueA5fC0TEQm1mYz9wDzKzhksYoqc kwwRRWNjAG45ZmXDIgz6w8RoZC9/DO7gy7dSz58Tm5WzTSaA5qXZxRoJSY4zQJ5HdYUk Ui0XsbI0m6JmMRPS0tEJqNcxLUWDlX1xKa26fy2ZIktBIB3pbc1UeVzsFvtHobFwZMAl FnQYfkWhtpv497jCKHtyWaqmdV9GVmIU0P5rfgmFmNkVx/zTgBJdPYqBB3FUPPyo8psd +1+kf+B15He6KViV5V5CWRrMY2QQFvdVHf7lHMKlIe14AZgS/Q1JGxnWa/f4UA2nfkNt mfCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ELKFiU6Q; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 29-20020a50875d000000b00551c3e30092si2497139edv.194.2023.12.14.13.42.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:42:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ELKFiU6Q; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-146-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7DBE21F22703 for ; Thu, 14 Dec 2023 21:42:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9945C6E2AA; 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="ELKFiU6Q"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="N18HNVVu" 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 37D636A34D 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=n7/AQ14CtAPSsdBF4bK1N6nAJCYWmYHbSVQMVRCyl58=; b=ELKFiU6QcHpmyjj4y3/ThWrC6NQsGQrxCPGsHKykjs/CeBfb1lK742gwL4JdDM8lCJjxFZ w+ymCW6goNmRY5vxbSXxHJ/onItb2M5fnM2QrmKkat5qnFhhrwKT8jrB4n+R6Ukd6zzinb 1jdOKuWs/T04n+S6Aou6k+sjVMrAS2iMYCfHDme3aNQKFJ3O1cdTPyagsQhPbkVA0wx2gR V5HQuORKoXg6WyYNjOyoMgwv1vDu+x9W84Rq46CcnV3SrIbOOOi5+btRwkOr9jrxFKuM2r 2u4tWmuFFrnavCGbKEMk/FpbZNgfhRGBR/Q8ByC4CaMGJNea1odvqekSvqiJNg== 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=n7/AQ14CtAPSsdBF4bK1N6nAJCYWmYHbSVQMVRCyl58=; b=N18HNVVuiXztnaW/iSDFaWUXfIQT0nam9vm/nj3pVKOO4M1DD9GYxXgV0hGTwzBUbPMjDr 9e6CQjVJbikgkJCg== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Francesco Dolcini , kernel test robot , Sebastian Andrzej Siewior Subject: [PATCH printk v3 02/14] printk: Adjust mapping for 32bit seq macros Date: Thu, 14 Dec 2023 22:47:49 +0106 Message-Id: <20231214214201.499426-3-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. __ulseq_to_u64seq() computes the upper 32 bits of the passed argument value (@ulseq). The upper bits are derived from a base value (@rb_next_seq) in a way that assumes @ulseq represents a 64bit number that is less than or equal to @rb_next_seq. Until now this mapping has been correct for all call sites. However, in a follow-up commit, values of @ulseq will be passed in that are higher than the base value. This requires a change to how the 32bit value is mapped to a 64bit sequence number. Rather than mapping @ulseq such that the base value is the end of a 32bit block, map @ulseq such that the base value is in the middle of a 32bit block. This allows supporting 31 bits before and after the base value, which is deemed acceptable for the console sequence number during runtime. Here is an example to illustrate the previous and new mappings. For a base value (@rb_next_seq) of 2 2000 0000... Before this change the range of possible return values was: 1 2000 0001 to 2 2000 0000 __ulseq_to_u64seq(1fff ffff) => 2 1fff ffff __ulseq_to_u64seq(2000 0000) => 2 2000 0000 __ulseq_to_u64seq(2000 0001) => 1 2000 0001 __ulseq_to_u64seq(9fff ffff) => 1 9fff ffff __ulseq_to_u64seq(a000 0000) => 1 a000 0000 __ulseq_to_u64seq(a000 0001) => 1 a000 0001 After this change the range of possible return values are: 1 a000 0001 to 2 a000 0000 __ulseq_to_u64seq(1fff ffff) => 2 1fff ffff __ulseq_to_u64seq(2000 0000) => 2 2000 0000 __ulseq_to_u64seq(2000 0001) => 2 2000 0001 __ulseq_to_u64seq(9fff ffff) => 2 9fff ffff __ulseq_to_u64seq(a000 0000) => 2 a000 0000 __ulseq_to_u64seq(a000 0001) => 1 a000 0001 [ john.ogness: Rewrite commit message. ] Reported-by: Francesco Dolcini Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202311171611.78d41dbe-oliver.sang@intel.com Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202311161555.3ee16fc9-oliver.sang@intel.com Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: John Ogness --- kernel/printk/printk_ringbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/printk_ringbuffer.h b/kernel/printk/printk_ringbuffer.h index b82a96dc2ea2..12f60c782e46 100644 --- a/kernel/printk/printk_ringbuffer.h +++ b/kernel/printk/printk_ringbuffer.h @@ -407,7 +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 - ((u32)rb_next_seq - ulseq); + seq = rb_next_seq - (s32)((u32)rb_next_seq - ulseq); return seq; } -- 2.39.2