public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: George Guo <dongtai.guo@linux.dev>
To: gregkh@linuxfoundation.org, rostedt@goodmis.org,
	mhiramat@kernel.org, tom.zanussi@linux.intel.com
Cc: stable@vger.kernel.org, George Guo <guodongtai@kylinos.cn>
Subject: [PATCH 4.19.y 05/13] tracing: Consolidate trace_add/remove_event_call back to the nolock functions
Date: Thu,  9 May 2024 10:29:23 +0800	[thread overview]
Message-ID: <20240509022931.3513365-6-dongtai.guo@linux.dev> (raw)
In-Reply-To: <20240509022931.3513365-1-dongtai.guo@linux.dev>

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

commit 7e1413edd6194a9807aa5f3ac0378b9b4b9da879 upstream.

The trace_add/remove_event_call_nolock() functions were added to allow
the tace_add/remove_event_call() code be called when the event_mutex
lock was already taken. Now that all callers are done within the
event_mutex, there's no reason to have two different interfaces.

Remove the current wrapper trace_add/remove_event_call()s and rename the
_nolock versions back to the original names.

Link: http://lkml.kernel.org/r/154140866955.17322.2081425494660638846.stgit@devbox

Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 include/linux/trace_events.h     |  2 --
 kernel/trace/trace_events.c      | 30 ++++--------------------------
 kernel/trace/trace_events_hist.c |  6 +++---
 3 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 755daada7def..f4077379420f 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -529,8 +529,6 @@ extern int trace_event_raw_init(struct trace_event_call *call);
 extern int trace_define_field(struct trace_event_call *call, const char *type,
 			      const char *name, int offset, int size,
 			      int is_signed, int filter_type);
-extern int trace_add_event_call_nolock(struct trace_event_call *call);
-extern int trace_remove_event_call_nolock(struct trace_event_call *call);
 extern int trace_add_event_call(struct trace_event_call *call);
 extern int trace_remove_event_call(struct trace_event_call *call);
 extern int trace_event_get_offsets(struct trace_event_call *call);
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 2830a9cbe648..949eac9362a6 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2312,7 +2312,8 @@ __trace_early_add_new_event(struct trace_event_call *call,
 struct ftrace_module_file_ops;
 static void __add_event_to_tracers(struct trace_event_call *call);
 
-int trace_add_event_call_nolock(struct trace_event_call *call)
+/* Add an additional event_call dynamically */
+int trace_add_event_call(struct trace_event_call *call)
 {
 	int ret;
 	lockdep_assert_held(&event_mutex);
@@ -2327,17 +2328,6 @@ int trace_add_event_call_nolock(struct trace_event_call *call)
 	return ret;
 }
 
-/* Add an additional event_call dynamically */
-int trace_add_event_call(struct trace_event_call *call)
-{
-	int ret;
-
-	mutex_lock(&event_mutex);
-	ret = trace_add_event_call_nolock(call);
-	mutex_unlock(&event_mutex);
-	return ret;
-}
-
 /*
  * Must be called under locking of trace_types_lock, event_mutex and
  * trace_event_sem.
@@ -2383,8 +2373,8 @@ static int probe_remove_event_call(struct trace_event_call *call)
 	return 0;
 }
 
-/* no event_mutex version */
-int trace_remove_event_call_nolock(struct trace_event_call *call)
+/* Remove an event_call */
+int trace_remove_event_call(struct trace_event_call *call)
 {
 	int ret;
 
@@ -2399,18 +2389,6 @@ int trace_remove_event_call_nolock(struct trace_event_call *call)
 	return ret;
 }
 
-/* Remove an event_call */
-int trace_remove_event_call(struct trace_event_call *call)
-{
-	int ret;
-
-	mutex_lock(&event_mutex);
-	ret = trace_remove_event_call_nolock(call);
-	mutex_unlock(&event_mutex);
-
-	return ret;
-}
-
 #define for_each_event(event, start, end)			\
 	for (event = start;					\
 	     (unsigned long)event < (unsigned long)end;		\
diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 1a32b64d350b..1139075a6395 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -980,7 +980,7 @@ static int register_synth_event(struct synth_event *event)
 	call->data = event;
 	call->tp = event->tp;
 
-	ret = trace_add_event_call_nolock(call);
+	ret = trace_add_event_call(call);
 	if (ret) {
 		pr_warn("Failed to register synthetic event: %s\n",
 			trace_event_name(call));
@@ -989,7 +989,7 @@ static int register_synth_event(struct synth_event *event)
 
 	ret = set_synth_event_print_fmt(call);
 	if (ret < 0) {
-		trace_remove_event_call_nolock(call);
+		trace_remove_event_call(call);
 		goto err;
 	}
  out:
@@ -1004,7 +1004,7 @@ static int unregister_synth_event(struct synth_event *event)
 	struct trace_event_call *call = &event->call;
 	int ret;
 
-	ret = trace_remove_event_call_nolock(call);
+	ret = trace_remove_event_call(call);
 
 	return ret;
 }
-- 
2.34.1


  parent reply	other threads:[~2024-05-09  2:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09  2:29 [PATCH 4.19.y 00/13] fix double-free bug causing by destroy_hist_field(data->onmax.var, 0) George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 01/13] tracing: Simplify creation and deletion of synthetic events George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 02/13] tracing: Add unified dynamic event framework George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 03/13] tracing: Use dyn_event framework for synthetic events George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 04/13] tracing: Remove unneeded synth_event_mutex George Guo
2024-05-09  2:29 ` George Guo [this message]
2024-05-09  2:29 ` [PATCH 4.19.y 06/13] string.h: Add str_has_prefix() helper function George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 07/13] tracing: Use str_has_prefix() helper for histogram code George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 08/13] tracing: Use str_has_prefix() instead of using fixed sizes George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 09/13] tracing: Have the historgram use the result of str_has_prefix() for len of prefix George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 10/13] tracing: Refactor hist trigger action code George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 11/13] tracing: Split up onmatch action data George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 12/13] tracing: Generalize hist trigger onmax and save action George Guo
2024-05-09  2:29 ` [PATCH 4.19.y 13/13] tracing: Remove unnecessary var_ref destroy in track_data_destroy() George Guo
2024-05-23 12:09 ` [PATCH 4.19.y 00/13] fix double-free bug causing by destroy_hist_field(data->onmax.var, 0) Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509022931.3513365-6-dongtai.guo@linux.dev \
    --to=dongtai.guo@linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=guodongtai@kylinos.cn \
    --cc=mhiramat@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    --cc=tom.zanussi@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox