From mboxrd@z Thu Jan 1 00:00:00 1970 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 76B3D13635C; Tue, 20 May 2025 13:57:50 +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=1747749470; cv=none; b=m3wb5QgahCAoOF7ZtNiJKXRR2Ih64Gnr5xiWFHNCEWUixiaFRCCYgSDfNLTVRPm6e9ZmFffO2rf8FbT4Jvj6lqqwcfbBse+B28r5y5b6MK2RrMsgvwrtkcyUQGv0sCA00Mn3zV8jWVKrLfpIeOBslzoUWFGwgsK/6e28ZxQ7N5o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747749470; c=relaxed/simple; bh=VWO44E/VUx01JAK+5EnBoP6U473XsgTa8ObdYZ4kiaU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M6SAwe8bSmK2geK7L/wuxqxspJxKP8K928f83ehDGHlvf7wno1USHYoeBBupIxkyZBk/XlESbtGUtLlwdhQeeRa5nM4c11nqb6jFF65t8IuKpwMNiEkOCgm8syJZl9Czl/Iz4d+DCiO62tHrX7+3LrjtjFsffP85mbCIbxRZhXQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NpQeF8c8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NpQeF8c8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3357C4CEE9; Tue, 20 May 2025 13:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747749470; bh=VWO44E/VUx01JAK+5EnBoP6U473XsgTa8ObdYZ4kiaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpQeF8c8j6D/57jVhfQeJw1ltjHXDP3kZ7UmgRVMAXrp7DIyZHlWHyHIO6/tNCk8U Vy2b+fm8tARpniR4xFS5YPf1yZ8zexlh4aKGeWIiMPtRVsbwfIwgGa3VpnYhvWpOwi 19/q+8EphPWlKe/sicswzYL/NAe0UAr4fq10ZUpw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, pengdonglin , "Steven Rostedt (Google)" Subject: [PATCH 6.1 55/97] ftrace: Fix preemption accounting for stacktrace trigger command Date: Tue, 20 May 2025 15:50:20 +0200 Message-ID: <20250520125802.814361817@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250520125800.653047540@linuxfoundation.org> References: <20250520125800.653047540@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: pengdonglin commit e333332657f615ac2b55aa35565c4a882018bbe9 upstream. 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: 556b1f3221d0, count: 8000) sshd-416 [002] ...1. 232.864913: => ftrace_syscall_enter => syscall_trace_enter => do_syscall_64 => entry_SYSCALL_64_after_hwframe The root cause is that the trace framework disables preemption in __DO_TRACE 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: 559b725ba130, count: 40000) sshd-410 [004] ..... 210.117662: => ftrace_syscall_enter => syscall_trace_enter => do_syscall_64 => entry_SYSCALL_64_after_hwframe Cc: stable@vger.kernel.org Fixes: ce33c845b030c ("tracing: Dump stacktrace trigger to the corresponding instance") Link: https://lore.kernel.org/20250512094246.1167956-1-dolinux.peng@gmail.com Signed-off-by: pengdonglin Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -1539,7 +1539,7 @@ stacktrace_trigger(struct event_trigger_ struct trace_event_file *file = data->private_data; 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); }