From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 212EA36E47F for ; Tue, 7 Jul 2026 15:04:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783436680; cv=none; b=m9tg85aQEfMG0kpP2DOPHo0B5n2PJoYxsjGVL6bv/PM0gHgKsznLRlMgd5bOJIISE+RHcgmoKGV/ib6o0ZYptNreGzeVgWOcn79P5H7rCmiNARfa4P46dCYQtvyS6cN6faW6eEdWsulPmrBSFex0vVK+JK62UhQpHbftF8Tl0jI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783436680; c=relaxed/simple; bh=JUuGK2lRAr3uDkonahalbTvpNXfJVpcw2TjZsADJ6CE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fQWyHULAk3QxE/uaAS4kE0/DrP5iP67+I6KrJucGiBavYK7CPEkahqRcugvR7vp52418+QgujwkQZTL+b5+Ixmig/dnhZPlYdopFVtcyNiyHm2Cu+f0LK5q7654+0aDNAC+6ybjqBfz9b1QPU8EBr0A22TcgFBO26RQ/FQJ61tc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=I3+n+pE6; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="I3+n+pE6" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so28536605e9.1 for ; Tue, 07 Jul 2026 08:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1783436677; x=1784041477; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=MNMm+K1n82gXoA0QCvJimYEIEGXjevfFGtDXgwHf6mU=; b=I3+n+pE6uCtUOVlF72Tdu7UZsRYX5lasW2wLMHiep4ckCQiJOBIvGe8sqhFlbzSuGg T8qmUaKphrTt3rfnWEB8N8m9NwulNVmk9J4jSrMcWvTMSgTPCMRbLkATZkCfU1XBnwiU Es8aSXYN6F6PUkwn3mmPD1ab5GtqVK4qxx/Qms7dFiTwbAduffzWWIX/0oJYG5hzL2GG 61y5Hr9nL6edmKJy/zXh0OV6lViGslskJcQyOfLw71RI2mXl5gqcr7AgaBaY8guC9wCf xYfBcBpnsORW7HvZpecUTehNt1jcWztXsyDtlulLsmIPYorgbHKsS1/A4CYrlfuF8ZqY niXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783436677; x=1784041477; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=MNMm+K1n82gXoA0QCvJimYEIEGXjevfFGtDXgwHf6mU=; b=RS3/BpZrCPDrz+rybsgEDgyRMtwyH6WU4vprLH/igJgL6m5B9PxlsgzCDiTYp4AKq1 WDQ0DopYYDMdWmBpEHkHB4X1ihxjEOTSNtnKbIdSaW+VnZtQY6/8naufkd5KLMKx1AOR gHjGnwKlUXWEejztMyWEYuzPH4VZ7eWSQi1IZSr9qvbHHgyY3fQuvckG/uZEvtKaf4Xk DDj5RrrF0m1uOa4Fvmkpx9k3+FeH3cp7HEO7iX5kWSF4JFbhizPEwpsdbMUQDkaXDMOM SDe/u7BTDfMOQa6Q4amoUoZpUVYBiPsSVtT0onNeEL9jnq4Y4CmTGY5gSsXLi7rSZQ3B 1AGQ== X-Forwarded-Encrypted: i=1; AHgh+Rp6/u+t6IOXH5D832XUgtUHd9fZ9GmWUrfyrD5xrrgPk5DT24oIlqcuMdaKw1SE0JgAvhKchhiJ+CLl8cc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0rVLIHddoW418v1E0hKsNGPj8edPzSSm2Tm8wSZmfzFUFsGVY P8USuKuBAJ2CvJ5LsBCNn5RzV83I1283Fr0FdRkllcxZoi9u5zbMrNZH4scKNXh0Zi8= X-Gm-Gg: AfdE7cm9y9PutSG1/qBYFCfyGIc4T820rOKIs9fysXWXmCrxMx5hC8IH5DL8X9TBgD2 Qd78yEProgq2jCTXxQfxg6o7nE8XWLSxWUNQK1ylPUr9CWjv1w+QO2BiiYTUGnryy3cymv02qD2 kh5e06VZySHSnx0z6J3DWPhph/pAa6uLNUewUeOq6C4CVvz71auWe9Mf6NKUdKb4EYvaxG5nFbU YNcP5QTSLliRWcGDPI+Ysw9G6H3V+MiQ9jXCd3H4vJZfDD9pnV6XuIzwZMVgzX2hCeczvkmfru/ M3nwIk1h3HbgTD87kPIjCnliEqlrJ1ONwoBw1/w5DJt1b6i7ei0Sz7wnH2mASmBD0TGgF4PUZXN n8x1+9bbA3htFzIgqZPPxrhkSm3JV+8WWWR4Ocr0IfIIGr+aPdVE5TlBryq1hUcYpP5e6VMJL+C S3UWt9ik7A0+XJ/Bg= X-Received: by 2002:a05:600c:198e:b0:493:bed6:85e6 with SMTP id 5b1f17b1804b1-493df0711f9mr67136355e9.15.1783436677306; Tue, 07 Jul 2026 08:04:37 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.130]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493e0f294a6sm123915975e9.1.2026.07.07.08.04.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 08:04:36 -0700 (PDT) Date: Tue, 7 Jul 2026 17:04:34 +0200 From: Petr Mladek To: Benedikt Spranger Cc: Andrew Murray , Jonathan Corbet , Shuah Khan , Russell King , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Steven Rostedt , John Ogness , Sergey Senozhatsky , Andrew Morton , Sebastian Andrzej Siewior , Clark Williams , Randy Dunlap , Linus Torvalds , Greg Kroah-Hartman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-rt-devel@lists.linux.dev Subject: Re: [PATCH v2 3/4] printk: nbcon: move printk_delay to console emiting code Message-ID: References: <20260630-deprecate_boot_delay-v2-0-f9883d36aa4b@thegoodpenguin.co.uk> <20260630-deprecate_boot_delay-v2-3-f9883d36aa4b@thegoodpenguin.co.uk> <20260703165654.71be8707@mitra> <20260707145411.53a10893@mitra> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260707145411.53a10893@mitra> On Tue 2026-07-07 14:54:11, Benedikt Spranger wrote: > On Mon, 6 Jul 2026 18:05:06 +0100 > Andrew Murray wrote: > > Hi Andrew, > > > On Fri, 3 Jul 2026 at 15:56, Benedikt Spranger > > wrote: > > > On Tue, 30 Jun 2026 17:35:59 +0100 > > > Andrew Murray wrote: > > > > The printk_delay and boot_delay features are helpful for debugging > > > > as kernel output can be slowed down during boot allowing messages > > > > to be seen before scrolling off the screen, or to correlate timing > > > > between some physical event and console output. > > > By now, it slows down the boot process, which is the handy part of > > > that feature. > > > > > > > However, since the introduction of nbcon and the legacy printer > > > > thread for PREEMPT_RT kernels, printk records are now emited to > > > > the console asynchronously to the caller of printk. Thus, any > > > > printk delay added by boot_delay/printk_delay continues to slow > > > > down the calling process but may not have any impact to the rate > > > > in which records are emited to the console. > > > Using this feature to slow down the boot/suspend/resume process and > > > implicit make printk() happen, is the usefull part of that feature. > > > Imagine this sequence (which hit me on suspend/resume on i.MX after > > > shutting down all secondary CPUs) > > > > > > printk("A"); > > > (do some stuff) > > > printk("B"); > > > read from peripheral --> system got stuck here since peripheral > > > was not clocked or powered or both any more. > > > > > > The delay (and later on a ugly patch to make printk() synchrounous) > > > helped to locate where the failed access happend. JTAG did not help, > > > since the CPU got stuck --> no JTAG communication to that CPU. First, it is great to know that people are actually using the boot_delay and printk_delay features. > > I understand the use-case, you sprinkle printk's so you can find the > > point where a read to a register causes the CPU to stop. This requires > > that the printk happens before the read, and the output from the > > printk is printed before the read. > Enabling existing debug features in the kernel was a good start. > > > > With your purposed change you *may* see "A", but never "B". > > > Quite challenging... > > At present you may see 'A' and you may see 'B'. > That's correct. > > > Prior to the changes in this patchset, and assuming an nbcon console > iMX swtched over to nbcon, so your assumption is correct. > > > (which may not be your usecase, but is perhaps representative of > > future use-cases), then the printk delay will always happen within the > > call to printk (and always before emitting). > Which is quite good, but can be better. (See the missing sync feature > mentioned in Johns reply) > > > However, depending on the context, that printk call may return (and > > proceed to your CPU halting register read), before the message is > > actually emitted to the console. I.e. it's a race. > I am aware of that. > > > This series moves the delay to the emit side, as well as moving the > > delay after the emit. Thus the calling code may make progress more > > quickly, but depending on the context, it may also flush/emit before > > returning from printk. > Unfortunately it makes things worse. > > > In my view, with or without this series, there are no guarantees that > > you will see 'A' and 'B'. And in any case, achieving the functionality > > for debugging required you to modify the printk anyway. > The "sync" feature is on the TODO list as John mentioned. > > > > So please leave the delay on the calling side - it is helpfull > > > there. > > > > If you want to ensure printk is synchronous, perhaps you could call > > nbcon_cpu_emergency_enter() prior to your printk, or perhaps there are > > already printk wrappers that do somthing similar whilst debugging? > As said I did an ugly hack and forced printk() to be synchronous. > > > Would that provide a more reliable way to guarantee output? > It does. To summarize this discussion: + Benedikt would prefer to add the synchronous mode before moving the delay from the printk() caller to the console emit code path. + The delay in the printk() caller code path did not guarantee the output but it increased the chance to see it. + The synchronous mode will be even more reliable than the delay in printk() caller path. Please, let me know if I did not get it right, John, did you have any plan how to add the synchronous mode, please? Does it look complicated? I guess that we would somehow need to "mis-use" the emergency priority and force it everywhere by some global system setting. Best Regards, Petr