From nobody Sun Feb 8 15:28:56 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 92FA727A930; Wed, 14 May 2025 13:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747229953; cv=none; b=FUTEFz+9udUpakRgHUBB6SFRxQf7Q4nmZhnhIdUWrOoM4dYwQkAbZ1gi3rCXHjzv8I9f/dGKJ6J9NP+R1pehe6BWK+VKG+dChR01DXQ3kH7xOjBXQil5vUvJ1lQuILQWZeRztPUt7tQt3bKxgCPg8lrba9MYCo6B180b9/93/ew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747229953; c=relaxed/simple; bh=BEz47Ay0SnXLo032kX/uxFeO2wQ0x6Fp0KUQIe8W76g=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=m87NTfXD99QbkMsMI69dLxpcMnW+Ak0EuuDCTRC4/VCAT+yPXHW+Q98N1m6g8LnxsyOCXZe/NM+fH97OtHdt8xR+NGQtUahpO09bh/P40T9DEdTTSonB/2CbOXh6HuxEYOCgbj6Q/Ti70nIWANUwM5oM7PjPLPiPpNpOmw6CrYU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2814AC4CEED; Wed, 14 May 2025 13:39:13 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.98.2) (envelope-from ) id 1uFCKi-00000005IFS-23ps; Wed, 14 May 2025 09:39:40 -0400 Message-ID: <20250514133940.348447868@goodmis.org> User-Agent: quilt/0.68 Date: Wed, 14 May 2025 09:38:33 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, pengdonglin Subject: [for-linus][PATCH 2/4] ftrace: Fix preemption acounting for stacktrace trigger command References: <20250514133831.110736154@goodmis.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: pengdonglin When using the stacktrace trigger command to trace syscalls, the preemption count was consistently reported as 1 when the system call event itself had 0 ("."). For example: root@ubuntu22-vm:/sys/kernel/tracing/events/syscalls/sys_enter_read $ echo stacktrace > trigger $ echo 1 > enable sshd-416 [002] ..... 232.864910: sys_read(fd: a, buf: 556b1f3221d= 0, count: 8000) sshd-416 [002] ...1. 232.864913: =3D> ftrace_syscall_enter =3D> syscall_trace_enter =3D> do_syscall_64 =3D> entry_SYSCALL_64_after_hwframe The root cause is that the trace framework disables preemption in __DO_TRAC= E before invoking the trigger callback. Use the tracing_gen_ctx_dec() that will accommodate for the increase of the preemption count in __DO_TRACE when calling the callback. The result is the accurate reporting of: sshd-410 [004] ..... 210.117660: sys_read(fd: 4, buf: 559b725ba13= 0, count: 40000) sshd-410 [004] ..... 210.117662: =3D> ftrace_syscall_enter =3D> syscall_trace_enter =3D> do_syscall_64 =3D> entry_SYSCALL_64_after_hwframe Cc: stable@vger.kernel.org Fixes: ce33c845b030c ("tracing: Dump stacktrace trigger to the correspondin= g instance") Link: https://lore.kernel.org/20250512094246.1167956-1-dolinux.peng@gmail.c= om Signed-off-by: pengdonglin Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_event= s_trigger.c index b66b6d235d91..6e87ae2a1a66 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1560,7 +1560,7 @@ stacktrace_trigger(struct event_trigger_data *data, struct trace_event_file *file =3D data->private_data; =20 if (file) - __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP); + __trace_stack(file->tr, tracing_gen_ctx_dec(), STACK_SKIP); else trace_dump_stack(STACK_SKIP); } --=20 2.47.2