From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326985; b=RKHVYQkyLY6t4C5eE+A3vxKqTtH/VP++riqWjcNR7D4vjAw9ZQB8MhJO+kag/Jir62Y0 x8Ftnv8y4dkOVjN4oiqRSU/ei5S6lKjdFzb+wn59RZS5Ev4YCu/ltPNVBMw9jj9IleDoR eckHSSQllpcemh+PUwwZXnRbjDIS/HghNqch7lmIZaEPi0e/awsgMI9MQMezphCoSMATO o/dpVFqaRjFa3G6hLI1zv5xV/pRPItXdPU4wX247p9lZTZPXmMkH4RRVy4o0z+qWfU1YD KHrIGXVpByP6Hk0iZbI0WV4YmcGTjiyttK5ZSTIzpolfO8BJvWIQa6j+tY3zTOuAeMg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326985; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8ZB9DSvDPcmLjTfwm0Emf2ZrNA91XPRHnKkVrv/17Lk=; b=B92BtcwN5beQgjKJ+nYgGm57AzS05eJzHE9X/khKGLVotTGRBUYYRgd9EWLjuqK1tvP0 mLFqpjAj+3oK7q98vtzqPA5YnQVcPeor5GIFVfzkiiGFDZctmIlYopwJ2bJZ/igmGnR0O Plz/PyTNw3OFX/Ch+1wyY0YeSIkZ38G02ZAg/gY8OWbMm62axYPCriwd8Un12gom5cK3b wFUA5zvmKuUApB4Kk27wVaDqpJZvFJDtKIoNx9F7LT2R0wHpAe3j2E1B0D5zuuf/9YBih EsveE+TNb0JyrirsBzfuhoWYyatrj8th+dlV/oJvgUeAoWjDQsNP8lLee/mtgidpb4w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V7+BsldC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D0DE60A3808 for ; Thu, 3 Dec 2026 19:43:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=V7+BsldC Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA1E1F000C2; Thu, 3 Dec 2026 19:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326985; bh=8ZB9DSvDPcmLjTfwm0Emf2ZrNA91XPRHnKkVrv/17Lk=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=V7+BsldCrmywBxVSZiUikKDVJzaXQFamwJ9lkaNywzM92l3RurVW+eCz8WTRyus8D fvMyOacEgyoc1nGe94fl/KYhiaUQozVbt0onF4paMP7q7N3pKTGPhwKJfqwTW23Zlo gveSyK6lWyc70mqPnBman40Csvp7tWXRqrQ7VclR/cH9i4HoChB1mMPgvA/+UDVtPW jiCr43G0X//ujTj6mX8hDWTElMj2uxTF6vQMhg4BIsxLHIiGDoPpSxZcRfZbpyUR7I 5Z5DTlQ93V7363IlaAESGOSSQmxn1PC8HHPSoE/62oKzdadLT95LfqwKtZFX780cB/ +8gzyR61BXlYA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v10 08/19] tracing/remotes: Add dmesg tracefs file Reply-To: sashiko-reviews@lists.linux.dev To: "Vincent Donnefort" , linux-trace-kernel@vger.kernel.org In-Reply-To: <20261203190007.2431041-9-vdonnefort@google.com> References: <20261203190007.2431041-1-vdonnefort@google.com> <20261203190007.2431041-9-vdonnefort@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 19:43:04 +0000 X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] tracing/remotes: synchronous dmesg drain under remote->lock on enable - [Medium] tracing/remotes: trace_remote_iter_free() clears dmesg before flushing poll - [Low] tracing/remotes: dmesg polling stalls without consuming when !CONFIG_PRINTK -- commit 0f953f3a2ea37a1e06fbc59b11b172138965ff61 Author: Vincent Donnefort tracing/remotes: Add dmesg tracefs file This commit adds a dmesg tracefs file for trace remotes that consumes buffered events from the polling worker and prints them with pr_info(). > diff --git a/kernel/trace/trace_remote.c b/kernel/trace/trace_remote.c > index 038a8e35ac640..f1ceb1733f45b 100644 > --- a/kernel/trace/trace_remote.c > +++ b/kernel/trace/trace_remote.c [ ... ] > @@ -395,10 +397,15 @@ static int __alloc_ring_buffer_iter(struct trace_re= mote_iterator *iter, int cpu) > return 0; > } > =20 > +static bool trace_remote_do_dmesg(struct trace_remote *remote); > + > static void trace_remote_do_poll(struct trace_remote *remote) > { > + bool yield; > + > ring_buffer_poll_remote(remote->trace_buffer, RING_BUFFER_ALL_CPUS); > - schedule_delayed_work(&remote->poll_work, msecs_to_jiffies(remote->poll= _ms)); > + yield =3D trace_remote_do_dmesg(remote); > + schedule_delayed_work(&remote->poll_work, yield ? 0 : msecs_to_jiffies(= remote->poll_ms)); > } [Severity: Medium] Can calling trace_remote_do_dmesg() from trace_remote_do_poll() stall dmesg_write() under remote->lock? When remote->poll_cnt is 0, dmesg_write() calls trace_remote_inc_poll() -> trace_remote_do_poll() synchronously under remote->lock. That takes down_write(&remote->reader_lock) and runs up to 1000 pr_info() calls before returning. On systems with legacy direct consoles (such as serial consoles), flushing those events stalls dmesg_write() and blocks all other control and open operations on the remote. Scheduling poll_work asynchronously with delay 0 avoids printk I/O and reader_lock under remote->lock. [ ... ] > @@ -487,6 +502,11 @@ static void trace_remote_iter_free(struct trace_remo= te_iterator *iter) > lockdep_assert_held(&remote->lock); > =20 > switch (iter->type) { > + case TRI_DMESG: > + WARN_ON_ONCE(remote->dmesg !=3D iter); > + WRITE_ONCE(remote->dmesg, NULL); > + flush_delayed_work(&remote->poll_work); > + fallthrough; > case TRI_CONSUMING: > trace_remote_dec_poll(remote); > break; [Severity: Medium] Does clearing remote->dmesg before flush_delayed_work() cause a spurious poll and leave unconsumed events in remote->trace_buffer? flush_delayed_work() deletes the pending poll_ms timer, immediately queues __poll_remote(), and waits for it under remote->lock. That forced poll pulls new remote events and re-arms poll_work, only for trace_remote_dec_poll() to cancel it right after when poll_cnt hits 0. Because remote->dmesg is already NULL during that forced run, trace_remote_do_dmesg() skips consuming those newly polled events. The remaining entries then cause trace_remote_try_unload() to keep the buffer loaded after trace_remote_put(). Decrementing poll_cnt first and calling flush_work(&remote->poll_work.work) only when poll_cnt stays non-zero avoids forcing a pending timer to run during teardown. [ ... ] > @@ -883,6 +909,87 @@ static const struct file_operations trace_fops =3D { > .release =3D trace_release, > }; > =20 > +static bool trace_remote_do_dmesg(struct trace_remote *remote) > +{ > + struct trace_remote_iterator *iter =3D smp_load_acquire(&remote->dmesg); > + unsigned int max_events =3D 1000; > + > + if (!iter) > + return false; > + > + trace_remote_iter_read_start(iter); > + > + while (trace_remote_iter_read_event(iter)) { > + trace_seq_init(&iter->seq); > + > + trace_remote_iter_print_event(iter); > + trace_seq_putc(&iter->seq, 0); > + if (!pr_info("%s", seq_buf_str(&iter->seq.seq))) > + break; > + > + trace_remote_iter_move(iter); [Severity: Low] What happens here when CONFIG_PRINTK is disabled? CONFIG_TRACE_REMOTE does not depend on CONFIG_PRINTK, and the _printk() stub always returns 0. Enabling dmesg then pins the remote buffer, but trace_remote_do_dmesg() breaks before trace_remote_iter_move() and re-formats the same head event every poll_ms tick without consuming it. Guarding the dmesg file or returning -EOPNOTSUPP in trace_remote_enable_dmesg() when !IS_ENABLED(CONFIG_PRINTK) would avoid this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203190007.2431= 041-1-vdonnefort@google.com?part=3D8