Finally kill trace_uprobe->enabled and add is_trace_uprobe_enabled()
which can rely on TP_FLAG_TRACE/TP_FLAG_PROFILE bits we set/clear
anyway.

Note that we could do this from the very beginning, ->enabled was
never strictly needed. But I'd prefer to do this as a last change
so that it can be dropped if the reviewers do not like the (ab)use
of tu->flags.

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---
 kernel/trace/trace_uprobe.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c
index 642e003..1e1633c 100644
--- a/kernel/trace/trace_uprobe.c
+++ b/kernel/trace/trace_uprobe.c
@@ -40,7 +40,6 @@ struct trace_uprobe {
        struct list_head                list;
        struct ftrace_event_class       class;
        struct ftrace_event_call        call;
-       bool                            enabled;
        struct uprobe_consumer          consumer;
        struct trace_uprobe_filter      filter;
        struct inode                    *inode;
@@ -633,31 +632,33 @@ partial:
        return TRACE_TYPE_PARTIAL_LINE;
 }
 
+static inline bool is_trace_uprobe_enabled(struct trace_uprobe *tu)
+{
+       return tu->flags & (TP_FLAG_TRACE | TP_FLAG_PROFILE);
+}
+
 static int probe_event_enable(struct trace_uprobe *tu, int flag)
 {
        int ret = 0;
 
-       if (tu->enabled)
+       if (is_trace_uprobe_enabled(tu))
                return -EINTR;
 
        tu->flags |= flag;
        ret = uprobe_register(tu->inode, tu->offset, &tu->consumer);
        if (ret)
                tu->flags &= ~flag;
-       else
-               tu->enabled = true;
 
        return ret;
 }
 
 static void probe_event_disable(struct trace_uprobe *tu, int flag)
 {
-       if (!tu->enabled)
+       if (!is_trace_uprobe_enabled(tu))
                return;
 
        uprobe_unregister(tu->inode, tu->offset, &tu->consumer);
        tu->flags &= ~flag;
-       tu->enabled = false;
 }
 
 static int uprobe_event_define_fields(struct ftrace_event_call *event_call)
-- 
1.5.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to