Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp502334rdf; Tue, 21 Nov 2023 08:17:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7+bclD8sSRU3kE7bxszOzv4UYQ0PCb8dlKalQTPRO4Yz9hVGeT4tbuZiY/NbqUA8ivxh3 X-Received: by 2002:a05:6a20:12cd:b0:154:b4cb:2e8c with SMTP id v13-20020a056a2012cd00b00154b4cb2e8cmr10223188pzg.24.1700583473290; Tue, 21 Nov 2023 08:17:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700583473; cv=none; d=google.com; s=arc-20160816; b=MJikNpYM2IAf17X8gofmmkZ9MANqIPAKnLvgMfLqF+Om2d1l6JAqO74CiYPATqGtfo 2M83W5ryT/XCZ93lFvHj2OsRaNdWDqG2HPJalB1Sf/bTlq9TxalU7MQOc14puHRjh0Uh 2mI6XNVKuBH4JGMKK2c7hHLp6mctLUq70LiNkKrHPSbT7qVImoB+Vi4yFsSJAE0k2aeY WhwucxzYAidZdE16es6wvMDHLl7oUl5EZ32YrfdLjJbJi9GQPmojVyDoWBCPDxN1BazI tMlPRCf6HJmqlNjUBUzC1yns1xei6vPqWxjJ03ltbzXci+WgJA/eQG4rr2VRYXJa0XCN TUyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=AO5kesI1HmDAihR6XXO3SekHStdGriMuI91PxRGMYVg=; fh=BgW6TAwdf6B5qOl/CYM4mR4uAPTGSH1YWOTjndww6CQ=; b=07bf9WKrmMkowHJ9yi15rMMCElFFGncpZ0P1OIrsLtw6vM6u5qdI3XqYh8pCdPM1S4 vLwMd/9xK/fivlrtwc9qLlApVSLQOaQ8Lk/MfC0R1fnQ9lV70dzuRDvgjy2YVdsE5Wg5 w2nSK+2560ucs7od8JMTTQJyX+WTUUuD/OQ/lZcSuAHNl3/M9zn6aCFJ8zUXyfBorT8m peCW/ajx0/yu6L/CzWcguA0Yin+WxwAGMhIc6Ke0cU7c66pQx2v2xrqNMIks0VpCxxu3 ZT0eOazU1iAEvnYKiISXcq/B1fpMapkYcpEvawiZT8s+R4zkyD5F/4aatA12Y1Uh60H8 m/2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VuZLF+io; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r6-20020a63fc46000000b005be00714949si10642538pgk.222.2023.11.21.08.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 08:17:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VuZLF+io; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1C0738029860; Tue, 21 Nov 2023 08:17:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjKUQRn (ORCPT + 99 others); Tue, 21 Nov 2023 11:17:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbjKUQRm (ORCPT ); Tue, 21 Nov 2023 11:17:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E19C5112 for ; Tue, 21 Nov 2023 08:17:38 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1700583456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AO5kesI1HmDAihR6XXO3SekHStdGriMuI91PxRGMYVg=; b=VuZLF+io25nu8e82+NON/UNkilGW2j0iMgE6Ijg1eouipnoC8vZ/r1YL+Y1GoRxoZLSzyv s3C0j2wFdvc0bJbE3oRrfNWHJrEnitDgXHnxUedeBEzvb7NQ/4/yGgfzZxbfHoGp+ah9OD zEc3HpnSkygoyO2+Tj/NLMxGrnT9x+bbOlZw8Jt2Q/wcaV4Pxhcr1omZ4yT5rAhOZX4q0r BzZpHnTHBPZeD86wZXSNkR/R+lw9Ux1o9kpayQM+KaXxfYjOlqNmbs083YulY079qRn8wp 643I6jmoBs5bP0w3uC1PAzZgL7T8yT6hxlQZKFR1LbnXmfj3ZWAnyhlC2H6hyw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1700583456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AO5kesI1HmDAihR6XXO3SekHStdGriMuI91PxRGMYVg=; b=bha82Qz14hKJM0w3dswspNNWNZFIbGHrlRHi4QCRjX0HvIMbcXabULGV/7Bb0Qn31lh4JG 6XwkUedyB/tBoaBQ== To: Sebastian Andrzej Siewior Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Mukesh Ojha Subject: Re: [PATCH printk v2 1/9] printk: ringbuffer: Do not skip non-finalized records with prb_next_seq() In-Reply-To: <20231120134556.DkKNwy7B@linutronix.de> References: <20231106210730.115192-1-john.ogness@linutronix.de> <20231106210730.115192-2-john.ogness@linutronix.de> <20231120134556.DkKNwy7B@linutronix.de> Date: Tue, 21 Nov 2023 17:23:35 +0106 Message-ID: <87lear2i8w.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INVALID_DATE_TZ_ABSURD, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 21 Nov 2023 08:17:51 -0800 (PST) On 2023-11-20, Sebastian Andrzej Siewior wrote: > based on my research this should be the most recent post of this patch. > If so then > > On 2023-11-06 22:13:22 [+0106], John Ogness wrote: >> --- a/kernel/printk/printk_ringbuffer.c >> +++ b/kernel/printk/printk_ringbuffer.c >> + /* >> + * The provided sequence is only the lower 32 bits of the ringbuffer >> + * sequence. It needs to be expanded to 64bit. Get the first sequence >> + * number from the ringbuffer and fold it. >> + */ >> + seq = rb_first_seq - ((u32)rb_first_seq - ulseq); > > This needs to become > seq = rb_first_seq - ((s32)((u32)rb_first_seq - ulseq)); > > in order to continue booting on 32bit. Indeed. The code assumes the passed in value (@ulseq) always represents a 64-bit number that is less than or equal to the basis value (@rb_first_seq). For kernel/printk/nbcon.c:__nbcon_seq_to_seq() that assumption is correct. For this function, it is not. Your change will round up or down to the nearest 32 bits of the basis value. For example, with @rb_first_seq = 0x200000000 and @ulseq = 0x1: before your change (where @ulseq cannot represent something higher than @rb_first_seq): @ulseq translates to 0x100000001 after your change: @ulseq translates to 0x200000001 Since __ulseq_to_u64seq() must deal with arbitrary values, I think the 32-bit rounding is appropriate. Despite not strictly being necessary (because of the valid assumption), I think we should also update __nbcon_seq_to_seq() to avoid any bizarre cases due to different translations of the 32-bit value. In fact, there is no reason to have 2 macros for this. I will create a single macro using the 32-bit rounding. Thanks for researching this! John