On 9/5/25 19:30, Steven Rostedt wrote:
On Fri, 5 Sep 2025 16:19:02 -0700
Guenter Roeck <[email protected]> wrote:

+++ b/kernel/trace/fgraph.c
@@ -1391,10 +1391,11 @@ int register_ftrace_graph(struct fgraph_ops *gops)
  error:
        if (ret) {
                ftrace_graph_active--;
                gops->saved_func = NULL;
                fgraph_lru_release_index(i);
+               unregister_pm_notifier(&ftrace_suspend_notifier);

Is this really correct ? The pm notifier is only registered if
ftrace_graph_active==1, but not if it is larger than that.
The above code unregisters it unconditionally, even if
ftrace_graph_active > 1. I can see that the resulting double
unregistration in unregister_ftrace_graph() doesn't really
matter since the error return will be ignored, but is it really
irrelevant for the successful registered graphs no longer get the
benefit of the pm notifier callback ?

Ah right, it should be:

error:
        if (ret) {
                ftrace_graph_active--;
                gops->saved_func = NULL;
                fgraph_lru_release_index(i);
                if (!ftrace_graph_active)
                        unregister_pm_notifier(&ftrace_suspend_notifier);
        }
        return ret;

I missed that there's a:

        ret = ftrace_startup_subops(&graph_ops, &gops->ops, command);
        if (!ret)
                fgraph_array[i] = gops;

Just before the error label, so the goto error isn't the only path there
that can affect the ret variable.

I could add a patch or you could send one.



I'll try to send a patch later tonight.

Guenter



Reply via email to