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 C62F322D794; Tue, 20 May 2025 14:18: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=1747750730; cv=none; b=iJ6EyAW1+3WHzk/6UO4UpiqmrSLstvx3pSiN2F5cVRUT6YbLOb/xHs0rbM5Cn037rxQmu6PLdgAhJh4UWWBiC4+aDfon4l+K3M6eu2SvK8Z8GWycfrzYMdwqUORZCf5D4IUMZBIF4l4elfksFjJ+jb8HB4FBBB/c5usd/pJbxCs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747750730; c=relaxed/simple; bh=jS7mZz27LWJVp8o0hGwHit3640eXTsmNTq4KRZdx/6s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvtLsKWo58JC79wrKshePVEhrSdxScE1yQ9T47q8XIurvIonAnoeoq7jbBYpwBM2t1vz3TkndcjfdYtjVCOioPnK0KVRSgRL50Ox/DLfMGcxQ3EytyV6UJcDfIn6c5uh2SWJpoAAUxPeLC13+SuRHpeUL3XfXNXzodHjGn4eLdo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oldXzC53; 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="oldXzC53" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC7B6C4CEE9; Tue, 20 May 2025 14:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747750730; bh=jS7mZz27LWJVp8o0hGwHit3640eXTsmNTq4KRZdx/6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oldXzC53dAPYiNONuh/KxyfzzYoISWdRHuQ2quKWicX1yy6xzB/dPTGpLWi33nmWe Xq9bC7cfc1aP8dixDQaKAoXBwQa3ytYWopMSc2EKj1OiIcjCcQSvjMoYwPeY2vnoBR /R5jKjvzcspunH5LIVKRJFGMDDsShtUnCDjwAlz4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, pengdonglin , "Steven Rostedt (Google)" Subject: [PATCH 6.14 102/145] ftrace: Fix preemption accounting for stacktrace trigger command Date: Tue, 20 May 2025 15:51:12 +0200 Message-ID: <20250520125814.562041994@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250520125810.535475500@linuxfoundation.org> References: <20250520125810.535475500@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-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 @@ -1560,7 +1560,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); }