From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, "stable@vger.kernel.org,
George Guo" <guodongtai@kylinos.cn>,
Tom Zanussi <tom.zanussi@linux.intel.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
"Steven Rostedt (VMware)" <rostedt@goodmis.org>,
George Guo <guodongtai@kylinos.cn>
Subject: [PATCH 4.19 07/18] tracing: Remove unneeded synth_event_mutex
Date: Thu, 23 May 2024 15:12:30 +0200 [thread overview]
Message-ID: <20240523130326.011328258@linuxfoundation.org> (raw)
In-Reply-To: <20240523130325.727602650@linuxfoundation.org>
4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <mhiramat@kernel.org>
commit 0e2b81f7b52a1c1a8c46986f9ca01eb7b3c421f8 upstream.
Rmove unneeded synth_event_mutex. This mutex protects the reference
count in synth_event, however, those operational points are already
protected by event_mutex.
1. In __create_synth_event() and create_or_delete_synth_event(),
those synth_event_mutex clearly obtained right after event_mutex.
2. event_hist_trigger_func() is trigger_hist_cmd.func() which is
called by trigger_process_regex(), which is a part of
event_trigger_regex_write() and this function takes event_mutex.
3. hist_unreg_all() is trigger_hist_cmd.unreg_all() which is called
by event_trigger_regex_open() and it takes event_mutex.
4. onmatch_destroy() and onmatch_create() have long call tree,
but both are finally invoked from event_trigger_regex_write()
and event_trace_del_tracer(), former takes event_mutex, and latter
ensures called under event_mutex locked.
Finally, I ensured there is no resource conflict. For safety,
I added lockdep_assert_held(&event_mutex) for each function.
Link: http://lkml.kernel.org/r/154140864134.17322.4796059721306031894.stgit@devbox
Reviewed-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Tested-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: George Guo <guodongtai@kylinos.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/trace/trace_events_hist.c | 30 +++++++-----------------------
1 file changed, 7 insertions(+), 23 deletions(-)
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -443,8 +443,6 @@ static bool have_hist_err(void)
return false;
}
-static DEFINE_MUTEX(synth_event_mutex);
-
struct synth_trace_event {
struct trace_entry ent;
u64 fields[];
@@ -1097,7 +1095,6 @@ static int __create_synth_event(int argc
return -EINVAL;
mutex_lock(&event_mutex);
- mutex_lock(&synth_event_mutex);
event = find_synth_event(name);
if (event) {
@@ -1139,7 +1136,6 @@ static int __create_synth_event(int argc
else
free_synth_event(event);
out:
- mutex_unlock(&synth_event_mutex);
mutex_unlock(&event_mutex);
return ret;
@@ -1159,7 +1155,6 @@ static int create_or_delete_synth_event(
/* trace_run_command() ensures argc != 0 */
if (name[0] == '!') {
mutex_lock(&event_mutex);
- mutex_lock(&synth_event_mutex);
event = find_synth_event(name + 1);
if (event) {
if (event->ref)
@@ -1173,7 +1168,6 @@ static int create_or_delete_synth_event(
}
} else
ret = -ENOENT;
- mutex_unlock(&synth_event_mutex);
mutex_unlock(&event_mutex);
return ret;
}
@@ -3660,7 +3654,7 @@ static void onmatch_destroy(struct actio
{
unsigned int i;
- mutex_lock(&synth_event_mutex);
+ lockdep_assert_held(&event_mutex);
kfree(data->onmatch.match_event);
kfree(data->onmatch.match_event_system);
@@ -3673,8 +3667,6 @@ static void onmatch_destroy(struct actio
data->onmatch.synth_event->ref--;
kfree(data);
-
- mutex_unlock(&synth_event_mutex);
}
static void destroy_field_var(struct field_var *field_var)
@@ -3810,15 +3802,14 @@ static int onmatch_create(struct hist_tr
struct synth_event *event;
int ret = 0;
- mutex_lock(&synth_event_mutex);
+ lockdep_assert_held(&event_mutex);
+
event = find_synth_event(data->onmatch.synth_event_name);
if (!event) {
hist_err("onmatch: Couldn't find synthetic event: ", data->onmatch.synth_event_name);
- mutex_unlock(&synth_event_mutex);
return -EINVAL;
}
event->ref++;
- mutex_unlock(&synth_event_mutex);
var_ref_idx = hist_data->n_var_refs;
@@ -3892,9 +3883,7 @@ static int onmatch_create(struct hist_tr
out:
return ret;
err:
- mutex_lock(&synth_event_mutex);
event->ref--;
- mutex_unlock(&synth_event_mutex);
goto out;
}
@@ -5611,6 +5600,8 @@ static void hist_unreg_all(struct trace_
struct synth_event *se;
const char *se_name;
+ lockdep_assert_held(&event_mutex);
+
if (hist_file_check_refs(file))
return;
@@ -5620,12 +5611,10 @@ static void hist_unreg_all(struct trace_
list_del_rcu(&test->list);
trace_event_trigger_enable_disable(file, 0);
- mutex_lock(&synth_event_mutex);
se_name = trace_event_name(file->event_call);
se = find_synth_event(se_name);
if (se)
se->ref--;
- mutex_unlock(&synth_event_mutex);
update_cond_flag(file);
if (hist_data->enable_timestamps)
@@ -5651,6 +5640,8 @@ static int event_hist_trigger_func(struc
char *trigger, *p;
int ret = 0;
+ lockdep_assert_held(&event_mutex);
+
if (glob && strlen(glob)) {
last_cmd_set(param);
hist_err_clear();
@@ -5741,14 +5732,10 @@ static int event_hist_trigger_func(struc
}
cmd_ops->unreg(glob+1, trigger_ops, trigger_data, file);
-
- mutex_lock(&synth_event_mutex);
se_name = trace_event_name(file->event_call);
se = find_synth_event(se_name);
if (se)
se->ref--;
- mutex_unlock(&synth_event_mutex);
-
ret = 0;
goto out_free;
}
@@ -5787,13 +5774,10 @@ enable:
if (ret)
goto out_unreg;
- mutex_lock(&synth_event_mutex);
se_name = trace_event_name(file->event_call);
se = find_synth_event(se_name);
if (se)
se->ref++;
- mutex_unlock(&synth_event_mutex);
-
/* Just return zero, not the number of registered triggers */
ret = 0;
out:
next prev parent reply other threads:[~2024-05-23 13:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 13:12 [PATCH 4.19 00/18] 4.19.315-rc1 review Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 01/18] Revert "selftests: mm: fix map_hugetlb failure on 64K page size systems" Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 02/18] dm: limit the number of targets and parameter size area Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 03/18] btrfs: add missing mutex_unlock in btrfs_relocate_sys_chunks() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 04/18] tracing: Simplify creation and deletion of synthetic events Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 05/18] tracing: Add unified dynamic event framework Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 06/18] tracing: Use dyn_event framework for synthetic events Greg Kroah-Hartman
2024-05-23 13:12 ` Greg Kroah-Hartman [this message]
2024-05-23 13:12 ` [PATCH 4.19 08/18] tracing: Consolidate trace_add/remove_event_call back to the nolock functions Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 09/18] string.h: Add str_has_prefix() helper function Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 10/18] tracing: Use str_has_prefix() helper for histogram code Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 11/18] tracing: Use str_has_prefix() instead of using fixed sizes Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 12/18] tracing: Have the historgram use the result of str_has_prefix() for len of prefix Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 13/18] tracing: Refactor hist trigger action code Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 14/18] tracing: Split up onmatch action data Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 15/18] tracing: Generalize hist trigger onmax and save action Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 16/18] tracing: Remove unnecessary var_ref destroy in track_data_destroy() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 17/18] serial: kgdboc: Fix NMI-safety problems from keyboard reset code Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 4.19 18/18] docs: kernel_include.py: Cope with docutils 0.21 Greg Kroah-Hartman
2024-05-24 6:55 ` [PATCH 4.19 00/18] 4.19.315-rc1 review Harshit Mogalapalli
2024-05-24 11:23 ` Pavel Machek
2024-05-24 13:46 ` Anders Roxell
2024-05-24 15:19 ` Jon Hunter
2024-05-24 16:26 ` Shuah Khan
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=20240523130326.011328258@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=guodongtai@kylinos.cn \
--cc=mhiramat@kernel.org \
--cc=patches@lists.linux.dev \
--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