From: Steven Rostedt <rostedt@goodmis.org>
To: Chengming Zhou <zhouchengming@bytedance.com>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, songmuchun@bytedance.com
Subject: Re: [External] Re: [PATCH 1/2] ftrace: clear module from hash of all ftrace ops
Date: Tue, 28 Jul 2020 13:26:30 -0400 [thread overview]
Message-ID: <20200728132630.678f94f7@oasis.local.home> (raw)
In-Reply-To: <557fa115-1247-e058-4a18-e73f6fb7d636@bytedance.com>
On Wed, 29 Jul 2020 00:59:33 +0800
Chengming Zhou <zhouchengming@bytedance.com> wrote:
> > i.e.
> >
> > # echo some_module_function > set_ftrace_filter
> > # rmmod module_with_that_function
> > # insmod module_with_same_address_of_function
> > # echo function > current_tracer
> >
> > Now the tr->ops->hash would still have the function of the original
> > module.
>
> I thought all ftrace_ops has non empty func_hash are on the ftrace
> global list...
Nope, the two are disjoint.
>
> Well, so I just leave this function unmodified.
>
> Just call that new function register_ftrace_ops_hash() from
> ftrace_release_mod.
I would say to have anything that uses one of the
ftrace_set_filter/notrace* functions, to also register itself for
module removal.
register_ftrace_mod_removal(struct ftrace_ops *ops);
and then also have a unregister_ftrace_mod_removal() as there needs to
be a way to remove it from the list before the ops gets freed.
Then these functions would add the ops to a list, and this list is
traversed to remove modules. The trace_arrays can register their ops
too, so you can update that function.
-- Steve
>
> Thanks!
>
> >
> > Either have all owners of ftrace_ops handle this case, or add a helper
> > function to handle it for them. But using ftarce_ops_list is the wrong
> > place to do it.
> >
> > -- Steve
> >
> >
> >> + 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)
next prev parent reply other threads:[~2020-07-28 17:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-28 10:27 [PATCH 1/2] ftrace: clear module from hash of all ftrace ops Chengming Zhou
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 [this message]
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=20200728132630.678f94f7@oasis.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=songmuchun@bytedance.com \
--cc=zhouchengming@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