[PATCH bpf-next 15/25] ftrace: factor out __unregister_ftrace_direct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Factor out __unregister_ftrace_direct, which doesn't hold the direct_mutex
lock.

Signed-off-by: Menglong Dong <dongml2@xxxxxxxxxxxxxxx>
---
 kernel/trace/ftrace.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 0befb4c93e89..5b6b74ea4c20 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -113,6 +113,8 @@ bool ftrace_pids_enabled(struct ftrace_ops *ops)
 }
 
 static void ftrace_update_trampoline(struct ftrace_ops *ops);
+static int __unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+				      bool free_filters);
 
 /*
  * ftrace_disabled is set when an anomaly is discovered.
@@ -6046,8 +6048,8 @@ EXPORT_SYMBOL_GPL(register_ftrace_direct);
  *  0 on success
  *  -EINVAL - The @ops object was not properly registered.
  */
-int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
-			     bool free_filters)
+static int __unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+				      bool free_filters)
 {
 	struct ftrace_hash *hash = ops->func_hash->filter_hash;
 	int err;
@@ -6057,10 +6059,8 @@ int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
 	if (!(ops->flags & FTRACE_OPS_FL_ENABLED))
 		return -EINVAL;
 
-	mutex_lock(&direct_mutex);
 	err = unregister_ftrace_function(ops);
 	remove_direct_functions_hash(hash, addr);
-	mutex_unlock(&direct_mutex);
 
 	/* cleanup for possible another register call */
 	ops->func = NULL;
@@ -6070,6 +6070,18 @@ int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
 		ftrace_free_filter(ops);
 	return err;
 }
+
+int unregister_ftrace_direct(struct ftrace_ops *ops, unsigned long addr,
+			     bool free_filters)
+{
+	int err;
+
+	mutex_lock(&direct_mutex);
+	err = __unregister_ftrace_direct(ops, addr, free_filters);
+	mutex_unlock(&direct_mutex);
+
+	return err;
+}
 EXPORT_SYMBOL_GPL(unregister_ftrace_direct);
 
 static int
-- 
2.39.5





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux