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 9FAEC2505A2; Tue, 20 May 2025 14:11:52 +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=1747750312; cv=none; b=ac+c30N11oWaA8vmYlixpep6ndYp31Xa2cNsWBRebul3QfTYAP0qJwRAU08ZDwED8ft1Ce0GOurkhgWq3wbnsSB5Hb0tKjXgbkk/m78/A2W0VkuZGQgM8k8kofrJNOldIk/BG4Fz1pAE5ZCQqKSoSpI70WnW4EvvJ2Rrx7pt8yQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747750312; c=relaxed/simple; bh=hAA+pbsNOIu2mbHHweO0RHo2D1BWoQDXKG5fSVMYZT8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gpb4t6LCC7bidKvogyZM0RKVgHFCKFGWaEX2dhfEGxWMyxyumTPY+C0wkUvDhyko6+YwCpRDzW+q3WjllzwFqQxV+N6sgjOZWnbpLrFx0l8QjmshVNAU6ZAIT5qFmY27LkjHnYIWZqwIwZrokfixm912PoaZc68ihEWmelZMgUI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YHF7eeAL; 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="YHF7eeAL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 093F1C4CEEA; Tue, 20 May 2025 14:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1747750312; bh=hAA+pbsNOIu2mbHHweO0RHo2D1BWoQDXKG5fSVMYZT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YHF7eeALZG4aChDdJiSH1KgpqgRvbyKlxh0HzGARvZFEOMqaLhGra6j0sMByvMs4C NbJBn3N1QRGIsakfTaE5rFeOryElrh3Y6yA6WDxbeagsnsfIMvrIrmKIiEbV3XMOFh yv9zXR4NGbz2Lteuy5ml1URqOgoRt0eIW7hrZ6QQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, pengdonglin , "Steven Rostedt (Google)" Subject: [PATCH 6.12 104/143] ftrace: Fix preemption accounting for stacktrace filter command Date: Tue, 20 May 2025 15:50:59 +0200 Message-ID: <20250520125814.135463117@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250520125810.036375422@linuxfoundation.org> References: <20250520125810.036375422@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: pengdonglin commit 11aff32439df6ca5b3b891b43032faf88f4a6a29 upstream. The preemption count of the stacktrace filter command to trace ksys_read is consistently incorrect: $ echo ksys_read:stacktrace > set_ftrace_filter <...>-453 [004] ...1. 38.308956: => ksys_read => do_syscall_64 => entry_SYSCALL_64_after_hwframe The root cause is that the trace framework disables preemption when invoking the filter command callback in function_trace_probe_call: preempt_disable_notrace(); probe_ops->func(ip, parent_ip, probe_opsbe->tr, probe_ops, probe->data); preempt_enable_notrace(); Use tracing_gen_ctx_dec() to account for the preempt_disable_notrace(), which will output the correct preemption count: $ echo ksys_read:stacktrace > set_ftrace_filter <...>-410 [006] ..... 31.420396: => ksys_read => do_syscall_64 => entry_SYSCALL_64_after_hwframe Cc: stable@vger.kernel.org Fixes: 36590c50b2d07 ("tracing: Merge irqflags + preempt counter.") Link: https://lore.kernel.org/20250512094246.1167956-2-dolinux.peng@gmail.com Signed-off-by: pengdonglin Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_functions.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) --- a/kernel/trace/trace_functions.c +++ b/kernel/trace/trace_functions.c @@ -574,11 +574,7 @@ ftrace_traceoff(unsigned long ip, unsign static __always_inline void trace_stack(struct trace_array *tr) { - unsigned int trace_ctx; - - trace_ctx = tracing_gen_ctx(); - - __trace_stack(tr, trace_ctx, FTRACE_STACK_SKIP); + __trace_stack(tr, tracing_gen_ctx_dec(), FTRACE_STACK_SKIP); } static void