[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240604081229.8d80bee75a29663f3b61322d@kernel.org>
Date: Tue, 4 Jun 2024 08:12:29 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org, Mark
Rutland <mark.rutland@....com>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, Andrew Morton
<akpm@...ux-foundation.org>, Alexei Starovoitov
<alexei.starovoitov@...il.com>, Florent Revest <revest@...omium.org>,
Martin KaFai Lau <martin.lau@...ux.dev>, bpf <bpf@...r.kernel.org>, Sven
Schnelle <svens@...ux.ibm.com>, Alexei Starovoitov <ast@...nel.org>, Jiri
Olsa <jolsa@...nel.org>, Arnaldo Carvalho de Melo <acme@...nel.org>, Daniel
Borkmann <daniel@...earbox.net>, Alan Maguire <alan.maguire@...cle.com>,
Peter Zijlstra <peterz@...radead.org>, Thomas Gleixner
<tglx@...utronix.de>, Guo Ren <guoren@...nel.org>
Subject: Re: [PATCH v2 11/27] ftrace: Allow subops filtering to be modified
On Mon, 3 Jun 2024 10:52:50 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:
> On Mon, 3 Jun 2024 11:37:23 +0900
> Masami Hiramatsu (Google) <mhiramat@...nel.org> wrote:
>
> > On Sat, 01 Jun 2024 23:37:55 -0400
> > Steven Rostedt <rostedt@...dmis.org> wrote:
> >
> > [...]
> > >
> > > +static int ftrace_hash_move_and_update_subops(struct ftrace_ops *subops,
> > > + struct ftrace_hash **orig_subhash,
> > > + struct ftrace_hash *hash,
> > > + int enable)
> > > +{
> > > + struct ftrace_ops *ops = subops->managed;
> > > + struct ftrace_hash **orig_hash;
> > > + struct ftrace_hash *save_hash;
> > > + struct ftrace_hash *new_hash;
> > > + int ret;
> > > +
> > > + /* Manager ops can not be subops (yet) */
> > > + if (WARN_ON_ONCE(!ops || ops->flags & FTRACE_OPS_FL_SUBOP))
> > > + return -EINVAL;
> >
> > This does return if ops->flags & FTRACE_OPS_FL_SUBOP, but --> (1)
>
> Yes, because what is passed in is "subops" and "ops" is subops->managed.
Ah, I missed that point. OK, I got it.
>
> >
> > > +
> > > + /* Move the new hash over to the subops hash */
> > > + save_hash = *orig_subhash;
> > > + *orig_subhash = __ftrace_hash_move(hash);
> > > + if (!*orig_subhash) {
> > > + *orig_subhash = save_hash;
> > > + return -ENOMEM;
> > > + }
> > > +
> > > + /* Create a new_hash to hold the ops new functions */
> > > + if (enable) {
> > > + orig_hash = &ops->func_hash->filter_hash;
> > > + new_hash = append_hashes(ops);
> > > + } else {
> > > + orig_hash = &ops->func_hash->notrace_hash;
> > > + new_hash = intersect_hashes(ops);
> > > + }
> > > +
> > > + /* Move the hash over to the new hash */
> > > + ret = ftrace_hash_move_and_update_ops(ops, orig_hash, new_hash, enable);
So this `ops` is managed ops of this subops.
> >
> > This also a bit wired to me. maybe we need simple version like
> >
> > `__ftrace_hash_move_and_update_ops()`
> >
> > And call it from ftrace_hash_move_and_update_ops() and here?
>
> We could do that. I almost did due to other issues but I reworked the code
> where I didn't need to.
>
> >
> > > +
> > > + free_ftrace_hash(new_hash);
> > > +
> > > + if (ret) {
> > > + /* Put back the original hash */
> > > + free_ftrace_hash_rcu(*orig_subhash);
> > > + *orig_subhash = save_hash;
> > > + } else {
> > > + free_ftrace_hash_rcu(save_hash);
> > > + }
> > > + return ret;
> > > +}
> > > +
> > > +
> > > static u64 ftrace_update_time;
> > > unsigned long ftrace_update_tot_cnt;
> > > unsigned long ftrace_number_of_pages;
> > > @@ -4770,8 +4823,33 @@ static int ftrace_hash_move_and_update_ops(struct ftrace_ops *ops,
> > > {
> > > struct ftrace_ops_hash old_hash_ops;
> > > struct ftrace_hash *old_hash;
> > > + struct ftrace_ops *op;
> > > int ret;
> > >
> > > + if (ops->flags & FTRACE_OPS_FL_SUBOP)
> > > + return ftrace_hash_move_and_update_subops(ops, orig_hash, hash, enable);
> >
> > (1) This calls ftrace_hash_move_and_update_subops() if ops->flags & FTRACE_OPS_FL_SUBOP ?
>
> Yes, because ops turns into subops, and the ops above it is its manager ops.
Ah, OK. This `ops` is a subops.
Thank you,
>
> -- Steve
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists