Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp417341lqp; Wed, 22 May 2024 08:18:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUW4B0WibN1dCJzUjnvDv8b3iR23jt+OJZs1LMs6gT+SysATc69h33eD6QyuUUekTZ6mtAOVUKqizxDjNBKQblxhne3Hqm3W+AnecGcSg== X-Google-Smtp-Source: AGHT+IFSFvCVlUZqEY09DxLXoiieratxuKkhYxqb+vOrJc2cZM3mnAc5bPUs027YJgFtKBsojWpl X-Received: by 2002:a05:6870:5588:b0:22e:cee9:c239 with SMTP id 586e51a60fabf-24c68ada928mr2532920fac.7.1716391111140; Wed, 22 May 2024 08:18:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716391111; cv=pass; d=google.com; s=arc-20160816; b=1C6Qdm8atsg3CBYwOEGD54U5RklTU4uzJYfDiNXdvRhA+efdV6PzZxnvE+z4EKmlxK kFYoutjopGIBI0+6qScdDF9+9GxYWqTHKTzmhVjqdJI3wY4NRCUogqPxpS2pQtQVbomN 57WY7xprDV+NGdzbTNx4Fr1BNPAuVuxxwC3ByneMF4a3ppybgoNwDjKYy2V+aTUpwIIU iTRK2YZitQmJF9w4CeacmbbRCYsKwq8e4xz4Ic04sGtbWrVyp3PtKEP6m5lp/ASnY2K3 uU3eUBE1hq+P+G+dqys1sDlT/lUwarSbNM+wU+6Wllmn9XACTqPu+WWOnhzQf6C3ojta ajHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=/VaHGLRs/J+Fd8zTYkJgbyVxa4bOKjtKO0wVzh6qgxg=; fh=T0gxhBXY/jw1baSEHW+3GteMy00vSxnABkNIpDy2MeU=; b=inNM3fnivJUMDkzf2mbW8vxZkt/OCZsQLOSZMVYsbwF9avP2gne5WoCaDhPmaylUZs rbRbBYmEgQ2T28pp4IFniPfOwA5OpuByF5cO15uF7HBycpj4GUjcWN4t3UZlPLfp3OaL ZIdCQhZarJNoSwiztNdXXfWj84rBdgzLLbl+dwBRQy2VDbJ+QN9wVQwB9eN9poxwyB86 WC2tRh+cpdoLiTrtz7A0IkPLoqhfgHUk6un1eNkwk5ffCHVSFrWA9nGhqL7naFisqyP4 E56imzxV+lgSndNeG2Yaif9JKwUbEFpmk1B2aL+ssVl73XNBlsHUWGp2ELQyGjD1f/WA xQvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=O5agnHKn; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-186421-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e3a655fd3si35253661cf.807.2024.05.22.08.18.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 08:18:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186421-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=O5agnHKn; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-186421-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186421-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D4E631C22200 for ; Wed, 22 May 2024 15:18:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B368D7D08D; Wed, 22 May 2024 15:18:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="O5agnHKn" Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (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 C6B012B9C3 for ; Wed, 22 May 2024 15:18:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716391098; cv=none; b=KPvxcs6W/yA4sBinr+F+tMHhyPnaSyfKD3ZaPilnw419rInYVc5uzfSUvxm5rq8bXaFcoTGRm4+qkq4B9Sm9z7kvbE9Q+hkyN3Tds5g+/hgIX8WkBfFR9sfl/4vrzG6aNAAJduYm2vPokcYqYBeisbBzWpQDMg0lWsUkW2nyv34= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716391098; c=relaxed/simple; bh=sYIrj0Iso+GkGLJvhkjsCdF5mUygCRp/pk2z46+PRps=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nadJnM7WKMuBfjVTeinaOXqruFH8rQtvpxr3R1r1zpdI+3p+HrcNMYQtlX93inOm8OW7OPPrgY3pQ8wXzLPOFAdMjcwFU8ts2uSqmP7opGwIqKTCFyt4hCZlA0FY1rKEVXQGupofudFNuaWnmoJ/8TGKiUn7cXQY0IhzbMTo6Do= 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=O5agnHKn; arc=none smtp.client-ip=209.85.208.43 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 Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-56e1bbdb362so8323887a12.1 for ; Wed, 22 May 2024 08:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1716391095; x=1716995895; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=/VaHGLRs/J+Fd8zTYkJgbyVxa4bOKjtKO0wVzh6qgxg=; b=O5agnHKn6hK6uZz19BkSlwfKfZF/bIBLNaxr9/rZSo3TimocCvdv2jd/A22G9gotqU xOxscx4ry2cv57rz7lAwTy80hcRH+J1fDHzvME/d9Ou7ZvSAXU3rxWA9X+35LHg7Zz87 pszvcsErJy/gdYhexy6WF2z8CJC8A833Y+0zXYEFSXs31UHMy0z8vL5rWiOx+PZIauM2 zEkkijD9zzLgXf+M8lohCBGAkS+j3iz0mjxCAOIUkWA4SUCkxUxBJViasHYMY0UKOeGr J92K0nTT8TCMq77igMot+zOPlc4BHVuwg6+V5BZYVdrH8VP/k/xscQcz1p0iY9ygbHmc J/4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716391095; x=1716995895; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/VaHGLRs/J+Fd8zTYkJgbyVxa4bOKjtKO0wVzh6qgxg=; b=ObBe+6Jyd7xCdaWX4ZNaedWn7/t7RpYkK0QLku9NBDt7vcYmGYMKFYEJ9A+L4QAVNm divUAC/dqPC39lB20F43RlsAJz+fhQVIynqQOWehOBdo7M9WgZ7G0VS4gkpHR8SSI3+j vkw+/KB3NKL5aqW0mRcTyLfgVMRCgM9T64VXvExs0Za6yUeJ8fD2j+A0quGot2moAU5F jH4rhFnIdrAk2pqEaOoYGmqf4kIL3ezehWMxonRVg/0YqvFqoDuodx0j3D0PqwD7jHnQ WY0HdmHrrO72IVvowa6ey/VGSlTOIz2jUx0bomQnf1/sYshux3ClS+ZbvLhBVQBSUljO ru5g== X-Forwarded-Encrypted: i=1; AJvYcCV7ut2CQ8PD4aAmyVAz3TWf5o+MWNmUMB+pscJ96D8nWpppeqfu+JxP0Gil1+RjmeGuG4nLJBrIeFGAh42lhRXbW/z9HUcKA01bBWO8 X-Gm-Message-State: AOJu0YwkO8LqRAiJMNZLwa1UXG5+7RvSdKMB58/34g92OSjVWbHIypMV yRvZMUqGYIBAddEnhMBuEYqcEDVrgzqbFcnNe92NUR07guzNMIbbBuQDDYWzsVM= X-Received: by 2002:a17:906:cc12:b0:a61:42ce:bbe4 with SMTP id a640c23a62f3a-a62280d6253mr228842666b.27.1716391095199; Wed, 22 May 2024 08:18:15 -0700 (PDT) Received: from pathway.suse.cz ([176.114.240.50]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1781d6bfsm1789227566b.31.2024.05.22.08.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 08:18:14 -0700 (PDT) Date: Wed, 22 May 2024 17:18:13 +0200 From: Petr Mladek To: Sreenath Vijayan Cc: john.ogness@linutronix.de, corbet@lwn.net, gregkh@linuxfoundation.org, jirislaby@kernel.org, rdunlap@infradead.org, rostedt@goodmis.org, senozhatsky@chromium.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, taichi.shimoyashiki@sony.com, daniel.palmer@sony.com, anandakumar.balasubramaniam@sony.com Subject: Re: [PATCH v6 1/2] printk: Add function to replay kernel log on consoles Message-ID: References: <90ee131c643a5033d117b556c0792de65129d4c3.1710220326.git.sreenath.vijayan@sony.com> 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: <90ee131c643a5033d117b556c0792de65129d4c3.1710220326.git.sreenath.vijayan@sony.com> On Wed 2024-03-13 15:50:52, Sreenath Vijayan wrote: > Add a generic function console_replay_all() for replaying > the kernel log on consoles, in any context. It would allow > viewing the logs on an unresponsive terminal via sysrq. > > Reuse the existing code from console_flush_on_panic() for > resetting the sequence numbers, by introducing a new helper > function __console_rewind_all(). It is safe to be called > under console_lock(). > > Try to acquire lock on the console subsystem without waiting. > If successful, reset the sequence number to oldest available > record on all consoles and call console_unlock() which will > automatically flush the messages to the consoles. > > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -4259,6 +4271,23 @@ void kmsg_dump_rewind(struct kmsg_dump_iter *iter) > } > EXPORT_SYMBOL_GPL(kmsg_dump_rewind); > > +/** > + * console_replay_all - replay kernel log on consoles It should rather be called "console_try_replay_all()" to make it clear that it is just the best effort. > + * > + * Try to obtain lock on console subsystem and replay all > + * available records in printk buffer on the consoles. > + * Does nothing if lock is not obtained. > + * > + * Context: Any context. This should be: * Context: Any, except for NMI Basically only lockless code is safe in NMI which is not the case here. > + */ > +void console_replay_all(void) > +{ > + if (console_trylock()) { > + __console_rewind_all(); > + /* Consoles are flushed as part of console_unlock(). */ > + console_unlock(); > + } > +} > #endif Otherwise, it looks good. With the two changes: Reviewed-by: Petr Mladek I am sorry for the late review. I have been snowed under tasks. Also I had healthy problems. I have seen a mail that Greg has queued the patch in tty-next. I am not sure if it still can be fixed. It will be perfectly fine to change this by a followup patch. Best Regards, Petr