From: Jiri Olsa <jolsa@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
lkml <linux-kernel@vger.kernel.org>,
Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@chromium.org>,
"Naveen N . Rao" <naveen.n.rao@linux.ibm.com>,
Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>,
"David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH v5 1/9] ftrace: Add ftrace_set_filter_ips function
Date: Tue, 25 Jan 2022 17:46:07 +0100 [thread overview]
Message-ID: <YfApT8uAoCODPAGu@krava> (raw)
In-Reply-To: <20220125110659.2cc8df29@gandalf.local.home>
On Tue, Jan 25, 2022 at 11:06:59AM -0500, Steven Rostedt wrote:
SNIP
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index be5f6b32a012..39350aa38649 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -4958,7 +4958,7 @@ ftrace_notrace_write(struct file *file, const char __user *ubuf,
> > }
> >
> > static int
> > -ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
> > +__ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
> > {
> > struct ftrace_func_entry *entry;
> >
> > @@ -4976,9 +4976,25 @@ ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove)
> > return add_hash_entry(hash, ip);
> > }
> >
> > +static int
> > +ftrace_match_addr(struct ftrace_hash *hash, unsigned long *ips,
> > + unsigned int cnt, int remove)
> > +{
> > + unsigned int i;
> > + int err;
> > +
> > + for (i = 0; i < cnt; i++) {
> > + err = __ftrace_match_addr(hash, ips[i], remove);
> > + if (err)
> > + return err;
>
> On error should we revert what was done?
>
> goto err;
> > + }
> > + return 0;
>
> err:
> for (i--; i >= 0; i--)
> __ftrace_match_addr(hash, ips[i], !remove);
> return err;
>
> Although it may not matter as it looks like it is only used on a temporary
> hash. But either it should be commented that is the case, or we do the above
> just to be more robust.
yes, that's the case.. it populates just the hash at this point
and if __ftrace_match_addr fails, the thehash is relased after
jumping to out_regex_unlock
>
> > +}
> > +
> > static int
> > ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
> > - unsigned long ip, int remove, int reset, int enable)
> > + unsigned long *ips, unsigned int cnt,
> > + int remove, int reset, int enable)
> > {
> > struct ftrace_hash **orig_hash;
> > struct ftrace_hash *hash;
> > @@ -5008,8 +5024,8 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
> > ret = -EINVAL;
> > goto out_regex_unlock;
> > }
> > - if (ip) {
> > - ret = ftrace_match_addr(hash, ip, remove);
> > + if (ips) {
> > + ret = ftrace_match_addr(hash, ips, cnt, remove);
> > if (ret < 0)
> > goto out_regex_unlock;
> > }
> > @@ -5026,10 +5042,10 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
> > }
> >
> > static int
> > -ftrace_set_addr(struct ftrace_ops *ops, unsigned long ip, int remove,
> > - int reset, int enable)
> > +ftrace_set_addr(struct ftrace_ops *ops, unsigned long *ips, unsigned int cnt,
> > + int remove, int reset, int enable)
> > {
> > - return ftrace_set_hash(ops, NULL, 0, ip, remove, reset, enable);
> > + return ftrace_set_hash(ops, NULL, 0, ips, cnt, remove, reset, enable);
> > }
> >
> > #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
> > @@ -5634,10 +5650,29 @@ int ftrace_set_filter_ip(struct ftrace_ops *ops, unsigned long ip,
> > int remove, int reset)
> > {
> > ftrace_ops_init(ops);
> > - return ftrace_set_addr(ops, ip, remove, reset, 1);
> > + return ftrace_set_addr(ops, &ip, 1, remove, reset, 1);
> > }
> > EXPORT_SYMBOL_GPL(ftrace_set_filter_ip);
> >
> > +/**
> > + * ftrace_set_filter_ips - set a functions to filter on in ftrace by addresses
>
> - set functions to filter on ...
will fix,
thanks,
jirka
next prev parent reply other threads:[~2022-01-25 16:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-25 12:11 [PATCH v5 0/9] fprobe: Introduce fprobe function entry/exit probe Masami Hiramatsu
2022-01-25 12:11 ` [PATCH v5 1/9] ftrace: Add ftrace_set_filter_ips function Masami Hiramatsu
2022-01-25 16:06 ` Steven Rostedt
2022-01-25 16:46 ` Jiri Olsa [this message]
2022-01-28 2:05 ` Masami Hiramatsu
2022-01-28 9:37 ` Jiri Olsa
2022-01-25 12:11 ` [PATCH v5 2/9] fprobe: Add ftrace based probe APIs Masami Hiramatsu
2022-01-25 16:21 ` Steven Rostedt
2022-01-26 9:06 ` Masami Hiramatsu
2022-01-25 16:41 ` Jiri Olsa
2022-01-25 18:11 ` Jiri Olsa
2022-01-26 2:50 ` Masami Hiramatsu
2022-01-26 15:59 ` Masami Hiramatsu
2022-01-26 18:39 ` Jiri Olsa
2022-01-25 12:12 ` [PATCH v5 3/9] rethook: Add a generic return hook Masami Hiramatsu
2022-01-25 16:46 ` Steven Rostedt
2022-01-26 0:10 ` Masami Hiramatsu
2022-01-26 5:29 ` Masami Hiramatsu
2022-01-25 12:12 ` [PATCH v5 4/9] rethook: x86: Add rethook x86 implementation Masami Hiramatsu
2022-01-25 12:12 ` [PATCH v5 5/9] ARM: rethook: Add rethook arm implementation Masami Hiramatsu
2022-01-25 12:12 ` [PATCH v5 6/9] arm64: rethook: Add arm64 rethook implementation Masami Hiramatsu
2022-01-25 12:12 ` [PATCH v5 7/9] fprobe: Add exit_handler support Masami Hiramatsu
2022-01-25 17:08 ` Steven Rostedt
2022-01-25 12:13 ` [PATCH v5 8/9] fprobe: Add sample program for fprobe Masami Hiramatsu
2022-01-25 12:13 ` [PATCH v5 9/9] docs: fprobe: Add fprobe description to ftrace-use.rst Masami Hiramatsu
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=YfApT8uAoCODPAGu@krava \
--to=jolsa@redhat.com \
--cc=andrii@kernel.org \
--cc=anil.s.keshavamurthy@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).