From: Chengming Zhou <zhouchengming@bytedance.com>
To: rostedt@goodmis.org, mingo@redhat.com, linux-kernel@vger.kernel.org
Cc: songmuchun@bytedance.com, zhouchengming@bytedance.com
Subject: [PATCH 1/2] ftrace: clear module from hash of all ftrace ops
Date: Tue, 28 Jul 2020 18:27:19 +0800 [thread overview]
Message-ID: <20200728102720.46837-1-zhouchengming@bytedance.com> (raw)
We should clear module from hash of all ops on ftrace_ops_list when
module going, or the ops including these modules will be matched
wrongly by new module loaded later.
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
---
kernel/trace/ftrace.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1903b80db6eb..fca01a168ae5 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6223,18 +6223,20 @@ clear_mod_from_hash(struct ftrace_page *pg, struct ftrace_hash *hash)
/* Clear any records from hashs */
static void clear_mod_from_hashes(struct ftrace_page *pg)
{
- struct trace_array *tr;
+ struct ftrace_ops *op;
- mutex_lock(&trace_types_lock);
- list_for_each_entry(tr, &ftrace_trace_arrays, list) {
- if (!tr->ops || !tr->ops->func_hash)
+ mutex_lock(&ftrace_lock);
+
+ do_for_each_ftrace_op(op, ftrace_ops_list) {
+ if (!op->func_hash)
continue;
- mutex_lock(&tr->ops->func_hash->regex_lock);
- clear_mod_from_hash(pg, tr->ops->func_hash->filter_hash);
- clear_mod_from_hash(pg, tr->ops->func_hash->notrace_hash);
- mutex_unlock(&tr->ops->func_hash->regex_lock);
- }
- mutex_unlock(&trace_types_lock);
+ mutex_lock(&op->func_hash->regex_lock);
+ clear_mod_from_hash(pg, op->func_hash->filter_hash);
+ clear_mod_from_hash(pg, op->func_hash->notrace_hash);
+ mutex_unlock(&op->func_hash->regex_lock);
+ } while_for_each_ftrace_op(op);
+
+ mutex_unlock(&ftrace_lock);
}
static void ftrace_free_mod_map(struct rcu_head *rcu)
--
2.20.1
next reply other threads:[~2020-07-28 10:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 10:27 Chengming Zhou [this message]
2020-07-28 10:27 ` [PATCH 2/2] ftrace: setup correct flags before replace code of module rec Chengming Zhou
2020-07-28 13:02 ` Steven Rostedt
2020-07-28 17:29 ` [External] " Chengming Zhou
2020-07-28 12:53 ` [PATCH 1/2] ftrace: clear module from hash of all ftrace ops Steven Rostedt
2020-07-28 16:59 ` [External] " Chengming Zhou
2020-07-28 17:26 ` Steven Rostedt
2020-07-31 4:00 ` Chengming Zhou
2020-08-10 2:54 ` [ftrace] a89282bc45: WARNING:possible_circular_locking_dependency_detected kernel test robot
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=20200728102720.46837-1-zhouchengming@bytedance.com \
--to=zhouchengming@bytedance.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=songmuchun@bytedance.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