From nobody Thu Dec 18 08:13:32 2025 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 CFB0F1AAE0B for ; Thu, 2 Jan 2025 22:31:39 +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=1735857099; cv=none; b=i24lcUYLOSWXWnkOzvqzBas77W8aXvrJOaSCEOLOygLNWtyCciCLB5tWP3Phu86UDJLMQGaReL6FqUn44RSnJs2aX/DVvytqjXF3FfL2aVJlFUENDFzBpw3bjLqqIuPIMEkzWg3y+IuiI4PcqSE7EeGmYArDHSPxRRpyigyRxk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735857099; c=relaxed/simple; bh=5HRbPWbYY2dmBQhdkmcDeOhjo2HdKw/9gCN0XTEYS48=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=jsmZqyTS+L8Hr7kMLQy845S5LqiolHl8nBfrbAVSkpb0NhHZJFDfbjM848PA0fjdjrL+qC2GIN4dRKbwWc2fSv4Gc7XkMbbh+lyrhpjoHPIbCWbVaDOX5SBpcsMmczLIaIHr8jNDr2awjKjNz2ecGF3g/dGwFnj9yjKjhUXWH0k= 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 71E53C4CED0; Thu, 2 Jan 2025 22:31:38 +0000 (UTC) Date: Thu, 2 Jan 2025 17:32:54 -0500 From: Steven Rostedt To: Linus Torvalds Cc: LKML , Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Kohei Enju , Zilin Guan Subject: [GIT PULL v2] ftrace: Fixes for v6.13 Message-ID: <20250102173254.04d784d6@gandalf.local.home> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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" Linus, Fixes for ftrace in v6.13: - Add needed READ_ONCE() around access to the fgraph array element The updates to the fgraph array can happen when callbacks are registered and unregistered. The __ftrace_return_to_handler() can handle reading either the old value or the new value. But once it reads that value it must stay consistent otherwise the check that looks to see if the value is a stub may show false, but if the compiler decides to re-read after that check, it can be true which can cause the code to crash later on. - Make function profiler use the top level ops for filtering again When function graph became available for instances, its filter ops became independent from the top level set_ftrace_filter. In the process the function profiler received its own filter ops as well. But the function profiler uses the top level set_ftrace_filter file and does not have one of its own. In giving it its own filter ops, it lost any user interface it once had. Make it use the top level set_ftrace_filter file again. This fixes a regression. Please pull the latest ftrace-v6.13-rc5-2 tree, which can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.git ftrace-v6.13-rc5-2 Tag SHA1: 5481b9d16647243f56a1660ee24edb8ea400b6af Head SHA1: 789a8cff8d2dbe4b5c617c3004b5eb63fa7a3b35 Kohei Enju (1): ftrace: Fix function profiler's filtering functionality Zilin Guan (1): fgraph: Add READ_ONCE() when accessing fgraph_array[] ---- kernel/trace/fgraph.c | 2 +- kernel/trace/ftrace.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) --------------------------- diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c index ddedcb50917f..30e3ddc8a8a8 100644 --- a/kernel/trace/fgraph.c +++ b/kernel/trace/fgraph.c @@ -833,7 +833,7 @@ static unsigned long __ftrace_return_to_handler(struct = fgraph_ret_regs *ret_regs #endif { for_each_set_bit(i, &bitmap, sizeof(bitmap) * BITS_PER_BYTE) { - struct fgraph_ops *gops =3D fgraph_array[i]; + struct fgraph_ops *gops =3D READ_ONCE(fgraph_array[i]); =20 if (gops =3D=3D &fgraph_stub) continue; diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 9b17efb1a87d..2e113f8b13a2 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -902,16 +902,13 @@ static void profile_graph_return(struct ftrace_graph_= ret *trace, } =20 static struct fgraph_ops fprofiler_ops =3D { - .ops =3D { - .flags =3D FTRACE_OPS_FL_INITIALIZED, - INIT_OPS_HASH(fprofiler_ops.ops) - }, .entryfunc =3D &profile_graph_entry, .retfunc =3D &profile_graph_return, }; =20 static int register_ftrace_profiler(void) { + ftrace_ops_set_global_filter(&fprofiler_ops.ops); return register_ftrace_graph(&fprofiler_ops); } =20 @@ -922,12 +919,11 @@ static void unregister_ftrace_profiler(void) #else static struct ftrace_ops ftrace_profile_ops __read_mostly =3D { .func =3D function_profile_call, - .flags =3D FTRACE_OPS_FL_INITIALIZED, - INIT_OPS_HASH(ftrace_profile_ops) }; =20 static int register_ftrace_profiler(void) { + ftrace_ops_set_global_filter(&ftrace_profile_ops); return register_ftrace_function(&ftrace_profile_ops); }