All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops
@ 2016-10-20  1:31 Joel Fernandes
  2016-10-20  1:31 ` [PATCH 2/2] pstore: Use global ftrace filters for function trace filtering Joel Fernandes
  2016-11-14 18:56 ` [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Steven Rostedt
  0 siblings, 2 replies; 3+ messages in thread
From: Joel Fernandes @ 2016-10-20  1:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: Steven Rostedt, Kees Cook, Joel Fernandes, Ingo Molnar

Currently the global_ops filtering hash is not available to outside
users registering for function tracing. Provide an API for those
users to be able to choose global filtering.

This is in preparation for pstore's ftrace feature to be able to
use the global filters.

Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Joel Fernandes <joelaf@google.com>
---
 include/linux/ftrace.h |  2 ++
 kernel/trace/ftrace.c  | 13 +++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 7d565af..653600a 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -398,6 +398,7 @@ int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
 void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
 void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
 void ftrace_free_filter(struct ftrace_ops *ops);
+void ftrace_ops_set_global_filter(struct ftrace_ops *ops);
 
 int register_ftrace_command(struct ftrace_func_command *cmd);
 int unregister_ftrace_command(struct ftrace_func_command *cmd);
@@ -645,6 +646,7 @@ static inline unsigned long ftrace_location(unsigned long ip)
 #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
 #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
 #define ftrace_free_filter(ops) do { } while (0)
+#define ftrace_ops_set_global_filter(ops) do { } while (0)
 
 static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
 			    size_t cnt, loff_t *ppos) { return -ENODEV; }
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 84752c8..c768c7a 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -4233,6 +4233,19 @@ int ftrace_set_filter_ip(struct ftrace_ops *ops, unsigned long ip,
 }
 EXPORT_SYMBOL_GPL(ftrace_set_filter_ip);
 
+/**
+ * ftrace_ops_set_global_filter - setup ops to use global filters
+ * @ops - the ops which will use the global filters
+ *
+ * ftrace users who need global function trace filtering should call this.
+ */
+void ftrace_ops_set_global_filter(struct ftrace_ops *ops)
+{
+	ftrace_ops_init(ops);
+	ops->func_hash = &global_ops.local_hash;
+}
+EXPORT_SYMBOL_GPL(ftrace_ops_set_global_filter);
+
 static int
 ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
 		 int reset, int enable)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] pstore: Use global ftrace filters for function trace filtering
  2016-10-20  1:31 [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Joel Fernandes
@ 2016-10-20  1:31 ` Joel Fernandes
  2016-11-14 18:56 ` [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Joel Fernandes @ 2016-10-20  1:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: Steven Rostedt, Kees Cook, Joel Fernandes, Anton Vorontsov,
	Colin Cross, Tony Luck

Currently, pstore doesn't have any filters setup for function tracing.  This
has the associated overhead and may not be useful for users looking for tracing
specific set of functions.

ftrace's regular function trace filtering is done writing to
tracing/set_ftrace_filter however this is not available if not requested.
Inorder to be able to use this feature, the support to request global filtering
introduced earlier in the series should be requested before registering the
ftrace ops. Here we do the same.

Signed-off-by: Joel Fernandes <joelaf@google.com>
---
 fs/pstore/ftrace.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/ftrace.c b/fs/pstore/ftrace.c
index 1c6cf86..bcdcbcd 100644
--- a/fs/pstore/ftrace.c
+++ b/fs/pstore/ftrace.c
@@ -74,10 +74,13 @@ static ssize_t pstore_ftrace_knob_write(struct file *f, const char __user *buf,
 	if (!on ^ pstore_ftrace_enabled)
 		goto out;
 
-	if (on)
+	if (on) {
+		ftrace_ops_set_global_filter(&pstore_ftrace_ops);
 		ret = register_ftrace_function(&pstore_ftrace_ops);
-	else
+	} else {
 		ret = unregister_ftrace_function(&pstore_ftrace_ops);
+	}
+
 	if (ret) {
 		pr_err("%s: unable to %sregister ftrace ops: %zd\n",
 		       __func__, on ? "" : "un", ret);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops
  2016-10-20  1:31 [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Joel Fernandes
  2016-10-20  1:31 ` [PATCH 2/2] pstore: Use global ftrace filters for function trace filtering Joel Fernandes
@ 2016-11-14 18:56 ` Steven Rostedt
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2016-11-14 18:56 UTC (permalink / raw)
  To: Joel Fernandes; +Cc: linux-kernel, Kees Cook, Ingo Molnar

On Wed, 19 Oct 2016 18:31:42 -0700
Joel Fernandes <joelaf@google.com> wrote:

> Currently the global_ops filtering hash is not available to outside
> users registering for function tracing. Provide an API for those
> users to be able to choose global filtering.
> 
> This is in preparation for pstore's ftrace feature to be able to
> use the global filters.
> 
> Suggested-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Joel Fernandes <joelaf@google.com>
> ---
>  include/linux/ftrace.h |  2 ++
>  kernel/trace/ftrace.c  | 13 +++++++++++++
>  2 files changed, 15 insertions(+)
> 
> diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> index 7d565af..653600a 100644
> --- a/include/linux/ftrace.h
> +++ b/include/linux/ftrace.h
> @@ -398,6 +398,7 @@ int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
>  void ftrace_set_global_filter(unsigned char *buf, int len, int reset);
>  void ftrace_set_global_notrace(unsigned char *buf, int len, int reset);
>  void ftrace_free_filter(struct ftrace_ops *ops);
> +void ftrace_ops_set_global_filter(struct ftrace_ops *ops);
>  
>  int register_ftrace_command(struct ftrace_func_command *cmd);
>  int unregister_ftrace_command(struct ftrace_func_command *cmd);
> @@ -645,6 +646,7 @@ static inline unsigned long ftrace_location(unsigned long ip)
>  #define ftrace_set_filter(ops, buf, len, reset) ({ -ENODEV; })
>  #define ftrace_set_notrace(ops, buf, len, reset) ({ -ENODEV; })
>  #define ftrace_free_filter(ops) do { } while (0)
> +#define ftrace_ops_set_global_filter(ops) do { } while (0)
>  
>  static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
>  			    size_t cnt, loff_t *ppos) { return -ENODEV; }
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 84752c8..c768c7a 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -4233,6 +4233,19 @@ int ftrace_set_filter_ip(struct ftrace_ops *ops, unsigned long ip,
>  }
>  EXPORT_SYMBOL_GPL(ftrace_set_filter_ip);
>  
> +/**
> + * ftrace_ops_set_global_filter - setup ops to use global filters
> + * @ops - the ops which will use the global filters
> + *
> + * ftrace users who need global function trace filtering should call this.
> + */
> +void ftrace_ops_set_global_filter(struct ftrace_ops *ops)
> +{

I think we should add:

	if (ops->flags & FTRACE_OPS_FL_INITIALIZED)
		return;

This function must only be called if ops hasn't been initialized yet.
Probably need to add that in the comment for the function as well.

But other than that, this looks good. Post an update, and since the
next patch is dependent on this one, It may be best to go through your
tree (after I ack the next version of this patch).


-- Steve

> +	ftrace_ops_init(ops);
> +	ops->func_hash = &global_ops.local_hash;
> +}
> +EXPORT_SYMBOL_GPL(ftrace_ops_set_global_filter);
> +
>  static int
>  ftrace_set_regex(struct ftrace_ops *ops, unsigned char *buf, int len,
>  		 int reset, int enable)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-14 18:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-20  1:31 [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Joel Fernandes
2016-10-20  1:31 ` [PATCH 2/2] pstore: Use global ftrace filters for function trace filtering Joel Fernandes
2016-11-14 18:56 ` [PATCH 1/2] ftrace: Provide API to use global filtering for ftrace ops Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.